forked from kenuoseclab/SZhe_Scan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBaseMessage.py
More file actions
137 lines (120 loc) · 4.15 KB
/
BaseMessage.py
File metadata and controls
137 lines (120 loc) · 4.15 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
import requests
import core
import re
import time
from Wappalyzer import WebPage
import get_message
from WebLogicScan import WebLogicScan
from init import app
from exts import db
from models import BugList
from init import redispool
from POCScan import selfpocscan
'''
获取输入网址基础信息:
1,WEB指纹识别,技术识别 Finger
2,状态码 Status
3,标题 Title
4,收录扫描时间 Date
5,响应包 response
6,端口开放信息
'''
class GetBaseMessage():
def __init__(self, url, attackurl,rep):
self.domain = url
self.redispool = redispool
self.url=attackurl
self.rep=rep
def GetStatus(self):
print("正在获取网页状态码!")
try:
return str(self.rep.status_code)
except Exception as e:
print(e)
return "None"
def GetTitle(self):
print("正在获取网页标题!")
if self.rep != None:
try:
title=re.findall('<title>(.*?)</title>', self.rep.text)[0]
return title
except Exception as e:
print(e)
return None
return None
def GetDate(self):
print("正在获取系统当前时间!")
return str(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()))
def GetResponseHeader(self):
print("正在获取网页响应头!")
context = ""
try:
for key, val in self.rep.headers.items():
context += (key + ": " + val + "\r\n")
return context
except Exception as e:
print(e)
return context
def GetFinger(self):
print("正在获取网站指纹及技术!")
try:
finger=WebPage(self.url, self.rep).info()
return finger
except Exception as e:
print(e)
return "Unknow"
def PortScan(self):
print("正在对目标进行端口扫描!")
try:
return get_message.PortScan(self.domain)
except Exception as e:
print(e)
return "Unknow"
def SenDir(self):
print("正在进行敏感目录及文件探测!")
try:
return get_message.SenFileScan(self.domain,self.url)
except Exception as e:
print(e)
return "None"
def WebLogicScan(self):
print("正在进行weblogic漏洞检测!")
try:
results=WebLogicScan.run(self.domain)
with app.app_context():
for result in results:
vulnerable, bugurl, bugname, bugdetail = result
if vulnerable:
bug = BugList(oldurl=self.domain, bugurl=bugurl, bugname=bugname,
buggrade=redispool.hget('bugtype', bugname),
payload=bugurl, bugdetail=bugdetail)
redispool.pfadd(redispool.hget('bugtype', bugname), bugurl)
redispool.pfadd(bugname, bugurl)
db.session.add(bug)
db.session.commit()
except Exception as e:
print(e)
pass
def AngelSwordMain(self):
print("正在使用碎遮内置POC进行漏洞检测!")
try:
selfpocscan.AngelSwordMain(self.url)
except Exception as e:
print(e)
pass
if __name__=='__main__':
# redispool=redis.ConnectionPool(host='127.0.0.1',port=6379, decode_responses=True)
# redispool = redis.Redis(connection_pool=ImportToRedis.redisPool)
try:
rep=requests.get(url="https://www.nowcoder.com",headers=core.GetHeaders(),timeout=10)
test=GetBaseMessage("www.nowcoder.com","https://www.nowcoder.com",rep)
# test.AngelSwordMain()
print(test.GetStatus())
print(test.GetTitle())
print(test.GetResponseHeader())
print(test.GetFinger())
print(test.PortScan())
print(test.SenDir())
except Exception as e:
print(e)
pass