This commit is contained in:
t3chn0m4g3
2020-03-03 12:30:57 +00:00
parent 5d7a6f3270
commit 3b8c959c66
3 changed files with 152 additions and 21 deletions

View File

@ -23,12 +23,16 @@ import json
import asyncio
import hashlib
import argparse
import functools
from aiohttp import web
from asyncio.subprocess import PIPE
from pprint import pprint
_pretty_dumps = functools.partial(json.dumps, sort_keys=True, indent=4)
class PHPSandbox(object):
@classmethod
def php_tag_check(cls, script):
@ -51,7 +55,7 @@ class PHPSandbox(object):
self.stdout_value += line + b'\n'
@asyncio.coroutine
def sandbox(self, script, phpbin="php7.0"):
def sandbox(self, script, phpbin="php7"):
if not os.path.isfile(script):
raise Exception("Sample not found: {0}".format(script))
@ -96,12 +100,12 @@ def api(request):
except KeyboardInterrupt:
pass
ret['file_md5'] = file_md5
return web.Response(body=json.dumps(ret, sort_keys=True, indent=4).encode('utf-8'))
return web.json_response(ret, dumps=_pretty_dumps)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument("--phpbin", help="PHP binary, ex: php7.0", default="php7.0")
parser.add_argument("--phpbin", help="PHP binary, ex: php7", default="php7")
args = parser.parse_args()
phpbin = args.phpbin