1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import ctypes
- import os
- lib = ctypes.CDLL("/var/sandbox/sandbox-python/python.so")
- lib.DifySeccomp.argtypes = [ctypes.c_uint32, ctypes.c_uint32, ctypes.c_bool]
- lib.DifySeccomp.restype = None
- os.chdir("/var/sandbox/sandbox-python")
- lib.DifySeccomp(65537, 1000, 1)
- import sys
- import traceback
- # setup sys.excepthook
- def excepthook(type, value, tb):
- sys.stderr.write("".join(traceback.format_exception(type, value, tb)))
- sys.stderr.flush()
- sys.exit(-1)
- sys.excepthook = excepthook
- code = """
- import json
- # declare main function here
- def main() -> dict:
- import requests
-
- return {
- "result": requests.get("https://www.bilibili.com").text,
- }
- from json import loads, dumps
- from base64 import b64decode
- # execute main function, and return the result
- # inputs is a dict, and it
- inputs = b64decode('e30=').decode('utf-8')
- output = main(**json.loads(inputs))
- # convert output to json and print
- output = dumps(output, indent=4)
- result = f'''<<RESULT>>
- {output}
- <<RESULT>>'''
- print(result)
- """
- exec(code)
|