-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
279 lines (223 loc) · 13.4 KB
/
bot.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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import telebot
import secrets
import os
import time
bot = telebot.TeleBot(secrets.TELEGRAM_TOKEN)
@bot.message_handler(commands=['start'])
def send_welcome(message):
bot.send_message(message.chat.id, "Hello, Im a Bug Bounty Bot.\nI can do the whole bounty thingy for you.\n\n")
bot.send_message(message.chat.id, "To start, send me a domain with /domain <url>.\n\n")
#def domain command
@bot.message_handler(commands=['domain'])
def send_welcome(message):
args = message.text
#save time of start of script
start_time = time.time()
send_welcome.args = args.split(' ')[1]
if send_welcome.args.startswith('http://') or send_welcome.args.startswith('https://'):
send_welcome.args = send_welcome.args.split('//')[1]
if send_welcome.args.startswith('www.'):
send_welcome.args = send_welcome.args.split('www.')[1]
bot.send_message(message.chat.id, "Running... Please wait.\n\n")
bot.send_message(message.chat.id, "The whole process can take a while...\n\n")
msg = bot.send_message(message.chat.id, "[⬜⬜⬜⬜⬜⬜⬜⬜⬜⬜]")
send_welcome.process = mkdir()
bot.edit_message_text("[🔳⬜⬜⬜⬜⬜⬜⬜⬜⬜] + Running Sonar scan", msg.chat.id, msg.message_id)
send_welcome.process = sonar_rapid7()
bot.edit_message_text("[🔳🔳⬜⬜⬜⬜⬜⬜⬜⬜] + Running DNSX", msg.chat.id, msg.message_id)
send_welcome.process = dnsx()
bot.edit_message_text("[🔳🔳🔳⬜⬜⬜⬜⬜⬜⬜] + Running Subfinder", msg.chat.id, msg.message_id)
send_welcome.process = subfinder()
bot.edit_message_text("[🔳🔳🔳🔳⬜⬜⬜⬜⬜⬜] + Running Get all Urls", msg.chat.id, msg.message_id)
send_welcome.process = gau()
bot.edit_message_text("[🔳🔳🔳🔳🔳⬜⬜⬜⬜⬜] + Running DNSX again", msg.chat.id, msg.message_id)
send_welcome.process = dnsx2()
bot.edit_message_text("[🔳🔳🔳🔳🔳🔳⬜⬜⬜⬜] + Running CRT.SH", msg.chat.id, msg.message_id)
send_welcome.process = crtsh()
bot.edit_message_text("[🔳🔳🔳🔳🔳🔳🔳⬜⬜⬜] + Running nrich", msg.chat.id, msg.message_id)
send_welcome.process = shodan_nrich()
bot.edit_message_text("[🔳🔳🔳🔳🔳🔳🔳🔳⬜⬜] + Running Naabu", msg.chat.id, msg.message_id)
send_welcome.process = naabu()
bot.edit_message_text("[🔳🔳🔳🔳🔳🔳🔳🔳🔳⬜] + Running httpx", msg.chat.id, msg.message_id)
send_welcome.process = httpx_check()
bot.edit_message_text("[🔳🔳🔳🔳🔳🔳🔳🔳🔳🔳] + Running nuclei", msg.chat.id, msg.message_id)
send_welcome.process = nuclei()
bot.edit_message_text("[⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛]", msg.chat.id, msg.message_id)
time.sleep(1)
bot.edit_message_text("[✅✅✅✅✅✅✅✅✅✅]", msg.chat.id, msg.message_id)
time.sleep(1)
bot.edit_message_text("[⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛]", msg.chat.id, msg.message_id)
time.sleep(1)
bot.edit_message_text("[✅✅✅✅✅✅✅✅✅✅]", msg.chat.id, msg.message_id)
time.sleep(1)
bot.edit_message_text("[⬛⬛⬛⬛⬛⬛⬛⬛⬛⬛]", msg.chat.id, msg.message_id)
time.sleep(1)
bot.edit_message_text("[✅✅✅✅✅✅✅✅✅✅]", msg.chat.id, msg.message_id)
time.sleep(1)
bot.send_message(message.chat.id, "BotBounty work is done.\n\n")
bot.reply_to(message, "Sending now the results.\n\n")
send_welcome.process = end()
#subdomains
bot.send_message(message.chat.id, "Subdomains:\n\n")
if os.path.exists('{args}/{args}.subdomains.txt'.format(args=send_welcome.args)):
bot.send_document(message.chat.id, open('{args}/{args}.subdomains.txt'.format(args=send_welcome.args), 'rb'))
else:
bot.send_message(message.chat.id, "No subdomains found.\n\n")
#links
bot.send_message(message.chat.id, "Links:\n\n")
if os.path.exists('{args}/{args}.links.txt'.format(args=send_welcome.args)):
bot.send_document(message.chat.id, open('{args}/{args}.links.txt'.format(args=send_welcome.args), 'rb'))
else:
bot.send_message(message.chat.id, "No links found.\n\n")
#ips
bot.send_message(message.chat.id, "IPs:\n\n")
if os.path.exists('{args}/{args}.dnsx_ips.txt'.format(args=send_welcome.args)):
bot.send_document(message.chat.id, open('{args}/{args}.dnsx_ips.txt'.format(args=send_welcome.args), 'rb'))
else:
bot.send_message(message.chat.id, "No IPs found.\n\n")
#CVEs
bot.send_message(message.chat.id, "CVEs:\n\n")
if os.path.exists('{args}/{args}.cves_nrich.txt'.format(args=send_welcome.args)):
bot.send_document(message.chat.id, open('{args}/{args}.cves_nrich.txt'.format(args=send_welcome.args), 'rb'))
else:
bot.send_message(message.chat.id, "No CVEs found.\n\n")
#nuclei
bot.send_message(message.chat.id, "Nuclei:\n\n")
if os.path.exists('{args}/{args}.nuclei.txt'.format(args=send_welcome.args)):
bot.send_message(message.chat.id, 'Nuclei completed. Found some (potential) issues.\n\n')
bot.send_document(message.chat.id, open('{args}/{args}.nuclei.txt'.format(args=send_welcome.args), 'rb'))
else:
bot.send_message(message.chat.id, "Nuclei completed. No issues found.\n\n")
bot.send_message(message.chat.id, "Process done after {time} seconds.\n\n".format(time=time.time() - start_time))
#? create directory if not exist
def mkdir():
if not os.path.exists(send_welcome.args):
os.system('mkdir {args}'.format(args=send_welcome.args))
#0 sonar search tld
def sonar_rapid7():
os.system('curl -k -s https://sonar.omnisint.io/subdomains/{args} | jq -r ".[]" | sort -u > {args}/{args}.sonar.txt'.format(send_welcome.args, args=send_welcome.args))
#1 dnsx sub brute
def dnsx():
os.system('dnsx -silent -d {args}/{args}.sonar.txt -w -o {args}/{args}.dnsx.txt'.format(send_welcome.args, args=send_welcome.args))
#2 subfinder subdomain enumeration
def subfinder():
os.system('subfinder -silent -d {args} -o {args}/{args}.subfinder.txt'.format(send_welcome.args, args=send_welcome.args))
#3 gau + unfurl
def gau():
os.system('gau {args} --blacklist png,jpg,gif --o {args}/{args}.gau.txt'.format(send_welcome.args, args=send_welcome.args))
#4 get ip address
def dnsx2():
os.system('subfinder -silent -d {args} | dnsx -silent -a -resp-only -o {args}/{args}.dnsx_ips.txt'.format(send_welcome.args, args=send_welcome.args))
#5 get ctrsh
def crtsh():
os.system('crtsh search --domain %.{args} --plain | anew > {args}/{args}.crtsh.txt'.format(send_welcome.args, args=send_welcome.args))
#6 nrich portscan common cves
def shodan_nrich():
os.system('nrich {args}/{args}.dnsx_ips.txt -o {args}/{args}.cves_nrich.txt'.format(send_welcome.args, args=send_welcome.args))
#7 portscan
def naabu():
os.system('naabu -l {args}/{args}.subfinder.txt -s -o {args}/{args}.naabu.txt'.format(send_welcome.args, args=send_welcome.args))
#8 check active domains
def httpx_check():
os.system('httpx -l {args}/{args}.subfinder.txt -silent -o {args}/{args}.httpx.txt'.format(send_welcome.args, args=send_welcome.args))
#9 nuclei attack
def nuclei():
os.system('cat {args}/{args}.sonar.txt >> {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.crtsh.txt >> {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.subfinder.txt >> {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.subtemp.txt | anew >> {args}/{args}.subdomains.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('nuclei -c 150 -list "{args}/{args}.subdomains.txt" -severity low,medium,high,critical -etags "intrusive" -o "{args}/{args}.nuclei.txt"'.format(send_welcome.args, args=send_welcome.args))
#nuevos
def amass():
os.system('amass enum --passive -d {args} -o {args}/{args}.amass.txt'.format(send_welcome.args, args=send_welcome.args))
def altdns():
os.system('altdns -i {args}/{args}.subdomains.txt -o {args}/data_output -w fuzz/fuzz.txt -r -s {args}/{args}.altdns_results.txt'.format(send_welcome.args, args=send_welcome.args))
def gobustervhost():
os.system('gobuster vhost -u {args}/{args}.domains.txt -o {args}/{args}.vhosts.txt'.format(send_welcome.args, args=send_welcome.args))
def udpscan_500():
os.system('naabu -p 500 -l {args}/{args}.ips.txt -silent -o {args}/{args}.udpscan_500.txt'.format(send_welcome.args, args=send_welcome.args))
def jsonscanner():
#curl subdomains / links and save in file, then grep the file for "[{" and save in file
return
#end
def end():
os.system('cat {args}/{args}.sonar.txt >> {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.crtsh.txt >> {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.subfinder.txt >> {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.subtemp.txt | anew >> {args}/{args}.subdomains.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('rm {args}/{args}.subtemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.gau.txt >> {args}/{args}.linktemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.httpx.txt >> {args}/{args}.linktemp.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('cat {args}/{args}.linktemp.txt | anew >> {args}/{args}.links.txt'.format(send_welcome.args, args=send_welcome.args))
os.system('rm {args}/{args}.linktemp.txt'.format(send_welcome.args, args=send_welcome.args))
@bot.message_handler(commands=['nuclei'])
def getnuclei(message):
bot.send_message(message.chat.id, "Running... Please wait.\n\n")
os.system('nuclei -u {} -c 150 -severity low,medium,high,critical -etags "intrusive" > nuclei.txt'.format(message.text[7:]))
#if the file is empty, send a message
if os.stat('nuclei.txt').st_size == 0:
bot.send_message(message.chat.id, "No results found")
else:
bot.send_document(message.chat.id, open('nuclei.txt', 'rb'))
os.system('rm nuclei.txt')
@bot.message_handler(commands=['astra'])
def getastra(message):
bot.send_message(message.chat.id, "Running... Please wait.\n\n")
os.system('echo {} | python3 Astra.py > output.txt'.format(message.text[7:]))
arg = message.text[7:]
if arg.startswith('http://') or arg.startswith('https://'):
if os.path.getsize('output.txt') > 4000:
bot.send_message(message.chat.id, 'The output is too long to send in one message. I will send it as txt...')
bot.send_document(message.chat.id, open('output.txt', 'rb'))
os.remove('output.txt')
else:
bot.send_message(message.chat.id, open('output.txt').read())
bot.send_message(message.chat.id, "Done!")
else:
bot.send_message(message.chat.id, "Please enter a valid URL")
@bot.message_handler(commands=['arjun'])
def getarjun(message):
bot.send_message(message.chat.id, "Running... Please wait.\n\n")
os.system('arjun -u {} -oT arjun.txt'.format(message.text[7:]))
bot.send_document(message.chat.id, open('arjun.txt', 'rb'))
os.system('rm arjun.txt')
bot.send_message(message.chat.id, "Done!")
@bot.message_handler(commands=['ffuf'])
def getFfuf(message):
bot.send_message(message.chat.id, "Command format: /ffuf <url> <wordlist>\n\n URL MUST HAVE 'FUZZ' SOMEWHERE.")
bot.send_message(message.chat.id, "wordlists: general, spanish, english, deutsch, api")
arg = message.text
#command will have two arguments after the command
#first argument is the url
url_arg = arg.split()[1]
#second argument is the wordlist
wordlist_arg = arg.split()[2]
#if the wordlist_arg is 'general':
if wordlist_arg == 'general':
os.system('./fuff/ffuf -u {} -w fuzz/SecLists/Discovery/Web_Content/Discovery_DNS_Records/DNS_Records_General_Purpose.txt -o output.txt'.format(url_arg))
#if the wordlist_arg is 'spanish':
elif wordlist_arg == 'spanish':
os.system('./fuff/ffuf -u {} -w fuzz/SecLists/Miscellaneous/lang-spanish.txt -o output.txt'.format(url_arg))
#if the wordlist_arg is 'english':
elif wordlist_arg == 'english':
os.system('./fuff/ffuf -u {} -w fuzz/SecLists/Miscellaneous/lang-english.txt -o output.txt'.format(url_arg))
#if the wordlist_arg is 'deutsch':
elif wordlist_arg == 'deutsch':
os.system('./fuff/ffuf -u {} -w fuzz/SecLists/Miscellaneous/lang-deutsch.txt -o output.txt'.format(url_arg))
#if the wordlist_arg is 'api':
elif wordlist_arg == 'api':
os.system('./fuff/ffuf -u {} -w fuzz/SecLists/Discovery/Web_Content/common-api-endpoints-mazen160.tx -o output.txt'.format(url_arg))
#if the wordlist_arg is not valid:
elif wordlist_arg =='otro':
os.system('./fuff/ffuf -u {} -w {} -o output.txt'.format(url_arg, wordlist_arg))
else:
bot.send_message(message.chat.id, "Please enter a valid wordlist")
#if the file is empty, send a message
if os.stat('output.txt').st_size == 0:
bot.send_message(message.chat.id, "No results found")
else:
bot.send_document(message.chat.id, open('output.txt', 'rb'))
os.system('rm output.txt')
bot.infinity_polling(timeout=10, long_polling_timeout=5)