这个题更偏向于代码审计。耐住性子慢慢理解,还是挺简单的。
很直接哦,就给源码。这么看不好看,得去pycharm里修正一下格式
#放在pycharm里Ctrl+Alt+L将代码格式化一下
1 #! /usr/bin/env python
2 #encoding=utf-8
3 from flask import Flask
4 from flask import request
5 import socket
6 import hashlib
7 import urllib
8 import sys
9 import os
10 import json
11 reload(sys)
12 sys.setdefaultencoding('latin1')
13
14 app = Flask(__name__)
15
16 secert_key = os.urandom(16)
17
18
19 class Task:
20 def __init__(self, action, param, sign, ip):
21 self.action = action
22 self.param = param
23 self.sign = sign
24 self.sandbox = md5(ip)
25 if(not os.path.exists(self.sandbox)): #SandBox For Remote_Addr
26 os.mkdir(self.sandbox)
27
28 def Exec(self):
29 result = {}
30 result['code'] = 500
31 if (self.checkSign()):
32 if "scan" in self.action:
33 tmpfile = open("./%s/result.txt" % self.sandbox, 'w')
34 resp = scan(self.param)
35 if (resp == "Connection Timeout"):
36 result['data'] = resp
37 else:
38 print resp
39 tmpfile.write(resp)
40 tmpfile.close()
41 result['code'] = 200
42 if "read" in self.action:
43 f = open("./%s/result.txt" % self.sandbox, 'r')
44 result[