-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathRSAS批量添加web扫描任务2.1.py
executable file
·280 lines (228 loc) · 9.32 KB
/
RSAS批量添加web扫描任务2.1.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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
#__author__ = 'techxsh'
#在同目录的url.txt,一行一个写入需要扫描的url,格式:http://www.xxx.com。
# -*- coding : utf-8 -*-
import urllib
import urllib.request
import http.cookiejar
import linecache
import re
from urllib.parse import urlparse
i = 1 #起始url行数
configdata = open('config.ini', 'rU', encoding='utf-8').read()
#print(configdata)
configlists = re.findall("= (.*?) ", configdata)
#print(configlists)
print(
'''
##################################################
#### RSAS批量添加web扫描任务~Author:Techxsh ####
##################################################
'''
)
print("在同目录的url.txt写入需批量待扫的url,格式:http://www.xxx.com\n")
taskname = input("输入任务名称:") #添加任务的名称
jtemp = len(open('url.txt', 'rU').readlines())
#print(jtemp)
if jtemp % 5 > 0:
j = (int(jtemp/5) + 1)*5
else:
j = jtemp
#print(j)
username = configlists[1]
password = configlists[2]
tasktype = configlists[3] #设置时间属性,timming为定时,directory为立即执行
year = configlists[4] #定时任务开始年
month = configlists[5] #定时任务开始月
day = configlists[6] #定时任务开始日
moment = configlists[7] #定时任务开始时刻
count = 0
#登录的主页面
hosturl = configlists[0]+'/user/login'
posturl = configlists[0]+'/user/login'
addurl = configlists[0]+'/task/newAction/class/wavsm'
cj = http.cookiejar.LWPCookieJar()
cookie_support = urllib.request.HTTPCookieProcessor(cj)
#proxy_handler = urllib.request.ProxyHandler({'https': 'http://127.0.0.1:8080'}) #此行及以下两行,为挂代理,方便使用burpsuit调试
#proxy_auth_handler = urllib.request.ProxyBasicAuthHandler()
#opener = urllib.request.build_opener( cookie_support, proxy_handler, proxy_auth_handler)
opener = urllib.request.build_opener(cookie_support)
urllib.request.install_opener(opener)
h = urllib.request.urlopen(hosturl)
hdata = h.read()
csrf_token = re.search("name=\"csrf_token\" value=\"(.*?)\"", str(hdata)).group(1)
#print(csrf_token)
#print(hdata)
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36',
'Referer': configlists[0]+'/user/requireLogin'}
print("正在登录...")
postData = {
'user[account]': username,
'user[password]': password,
'csrf_token': csrf_token
}
postData = urllib.parse.urlencode(postData).encode('utf-8')
request = urllib.request.Request(posturl, postData, headers)
#print(request)
response = urllib.request.urlopen(request)
text = response.read().decode('utf-8')
#print(text)
if '您好' in text:
print("登录过程已完成")
else:
print("登陆过程未完成,请检查配置。")
exit()
for i in range(1, j, 5): #此处为一次添加的url数量,可自行修改
task = [i, i+1, i+2, i+3, i+4]
alldata = ''
count+=1
for url in task:
data = linecache.getline('url.txt', url)
alldata = data+ alldata
addheader = {'User-Agent' : 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.137 Safari/537.36',
'Referer' : configlists[0]+'/task/index/class/wavsm',
'Content-Type': 'multipart/form-data; boundary=----WebKitFormBoundarymFEYc464OOnWEQVn',
# 'Cookie': 'language=zh_CN; PHPSESSID=3cb94decfa4e66fe38cfe7a3bf0a65a7; report_tpl_id=0; selectedTasks='
}
adddata = '''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[task_type]"
webscan
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[targets_url]"
'''+alldata+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[name]"
'''+taskname+'~'+str(count)+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[type]"
'''+tasktype+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_year]"
'''+year+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_month]"
'''+month+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_day_moment]"
'''+day+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_time_moment]"
'''+moment+'''
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_time_day]"
00:00
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_week]"
1
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_time_week]"
00:00
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_day_month]"
1
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[cron_time_time_month]"
00:00
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[plugin_template_id]"
0
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_scan_method]"
1
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[webscan_username]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[webscan_usrpwd]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_proxy_type]"
HttpProxy
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_proxy_server]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_proxy_port]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_proxy_username]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_proxy_password]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[subdomains_scan]"
0
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[subdomains]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_scan_level]"
15
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_scan_type]"
width-first
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[scan_link_limit]"
-1
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_duplicate_page]"
no
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[dir_files_limit]"
50
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_case_sensitive]"
yes
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[udef_link]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[del_link]"
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_filetype_to_check_backup]"
shtml,php,jsp,asp,aspx
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_backup_filetype]"
bak,old
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[webscan_timeout]"
30
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_plugin_threads]"
10
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_dir_level]"
1
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_dir_limit]"
3
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[ws_404]"
The\\\\ssystem\\\\scannot\\\\sfind\\\\sthe\\\\s(?:file|path)\\\\sspecified
page that no longer exists
the page you requested was not found
The page you requested cannot be found
The file you have requested is no longer available
The document you requested does not exist on this server
the page you\\\'re trying to reach is temporarily unavailable
the file you requested has moved or does not exist on our system
could not locate the page you requested
Document Not Found
Page Not Found
404 - File not found
404 - Object Not Found
404 Error
404 - Not Found
404 Not Found
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="newTask[report_format]"
html
------WebKitFormBoundarymFEYc464OOnWEQVn
Content-Disposition: form-data; name="start_ws"
å¼å§æ«æ
------WebKitFormBoundarymFEYc464OOnWEQVn--
'''
adddata = adddata.encode('utf-8')
req=urllib.request.Request(addurl, adddata, addheader)
#proxy_handler = urllib.request.ProxyHandler({'https' : 'http://127.0.0.1:8080'})
#proxy_auth_handler = urllib.request.ProxyBasicAuthHandler()
#opener = urllib.request.build_opener( cookie_support, proxy_handler, proxy_auth_handler)
opener = urllib.request.build_opener(cookie_support)
response = opener.open(req)
page = response.read()
print("第"+str(count)+"个任务添加成功")
print ("所有任务添加完毕,按Enter键退出...")
input()