-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnmp.py
62 lines (55 loc) · 1.45 KB
/
snmp.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
#!/usr/bin/python
import hashlib
import sys
import time
msg = "?"
target = "?"
msg_2 = msg.replace(target, "000000000000000000000000")
engineid = "?".decode('hex')
def caculate_md5(password):
passwordlen = len(password)
if passwordlen == 0:
return ""
password_buf = ""
count = 0
password_index = 0
while count < 1048576:
for i in range(64):
password_buf += password[password_index % passwordlen]
password_index += 1
count += 64
h = hashlib.new('md5')
h.update(password_buf)
key = h.hexdigest().decode('hex')
strpass = key + engineid + key
h = hashlib.new('md5')
h.update(strpass)
key = h.hexdigest()
entend_key = key + '00' * 48
IPAD = '36' * 64
k1 = "%0128x" % (int(entend_key, 16) ^ int(IPAD, 16))
OPAD = '5c' * 64
k2 = "%0128x" % (int(entend_key, 16) ^ int(OPAD, 16))
input = k1 + msg_2
h = hashlib.new('md5')
h.update(input.decode('hex'))
input = h.hexdigest()
input = k2 + input
h = hashlib.new('md5')
h.update(input.decode('hex'))
input = h.hexdigest()
return input[:12*2]
with open('dico-snmp.txt') as fp:
count_lignes = 0
lignes = fp.readlines()
lignestotal = len(lignes)
print "Passwords to test : " + str(lignestotal)
for line in lignes:
if count_lignes % 100 == 0:
print '%.2f %%' % float((count_lignes * 100.0) / lignestotal) + " (" + str(count_lignes) + " passwords tested)"
password = line[:-1]
ret = caculate_md5(password)
count_lignes += 1
if target == ret:
print "password : " + password
break