-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathREADME-retrieve_pickled_data
52 lines (48 loc) · 1.73 KB
/
README-retrieve_pickled_data
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
+----------------MOTPY-------------------+
| MOTP http://motp.sourceforge.net/ |
| |
| motpy for pam_exec.so a python solution|
| by |
| szimszon at oregpreshaz.eu |
| web: https://github.com/szimszon/motpy |
+----------------------------------------+
= How to retrieve pickled data =
If data is in "motpy.pickle" and salt is "salt" and the host we search for
is the first item then
--- cut ---
def decrypt(salt, ciphertext):
from Crypto.Cipher import AES
import re
re_code = re.compile(
"^\{(?P<version>\d+)\}\{(?P<iv>.{" + str(AES.block_size) + \
"})\}(?P<chipertext>.*)$")
c = re_code.search(ciphertext)
if c:
code_version = c.group('version')
iv = c.group('iv')
ciphertext = c.group('chipertext')
else:
code_version = '1'
iv = salt
ciphertext = ciphertext
if code_version == '1':
try:
encobj = AES.new(salt, AES.MODE_CFB)
except:
encobj = AES.new(salt, AES.MODE_CFB, iv)
elif code_version == '2':
encobj = AES.new(salt, AES.MODE_CFB, iv)
else:
sys.exit(10)
plaintext = encobj.decrypt(ciphertext)
return plaintext
salt='salt............'
import cPickle
pickled_data=cPickle.load(open('motpy.pickle'))
for x in pickled_data.keys():
print 'user : %s'%decrypt(salt,x)
print 'pin : %s'%decrypt(salt, pickled_data[x]['pin'] )
print 'secret: %s'%decrypt(salt, pickled_data[x]['secret'] )
print 'offset: %s'%decrypt(salt, pickled_data[x]['offset'] )
print '------------------------------'
--- cut ---