-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
120 lines (94 loc) · 3.22 KB
/
Copy pathapp.py
File metadata and controls
120 lines (94 loc) · 3.22 KB
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
from flask import Flask,request,jsonify
from flask_cors import CORS
from cvefinder.getPackagesandVulnerabilities import *
from cvefinder.CVEScorefinder import *
from webscan.webapplinkfinder import getWebAppLink
from webscan.ajaxspider import ajaxSpider
from webscan.passivescan import passiveScan
from webscan.spiderscan import spiderScan
from webscan.activeScan import activeScan
from secretscanner.filefinder import findAllFiles
from secretscanner.filesecrets import findSecrets
app = Flask(__name__)
CORS(app)
@app.route("/")
def index():
return "Flask Server Working !!!"
@app.route("/getvulnerablepackages",methods = ['GET'])
def find_vulnerable_packages():
url = request.args.get('url')
rightLink = projectLink(url)
if "http" not in rightLink:
return jsonify({"error":rightLink}),400
weblink = getWebAppLink(rightLink)
if "http" not in weblink:
weblink = None
packages = findPackages(rightLink)
if type(packages) == str:
return jsonify({"error":packages}),400
data = {
'orginalurl':url,
'projecturl':rightLink,
'packages':[],
'webLink' : weblink,
'CVSS_Score' : 0,
}
total_CVSS_Score = 0
ans = 0
for elem in packages:
package_CVSS_Score = 0
package = {
'name': elem,
'version' : packages[elem],
'vulnerability': [],
'CVSS_Score' : 0,
}
vulnerabilityData = findVulnerability(elem,packages[elem])
for el in vulnerabilityData:
package['vulnerability'].append({
'CVE' : el,
'description' : vulnerabilityData[el],
'CVSS_Score' : findCVEScore(el)
})
package_CVSS_Score += findCVEScore(el)
if len(package['vulnerability']) > 0:
ans += 1
package['CVSS_Score'] = package_CVSS_Score/len(package['vulnerability'])
data['packages'].append(package)
total_CVSS_Score += package['CVSS_Score']
if len(data['packages']) > 0:
data['CVSS_Score'] = total_CVSS_Score/ans
return jsonify(data)
@app.route("/runscan",methods = ['GET'])
def runScan():
url = request.args.get('url')
spider = request.args.get('spider')
ajaxspider = request.args.get('ajaxspider')
passivescan = request.args.get('passivescan')
activescan = request.args.get('activescan')
if spider == 'true':
results = spiderScan(url)
elif ajaxspider == 'true':
results = ajaxSpider(url)
elif passivescan == 'true':
results = passiveScan(url)
else :
results = activeScan(url)
if type(results) == str:
return jsonify({"error" : results}),400
return jsonify(results)
@app.route("/findsecrets",methods = ['GET'])
def findsecrets():
url = request.args.get('url')
filedata = findAllFiles(url)
if type(filedata) == str:
return jsonify({'error' : filedata}),400
final_data = []
for elem in filedata:
final_data.append({
'file' : elem['name'],
'url' : elem['url'],
'secrets' : findSecrets(elem['url'])
})
return jsonify(final_data)
app.run(port = 8000, debug = True, threaded = True)