-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathweb.py
196 lines (154 loc) · 5.13 KB
/
web.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#-*- coding: UTF-8 -*-
#__author__:Bing
#email:[email protected]
from flask import Flask,request,redirect, url_for, render_template
from models import AWVSTask
import json,os
from functools import wraps
app = Flask(__name__)
node_key = "wetk2i97ssd23kjsdhu223fdv234"
#允许访问ip地址
allowip = ['localhost','127.0.0.1']
def blocks(func):
@wraps(func)
def decorator(*args, **kwargs):
remote_ip = request.remote_addr
#return func(*args, **kwargs)
#print remote_ip,"***********"
if str(remote_ip) in allowip:
#print str(remote_ip),allowip
return func(*args, **kwargs)
else:
return json.dumps({"status":0,"data":"record your attack on IP!"})
return decorator
UPLOAD_FOLDER = 'C:\\Users\\Public\\Documents\\Acunetix WVS 10\\LoginSequences'
ALLOWED_EXTENSIONS = set(['lsr'])
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
def allowed_file(filename):
return '.' in filename and filename.rsplit('.',1)[1] in ALLOWED_EXTENSIONS
@app.route('/upfile', methods = ['GET','POST'])
@blocks
def upload_file():
if request.method == 'POST':
file = request.files['file']
if file and allowed_file(file.filename) and ".." not in (file.filename):
filename = file.filename
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
return json.dumps({"status":1})
#redirect(url_for('upload_file', filename = filename));
else:
return json.dumps({"status":0})
else:
return json.dumps({"status":0})
@app.route("/", methods=['POST', 'GET'])
@blocks
def index():
#print request.headers.get('User-Agent')
#request.args.items().__str__()
# remote_ip = request.remote_addr
# print remote_ip,"***********",type(remote_ip)
result = AWVSTask().awvs_count()
if result["status"] == 1:
return json.dumps(result)
else:
return json.dumps(result)
@app.route("/add", methods=['POST', 'GET'])
@blocks
def add():
if request.method == 'POST':
vultype = request.form.get('vultype').encode("gbk")
loginseq = request.form.get('loginseq').encode("gbk")
target = request.form.get('target').encode("gbk")
#print type(vultype),type(loginseq)
if target != "" and target.startswith("http://",0,8) or target.startswith("https://",0,8) and vultype != "":
#多个任务,进行分割
data = []
if "," in target :
try:
content = target.split(",")
except:
result = {"status":0,"data":"error not offer data or format "}
return json.dumps(result)
for line in content:
result = AWVSTask().awvs_add(profile=vultype,loginSeq= "<none>",target=line)
if result["status"] == 1:
res = {"id":result["data"],"target":line,"status":result["status"]}
data.append(res)
else:
res = {"target":line,"status":0}
data.append(res)
else:
try:
content = target.split("\n")
except:
result = {"status":0,"data":"error not offer data or format "}
return json.dumps(result)
for line in content:
result = AWVSTask().awvs_add(profile=vultype,loginSeq= "<none>",target=line)
if result["status"] == 1:
res = {"id":result["data"],"target":line,"status":result["status"]}
data.append(res)
else:
res = {"target":line,"status":0}
data.append(res)
result = {"status":1,"data":data}
return json.dumps(result)
else:
result = {"status":0,"data":"error not offer data or format "}
return json.dumps(result)
else:
result = {"status":0,"data":"no post"}
return json.dumps(result)
@app.route("/del", methods=['POST', 'GET'])
@blocks
def delete():
if request.method == 'POST':
taskid = request.form.get('taskid').encode("gbk")
if taskid != "" :
result = AWVSTask().awvs_delete(taskid)
return json.dumps(result)
else:
result = {"status":0,"data":"error not offer data or format "}
return json.dumps(result)
else:
result = {"status":0,"data":"no post "}
return json.dumps(result)
@app.route("/process", methods=['POST', 'GET'])
@blocks
def process():
if request.method == 'POST':
taskid = request.form.get('taskid').encode("gbk")
if taskid != "" :
result = AWVSTask().awvs_process(taskid)
return json.dumps(result)
else:
result = {"status":0,"data":"error not offer data or format "}
return json.dumps(result)
else:
result = {"status":0,"data":"no post "}
return json.dumps(result)
@app.route("/report", methods=['POST', 'GET'])
@blocks
def report():
if request.method == 'POST':
taskid = request.form.get('taskid').encode("gbk")
if taskid != "" :
result = AWVSTask().awvs_report(taskid)
return json.dumps(result)
else:
result = {"status":0,"data":"error not offer data or format "}
return json.dumps(result)
else:
result = {"status":0,"data":"no post "}
return json.dumps(result)
@app.route("/loginseq", methods=['POST', 'GET'])
@blocks
def loginseq():
result = AWVSTask().awvs_list_loginseq()
if result["status"] == 1:
return json.dumps(result)
else:
return json.dumps(result)
if __name__ == '__main__':
#app.run(port=8080,debug=False)
app.run(host= "0.0.0.0",port = 8080,debug=False)