-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.py
510 lines (471 loc) · 21.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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
import discord
from urllib.request import urlopen
import subprocess
from subprocess import call
import asyncio
import re
import os
import magic
import time
from discord.ext.commands import Bot
from discord.ext import commands
import glob
import pypwned
import json
import sys
TOKEN = ''
HIBP_API = ''
SHODAN_API = ''
HASHESORG_API = ''
TRUECNAM_USER = ""
TRUECNAM_API = ""
DEHASHED_API = "EMAIL:KEY"
#Also sorry for the hacky DEHASHED module, was acting all wacky on me parsing the json.
#class DevNull:
# def write(self, msg):
# pass
#
#sys.stderr = DevNull()
with open("blacklist.json", "r") as blacklist:
ids = json.load(blacklist)
with open ("whitelist.json", "r") as whitelist:
wlids = json.load(whitelist)
#print(wlids)
keyban = ['\'', ';', '&', '"', '}', '{', '!', '~', '>', '<', '?', '$', '|'] #Temporary fix
helpdata = """
Commands:
changelog - View latest changelog.
analyze - Check what a page is running.
callid - Check caller ID of US phone number. (2 requests per minute, so try again later if errors.)
checkemail - Check email in data breaches. (Best used with "search" command, chances.)
crack - Attempts to crack a password hash.
dbsearch - Accesses leaked data to grab info from users. (Whitelist based due to abuse.)
honeycheck - Checks if IP belongs to a honeypot. (experimental)
ip2cidr - Get CIDR from IP address.
joke - Tell a dad joke.
namecheck - Find accounts belonging to a username.
search - Get first 20 results from Breach Compilation. (Perms needed)
spyon - Take a screencap of a stolen camera. (Perms needed)
subdomains - Get subdomains from online sources.
target - Send a target for ANK to attack. Accepts an IP, email, or url.
ttcheck - Check onion URL title.
More to come...
"""
changedata = """
░░▒██████▌ ▄████████▄ ░░▒██████ ░░▒████▄ ░░▒██████▄ ███████████
░▒▒███████ ████▄▄ ██ ░▒▒██▌███ ░▒▒█▌███▌ ░▒▒██▌████ ███ ▒██▌███
░▒███▌████ ▐██████▄ ▀ ░▒███▌███ ░▒██▌██▀ ░▒███▌████ ▒▒█▌
▒▒███▌████ ▀▀▀▀ ███▄ ▒▒███████ ▒▒█████▄ ▒▒███▌████ ░▒█▌
▒████▌████ ░▒██ ▄████▌ ▒████▌███ ▒███▌███▌ ▒████▌████ ░▒▒▌
█████▌████ ░████████▀ █████▌███ ███████▀ ▀████████▀ ░░▒▌
Mon 21 Oct 2019 01:11:19 AM EDT
Added DB search function with whitelist.
"""
client = commands.Bot(command_prefix='nsa-')
client.remove_command('help')
@client.event
async def on_ready():
print('Bot is ready.')
@client.command()
async def help(ctx):
await ctx.send("```"+helpdata+"```")
@client.command()
async def changelog(ctx):
await ctx.send("```"+changedata+"```")
@client.command()
async def analyze(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: analysis on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
if re.match(r'^http', arg1):
whatwebdata = subprocess.getoutput("whatweb -a 1 --wait=5 --color=never "+arg1+" | head -1")
if whatwebdata == "":
await ctx.send("Unable to retrieve data.")
else:
embed=discord.Embed(color=0x39fd3f)
embed.add_field(name="Output:", value=whatwebdata, inline=False)
await ctx.send(embed=embed)
else:
await ctx.send("```Correct format: http://wahtever.com/```")
@client.command()
async def target(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: target "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
await ctx.send("Sending target to ANK...")
f=open("targets.txt", "a+")
f.write(arg1+" - "+authorid+"#"+descrim+"\n")
f.close
@client.command()
async def ip2cidr(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: ip2cidr on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
cidrdata = subprocess.getoutput("curl -s https://freeapi.robtex.com/ipquery/"+arg1+" | jq '.bgproute'")
embed=discord.Embed(color=0x39fd3f)
embed.add_field(name="Output:", value=cidrdata, inline=False)
await ctx.send(embed=embed)
@client.command()
async def joke(ctx):
dadjoke = subprocess.getoutput("curl -s -H 'User-Agent: DadBot' -H 'Accept: text/plain' https://icanhazdadjoke.com/")
await ctx.send(dadjoke)
@client.command()
async def checkemail(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: checkemail used on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
await ctx.send("```Checking email, please wait up to 30 seconds...```")
pwny = pypwned.pwned(HIBP_API)
s1 = json.dumps(pwny.getAllBreachesForAccount(email=arg1))
d2 = json.loads(s1)
finalout = ""
for finaldata in d2:
try:
finalout += finaldata['Name']+"\n"
except:
finalout == str("Not found or error.")
if finalout != "":
await ctx.send("Email found in: \n```"+finalout+"```")
else:
await ctx.send("```Not found.```")
@client.command()
async def namecheck(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
if ' ' in arg1:
await ctx.send("```Username cannot have spaces.```")
else:
filename = arg1+".txt"
await ctx.send("This might take a while...")
subprocess.call(["userrecon-py", "target", arg1, "--positive", "--output"])
if os.path.isfile(filename):
os.remove(filename)
makefile = open(filename, "w+")
p = subprocess.Popen("cat "+arg1+".json | jq '.[].url' | sed \'s/\"//g\' > "+filename, stdout=subprocess.PIPE, shell=False)
p.communicate()
testsum = 1999
space = 1
line = 1
charc = 1
with open(filename) as infile:
text = infile.read()
for i in text:
if(i == " "):
space += 1
elif(i == "\n"):
line += 1
else:
charc += 1
if charc > testsum:
p = subprocess.Popen("split -l 25 --additional-suffix='.split' "+filename, stdout=subprocess.PIPE, shell=False)
p.communicate()
for splits in os.listdir():
if splits.endswith(".split"):
with open(splits, 'r') as filedata:
content_file = filedata.read()
await ctx.send("```"+content_file+"```")
os.remove(splits)
else:
with open(filename, 'r') as filedata:
content_file = filedata.read()
await ctx.send("```"+content_file+"```")
os.remove(arg1 + ".json")
os.remove(arg1 + ".txt")
@client.command()
async def subdomains(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: sudomain check on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
if re.match(r'^([A-Za-z0-9]\.|[A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9]\.){1,3}[A-Za-z]{2,6}$', arg1):
await ctx.send("Grabbing subdomains from sources...")
subprocess.call(["/media/root/Leaks/New_Toolkit/Scanners/findomain/findomain-linux", "-t", arg1, "-o"])
with open('./'+arg1+'.txt', 'r') as content_file:
content = content_file.read()
await ctx.send("```"+content+"```")
os.remove("./"+arg1+".txt")
else:
await ctx.send("```Correct format: wahtever.com```")
@client.command()
async def honeycheck(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: honeypot check on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
honey = "https://api.shodan.io/labs/honeyscore/" + arg1 + "?key=" + SHODAN_API
phoney = str(urlopen(honey).read())
if '0.0' in phoney:
await ctx.send('Honeypot Probabilty: 0%')
if '.1' in phoney:
await ctx.send('Honeypot Probabilty: 10%')
if '.2' in phoney:
await ctx.send('Honeypot Probabilty: 20%')
if '.3' in phoney:
await ctx.send('Honeypot Probabilty: 30%')
if '.4' in phoney:
await ctx.send('Honeypot Probabilty: 40%')
if '.5' in phoney:
await ctx.send('Honeypot Probabilty: 50%')
if '.6' in phoney:
await ctx.send('Honeypot Probabilty: 60%')
if '.7' in phoney:
await ctx.send('Honeypot Probabilty: 70%')
if '.8' in phoney:
await ctx.send('Honeypot Probabilty: 80%')
if '.9' in phoney:
await ctx.send('Honeypot Probabilty: 90%')
if '1.0' in phoney:
await ctx.send('Honeypot Probabilty: 100%')
@client.command()
async def callid(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: callid check on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
calldata = subprocess.getoutput("curl -s \"https://api.truecnam.net/api/v1?username="+TRUECNAM_USER+"&password="+TRUECNAM_API+"&resp_type=basic&resp_format=json&calling_number="+arg1+"&call_party=terminating\" | jq .name")
if calldata != "":
await ctx.send("Name: ``"+calldata+"``")
elif calldata == "\"\"":
await ctx.send("Error.")
else:
await ctx.send("Error.")
@client.command()
async def crack(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: crack on hash "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
hasharg = arg1.lower()
if "," in hasharg:
hashdata = subprocess.getoutput("curl -s \"https://hashes.org/api.php?key=" + HASHESORG_API + "&query="+hasharg+"\" | jq --monochrome-output '.result'")
else:
hashdata = subprocess.getoutput("curl -s \"https://hashes.org/api.php?key=" + HASHESORG_API + "&query="+hasharg+"\" | jq --monochrome-output '.result | .[\""+hasharg+"\"] | .plain'")
if hashdata == "":
await ctx.send("Unable to crack hash.")
elif "error" in hashdata:
await ctx.send("Error, only 20 hashes per minute allowed.")
else:
await ctx.send("```"+hashdata+"```")
@client.command()
async def dbsearch(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
if str(ctx.author.id) in(wlids):
authorid = ctx.author.name
descrim = ctx.author.discriminator
testsum = 1999
space = 1
line = 1
charc = 1
try:
print("Log: dbsearch used on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
await ctx.send("```Checking, please wait...```")
pwndata = subprocess.getoutput("curl -s 'https://dehashed.com/search?query=\""+arg1+"\"' -u \""+DEHASHED_API+"\" -H 'Accept: application/json' > "+arg1+".leakdata")
leakfile = arg1+".leakdata"
data_email = subprocess.getoutput("jq '.[]' "+leakfile)
finalout = str(data_email)
try:
for i in finalout:
if(i == " "):
space += 1
elif(i == "\n"):
line += 1
else:
charc += 1
if charc > testsum:
f=open("temp_data", "a+")
f.write(finalout)
p = subprocess.Popen("split -l 10 --additional-suffix='.splitdata' temp_data", stdout=subprocess.PIPE, shell=False)
p.communicate()
for splits in os.listdir():
if splits.endswith(".splitdata"):
with open(splits, 'r') as filedata:
content_file = filedata.read()
await ctx.send("```"+content_file+"```")
os.remove(splits)
else:
continue
except:
finalout == str("Not found or error.")
if finalout != "":
await ctx.send("```"+finalout+"```")
os.remove(arg1+".leakdata")
else:
await ctx.send("```Not found.```")
else:
await ctx.send("You are not allowed to use this command.")
return
@client.command()
async def spyon(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: spyon "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
author = ctx.message.author
role = discord.utils.get(ctx.guild.roles, name="DadBot Access")
if role in ctx.author.roles:
await ctx.send("Screencapping camera...")
check = subprocess.getoutput("timeout -k 60 ffmpeg -loglevel fatal -rtsp_transport tcp -i 'rtsp://"+arg1+":554/tcp/av0_0' -r 1 -vframes 1 screencap.png")
await ctx.send(file=discord.File('screencap.png'))
os.remove("screencap.png")
else:
await ctx.send("Role required.")
@client.command()
async def ttcheck(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
print("Deep title check on "+arg1)
if re.match(r'^http://|onion/$', arg1):
await ctx.send("```Checking "+arg1+" for a title...```")
titledata = subprocess.getoutput("proxychains4 -q -f /etc/proxychains.conf curl -s -U 'Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0' "+arg1+" | pup 'title text{}'")
embed=discord.Embed(color=0x39fd3f)
finaloutput = arg1+" -- "+titledata
embed.add_field(name="Output:", value=finaloutput, inline=False)
await ctx.send(embed=embed)
else:
await ctx.send("```Correct format: http://wahtever.onion/```")
@client.command()
async def search(ctx, arg1):
if any(x in str(arg1) for x in keyban): #Temporary fix
await ctx.send("Possible exploitation detected...")
return
else:
if str(ctx.author.id) in(ids):
await ctx.send("You are banned from using the bot.")
return
else:
authorid = ctx.author.name
descrim = ctx.author.discriminator
try:
print("Log: breachsearch on "+arg1+" -- "+authorid+"#"+descrim+" ("+str(ctx.author.id)+") | Server: "+str(ctx.author.guild)+" ("+str(ctx.author.guild.id)+")")
except:
pass
author = ctx.message.author
role = discord.utils.get(ctx.guild.roles, name="DadBot Access")
if role in ctx.author.roles:
await ctx.send("Searching 20 max results for "+arg1+"...")
stdoutdata = subprocess.getoutput("/media/root/BigBoiDrive/DBLeaks/BreachCompilation/query.sh "+arg1+" | head -20 | awk '{printf \"%s\\n\", $0}'")
embed=discord.Embed(color=0x39fd3f)
embed.add_field(name="Data:", value=stdoutdata, inline=False)
await ctx.send(embed=embed)
else:
await ctx.send("Role required.")
client.run(TOKEN)