-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
213 lines (196 loc) · 5.92 KB
/
run.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
'''
The start of the application has all the routes and the app invocation
'''
import os
import logging
from flask import Flask, render_template, send_from_directory, request, redirect, url_for, flash
from setup.db import db, xss, sqlinjection, fuzzing
from setup.file import fileaccess
from setup.execution import execute
APP = Flask(__name__)
APP.secret_key = 'someSecret'
#**************
#Misc Routes
#**************
@APP.route('/')
def index():
'''
Route handler for the home page
'''
return render_template('index.html')
@APP.route('/robots.txt')
def robots():
'''
Route handler for the home page
'''
return send_from_directory(APP.static_folder, 'robots.txt')
@APP.route('/mysecret/')
def secret():
'''
Route handler for the home page
'''
return render_template('./mysecret.html')
@APP.route('/reset/')
def reset():
'''
Route handler page that resets the hole database
'''
db.create(True)
return redirect(url_for('index'))
#**************
#End Misc Routes
#**************
#*************
#XSS Routes
#*************
@APP.route('/xss/reflected/', methods=['GET', 'POST'])
def xss_reflected():
'''
Route handler for the reflected cross site scripting
'''
name = None
if request.values.get('name'):
name = request.values['name']
return render_template('./xss/reflected.html', name=name)
@APP.route('/xss/stored/', methods=['GET', 'POST'])
def xss_stored():
'''
Route handler for the stored cross site scripting
'''
if request.method == 'POST':
name = request.form['name']
comment = request.form['comment']
parentid = request.form['parentID']
if name and comment:
xss.addcomment(name, comment, parentid)
all_rows = xss.getcomments()
return render_template('./xss/stored.html', comments=all_rows)
#**************
#End XSS Routes
#**************
#**************
#SQLI Routes
#**************
@APP.route('/sqli/simple/', methods=['GET', 'POST'])
def sqli_simple():
'''
Route handler for the simple sql injection
'''
comments = None
search = ''
if request.method == 'POST':
search = request.form['search']
comments = sqlinjection.search(search)
return render_template('./sqli/simple.html', comments=comments[1],
search=search, sqlquery=comments[0])
@APP.route('/sqli/simpleescape/', methods=['GET', 'POST'])
def sqli_simpleescape():
'''
Route handler for the simple sql escape injection
'''
comments = None
search = ''
if request.method == 'POST':
search = request.form['search']
search = search.replace(";--", " ")
comments = sqlinjection.search(search)
return render_template('./sqli/simpleescape.html', comments=comments[1],
search=search, sqlquery=comments[0])
@APP.route('/sqli/blind/', methods=['GET', 'POST'])
def sqli_blind():
'''
Route handler for the Blind sql injection page
'''
name = None
phone = None
secret = None
display = 1
if request.method == 'POST':
name = request.form['name']
phone = request.form['phone']
secret = request.form['secret']
if name and phone and secret and display:
flash('Your submission has been saved.', 'success')
sqlinjection.search_insert(name, phone, secret)
else:
flash('Make sure you are filling out all the fields', 'error')
return render_template('./sqli/blindinjection.html', name=name, phone=phone,
secret=secret, display=display)
#**************
#End SQLI Routes
#**************
#**************
#File Routes
#**************
@APP.route('/file/traversal/', methods=['GET'])
def file_traversal():
'''
Route handler for the file traversal page
'''
current_path = fileaccess.fileaccess_getuploadspath()
entered_path = ""
file = None
results = None
if request.values.get('path'):
entered_path = request.values.get('path')
current_path = os.path.join(current_path, *(entered_path.replace('\\', '/').split("/")))
if request.values.get('file'):
file = request.values.get('file')
if fileaccess.fileaccess_fileexists(current_path, file):
return send_from_directory(current_path, file)
results = fileaccess.fileaccess_getfilesandfolders(current_path)
return render_template('./files/traversal.html', path=entered_path, results=results, file=file)
#**************
#End File Routes
#**************
#**************
# Execution Routes
#**************
@APP.route('/execution/simple/', methods=['GET', 'POST'])
def execution_simple():
'''
Route handler for the execute simple page
'''
ip_address = None
results = None
if request.method == 'POST':
ip_address = request.form['ip']
results = execute.execute_ping(ip_address)
return render_template('./execution/simple.html', ip=ip_address, results=results)
#**************
#End Execution Routes
#**************
#**************
#Fuzzing Routes
#**************
@APP.route('/fuzzing/simple/', methods=['GET'], defaults={'id':None})
@APP.route('/fuzzing/simple/<int:id>/', methods=['GET'])
def fuzzing_simple(id):
data = None
if id:
data = fuzzing.getFuzzing(id)
return render_template('./fuzzing/simple.html', data=data)
#**************
#End Execution Routes
#**************
#**************
#Filters
#**************
@APP.template_filter('commentcut')
def commentcut(comments, commentid):
'''
A filter used on the comments to get just
the comments that pertain to the id
'''
if comments:
return (x for x in comments if x[4] == commentid)
return None
#**************
#End Filters
#**************
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG)
logging.info("Starting db Creation")
db.create(False)
logging.info("DB creation script complete.\r\nStarting the server")
APP.run(debug=True, host='0.0.0.0')