我不久前做了一个程序,可以从wpa握手中提取部分。更具体地说,nonce(接入点和客户端)以及mac和“mics”。如果被猜到,程序就可以告诉我正确的密码。当时我对它有了更多的了解,但老实说,我已经忘记了很多。我应该给自己留些更好的笔记。我想要的是让程序给我一个散列。这样我就可以创建一个C++程序,并通过它运行,以达到优化的目的和速度。p>
这是我现在拥有的代码,可以使用,我只想修改它:
def sortHandshakes(in_1, in_2):
if len(in_1) != len(in_2):
raise 'lengths do not match'
in_1_byte_list = list(bytes(in_1))
in_2_byte_list = list(bytes(in_2))
for i in range(0, len(in_1_byte_list)):
if in_1_byte_list[i] < in_2_byte_list[i]:
return (in_2, in_1)
elif in_1_byte_list[i] > in_2_byte_list[i]:
return (in_1, in_2)
return (in_1, in_2)
def crackPassword(handshakeDict):
ap_mac = handshakeDict['ap_mac']
sta_mac = handshakeDict['sta_mac']
sta_nonce = handshakeDict['sta_nonce']
eapol_frame_zeroed_mic = handshakeDict['eapol_frame_zeroed_mic']
ap_nonce = handshakeDict['ap_nonce']
mic = handshakeDict['mic']
SSID = handshakeDict['SSID']
max_mac, min_mac = sortHandshakes(ap_mac, sta_mac)
max_nonce, min_nonce = sortHandshakes(ap_nonce, sta_nonce)
message = b''.join([
b'Pairwise key expansion\x00',
min_mac,
max_mac,
min_nonce,
max_nonce,
b'\x00'
])
while True:
password_guess = input('enter guess: ')
password_guess = ''.join(password_guess).encode()
pmk = hashlib.pbkdf2_hmac('sha1', password_guess, SSID.encode(), 4096, 32)
kck = hmac.new(pmk, message, hashlib.sha1).digest()[:16]
calculated_mic = hmac.new(kck, eapol_frame_zeroed_mic, hashlib.sha1).digest()[:16]
if calculated_mic == mic:
print('correct, password is {}'.format(password_guess.decode('ASCII')))
break
然后,我传递一个包含所需值的字典。然后我可以猜出我想要的密码。我想做的是提取一个散列,然后打印出来,就像我前面说的那样。从我现在的情况来看,我怎么能做到这一点
目前没有回答
相关问题 更多 >
编程相关推荐