test.py 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import ctypes
  2. import os
  3. import sys
  4. import json
  5. import traceback
  6. # setup sys.excepthook
  7. def excepthook(type, value, tb):
  8. sys.stderr.write("".join(traceback.format_exception(type, value, tb)))
  9. sys.stderr.flush()
  10. sys.exit(-1)
  11. sys.excepthook = excepthook
  12. lib = ctypes.CDLL("/var/sandbox/sandbox-python/python.so")
  13. lib.DifySeccomp.argtypes = [ctypes.c_uint32, ctypes.c_uint32, ctypes.c_bool]
  14. lib.DifySeccomp.restype = None
  15. import json
  16. import os
  17. import json
  18. import sys
  19. import traceback
  20. import os
  21. os.chdir("/var/sandbox/sandbox-python")
  22. lib.DifySeccomp(65537, 1001, 1)
  23. # declare main function here
  24. def main() -> dict:
  25. import requests
  26. return {
  27. "result": "awdawd",
  28. }
  29. from json import loads, dumps
  30. from base64 import b64decode
  31. # execute main function, and return the result
  32. # inputs is a dict, and it
  33. inputs = b64decode('e30=').decode('utf-8')
  34. output = main(**json.loads(inputs))
  35. # convert output to json and print
  36. output = dumps(output, indent=4)
  37. result = f'''<<RESULT>>
  38. {output}
  39. <<RESULT>>'''
  40. print(result)