-
Notifications
You must be signed in to change notification settings - Fork 0
/
simplocker_decrypt.py
58 lines (48 loc) · 1.45 KB
/
simplocker_decrypt.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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
*
* Revers@ndroid - Simplocker
*
* Atividade: Cassius Puodzius (@cpuodzius)
* Script: Cassius Puodzius (@cpuodzius)
*
"""
import hashlib
import os
import sys
from Crypto import Random
from Crypto.Cipher import AES
from Crypto.Hash import SHA256
password = "jndlasf074hr"
def decrypt(password, enc):
sha256 = SHA256.new()
sha256.update(password)
key = sha256.digest()
iv = 16 * '\x00'
return AES.new(key, AES.MODE_CBC, iv).decrypt(enc)
"""
Recebe a chave em formato hexadecimal.
"""
def decrypt_file(file_path, key):
print 'Decriptando o arquivo %s' % file_path
with open(file_path, 'rb') as fo:
ciphertext = fo.read()
dec = decrypt(key, ciphertext)
with open('%s%s%s' % (file_path[:-4], '_dec', file_path[-4:]), 'wb') as fo:
fo.write(dec)
"""
Recebe por parámetro o caminho da pasta que contém os arquivos cifrado ou um arquivo cifrado em particular.
"""
if __name__ == '__main__':
if len(sys.argv) > 2:
sys.exit('ERROR: Não especificou o caminho absoluto do arquivo ou diretório dos arquivos a serem decriptados.')
param_path = sys.argv[1]
if not os.path.exists(param_path):
sys.exit('ERROR: O arquivo ou diretório especificado nãõ existe.')
if not os.path.isdir(param_path):
decrypt_file(param_path, password)
else:
for root,subdirs, files in os.walk(param_path):
for filename in files:
decrypt_file(os.path.join(root, filename), key)