-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.py
230 lines (207 loc) · 8.3 KB
/
server.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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
from flask import Flask, redirect, request, url_for, render_template, jsonify
from models import hostScanner, portScanner, routeGetter, topoDrawer, vulFinder, webScanner, appScanner
import os
from flask_cors import CORS
app = Flask(__name__, static_folder=os.path.abspath("./templates/"), static_url_path="")
CORS(app, resources={r"/*": {"origins": "*"}})
hostInfo = {}
hostList = []
@app.route('/topoList', methods=['post'])
def topoList():
global hostInfo
global hostList
fromIp = request.json.get("fromIp")
toIp = request.json.get("toIp")
hostInfo = hostScanner.main(fromIp, toIp)
hostList = list(hostInfo.keys())
nodesArray = []
for ipA in hostList:
ipObj = {"id": ipA, "label": ipA}
nodesArray.append(ipObj)
nodesArray.append({"id": '127.0.0.1', "label": '127.0.0.1'})
print("hhhhhhhhhhhhllllllll:")
print(hostList)
edgesArray = routeGetter.main(hostList)
print(edgesArray)
for edge in edgesArray:
# print(edge)
# print(type(edge))
if (edge["to"] not in hostList):
hostList.append(edge["to"])
nodesArray.append({"id": edge["to"], "label": edge["to"]})
return {"nodesArray": nodesArray, "edgesArray": edgesArray}
@app.route('/basicInform', methods=['post'])
def basicInform():
global hostInfo
ipAddress = request.json.get("ipAddress")
basicList = hostInfo[ipAddress]
data = {"basicInform": {"hostname": basicList[0], "mac_address": basicList[1], "vendor": basicList[2],
"delay": basicList[3]}}
return data
@app.route('/appInform', methods=['post'])
def appInform():
ipAddress = request.json.get("ipAddress")
portList = portScanner.main(ipAddress)
appInformList = []
for port in portList:
appInformItem = appScanner.main([ipAddress, port])
appInformItem2 = {}
appInformItem2["port"] = port
appInformItem2.update(appInformItem)
appInformList.append(appInformItem2)
print(appInformList)
return {"appInform": appInformList}
@app.route('/webInform', methods=['post'])
def webInform():
ipAddress = request.json.get("ipAddress")
portList = portScanner.main(ipAddress)
result = webScanner.main(ipAddress, portList, 1)
print("rrrrrrrrrrrrrrrwebsult")
print(result)
return {"webInform": result}
@app.route('/findVul', methods=['post'])
def findVul():
inKeywordList = request.json.get("keywords")
vulList = []
for keyword in inKeywordList:
vulItem = vulFinder.main(keyword)
# print(vulItem)
for vulItemItem in vulItem:
vulItem2 = {'cve_id': vulItemItem[0], 'info': vulItemItem[1], 'date': vulItemItem[2]}
vulList.append(vulItem2)
print("vulllllllllllllllll")
print(vulList)
return {'vuls': vulList}
# ---------------------------------------------
# @app.route('/topoList', methods=['post'])
# def topoList():
#
# testData = {
# "nodesArray": [
# {"id": "192.168.1.1", "label": "192.168.1.1"},
# {"id": "192.168.1.2", "label": "192.168.1.2"},
# {"id": "192.168.1.3", "label": "192.168.1.3"},
# {"id": "192.168.1.4", "label": "192.168.1.4"}
# ],
# "edgesArray": [
# {"from": "192.168.1.1", "to": "192.168.1.1"},
# {"from": "192.168.1.2", "to": "192.168.1.1"},
# {"from": "192.168.1.3", "to": "192.168.1.1"},
# {"from": "192.168.1.4", "to": "192.168.1.1"},
# {"from": "192.168.1.3", "to": "192.168.1.3"},
# {"from": "192.168.1.3", "to": "192.168.1.2"}
#
# ]
# }
# return testData
# #
# #
# @app.route('/basicInform', methods=['post'])
# def basicInform():
#
# testData = {
# "basicInform": {
# "hostname": "xx2323231xx",
# "mac_address": "132323xxx",
# "vendor": "x3223332xxx",
# "delay": "xx2322323xx"
# }
# }
# return testData
#
# #
# @app.route('/appInform', methods=['post'])
# def appInform():
#
# # testData = {
# # "appInform": [{"port": 252,
# # "service": "ssjjjjjjjjjjjjjjjjjh",
# # "version": "openssh 2.3.3"
# # }, {
# # "port": 2223,
# # "service": "sssssssssssssh",
# # "version": "openssh 2.3.3"
# # }, {
# # "port": 24,
# # "service": "ssssssssssssssssh",
# # "version": "openssh 2.3.3"
# # }, {
# # "port": 25,
# # "service": "ssh",
# # "version": "openssh 2.3.3"
# # }
# # ]
# # }
# testData = [{'port': 7, 'service': 'echo', 'version': ''}, {'port': 9, 'service': 'discard', 'version': ''},
# {'port': 13, 'service': 'daytime', 'version': ''}, {'port': 17, 'service': 'qotd', 'version': ''},
# {'port': 19, 'service': 'chargen', 'version': ''}, {'port': 80, 'service': 'http', 'version': '1.1'},
# {'port': 135, 'service': 'msrpc', 'version': 'Microsoft Windows RPC'},
# {'port': 139, 'service': 'netbios-ssn', 'version': 'Microsoft Windows netbios-ssn'},
# {'port': 443, 'service': 'http', 'version': '1.1'}, {'port': 445, 'service': 'microsoft-ds', 'version': ''},
# {'port': 903, 'service': 'ssl/vmware-auth', 'version': '1.10'}, {'port': 5000, 'service': 'upnp', 'version': ''}]
#
# return testData
# #
# #
# @app.route('/webInform', methods=['post'])
# def webInform():
# testData ={"webInform":[{'port': 7, 'service': 'echo', 'version': ''}, {'port': 9, 'service': 'discard', 'version': ''}, {'port': 13, 'service': 'daytime', 'version': ''}, {'port': 17, 'service': 'qotd', 'version': ''}, {'port': 19, 'service': 'chargen', 'version': ''}, {'port': 80, 'service': 'http', 'version': '1.1'}, {'port': 135, 'service': 'msrpc', 'version': 'Microsoft Windows RPC'}, {'port': 139, 'service': 'netbios-ssn', 'version': 'Microsoft Windows netbios-ssn'}, {'port': 443, 'service': 'http', 'version': '1.1'}, {'port': 445, 'service': 'microsoft-ds', 'version': ''}, {'port': 903, 'service': 'ssl/vmware-auth', 'version': '1.10'}, {'port': 5000, 'service': 'upnp', 'version': ''}]}
# # testData = {
# # "webInform": [
# # {
# # "port": "225555555555555",
# # "cdn": "cdnx232xxx",
# # "cms": "cmsxxxx",
# # "framework": "frame23workxxxx",
# # "frontend": "fronte23ndxxxx",
# # "lang": "langxxx",
# # "server": "serverxxxx",
# # "system": "systemxxxx",
# # "waf": "wafxxxx"
# # },
# # {
# # "port": "80",
# # "cdn": "cdnxxxx",
# # "cms": "cmsxxxx",
# # "framework": "f33rameworkxxxx",
# # "frontend": "fro33ntendxxxx",
# # "lang": "langxxx",
# # "server": "serverxxxx",
# # "system": "systemxxxx",
# # "waf": "wafxxxx"
# # },
# # {
# # "port": "9999",
# # "cdn": "cdnxxxx",
# # "cms": "cmsxx32xx",
# # "framework": "frameworkxxxx",
# # "frontend": "frontendxxxx",
# # "lang": "langxxx",
# # "server": "serverxxxx",
# # "system": "systemxxxx",
# # "waf": "wafxxxx"
# # },
# # ]}
# return testData
# #
# #
# @app.route('/findVul', methods=['post'])
# def findVul():
#
# testData = {
# 'vuls': [
# {
# 'cve_id': "CV对方E-2022-34305",
# 'info': 'Apache Tomcat 跨站脚豆腐干地方本漏洞(CVE-2022-34305)',
# 'date': '2022-06-24'
# },
# {
# 'cve_id': "CVE-202豆腐干地方-34305",
# 'info': 'Apache Tomcat 跨站脚到底本漏洞(CVE-2022-34305)',
# 'date': '2022-06的风格-24'
# }
# ],
# }
# return testData
if __name__ == '__main__':
app.run(debug=True, host="0.0.0.0")