我尝试编写一个计算WPA握手的Python程序,但是我遇到了哈希问题.为了比较,我安装了cowpatty (看看我开始错误的地方).
我的PMK生成工作正常,但PTK计算似乎也是错误的.我不确定是否必须格式化我的输入(macadresses和noces)或者只是将它们作为字符串放入函数中.
我会给你我的路由器信息,这是没有问题,因为我只是设置它进行测试.
我的程序如下:
import hmac,hashlib,binascii
passPhrase = "10zZz10ZZzZ"
ssid = "Netgear 2/158"
A = "Pairwise key expansion"
APmac = "001e2ae0bdd0"
Clientmac = "cc08e0620bc8"
ANonce = "61c9a3f5cdcdf5fae5fd760836b8008c863aa2317022c7a202434554fb38452b"
SNonce = "60eff10088077f8b03a0e2fc2fc37e1fe1f30f9f7cfbcfb2826f26f3379c4318"
B = min(APmac,Clientmac)+max(APmac,Clientmac)+min(ANonce,SNonce)+max(ANonce,SNonce)
data="0103005ffe010900200000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
def customPRF512(key,A,B):
blen = 64
i = 0
R = ''
while i<=((blen*8+159)/160):
hmacsha1 = hmac.new(key,A+chr(0x00)+B+chr(i),sha)
i+=1
R = R+hmacsha1.digest()
return R[:blen]
pmk = pbkdf2(passPhrase, ssid, 4096, 32) #no sourcecode, since b2a_p(pmk) output fits to those of cowpatty
ptk = customPRF512(pmk,A,B) #the …Run Code Online (Sandbox Code Playgroud) 我想知道哪个hexdump()scapy使用,因为我想修改它,但我根本找不到任何东西.
我发现的是:
def hexdump(self, lfilter=None):
for i in range(len(self.res)):
p = self._elt2pkt(self.res[i])
if lfilter is not None and not lfilter(p):
continue
print "%s %s %s" % (conf.color_theme.id(i,"%04i"),
p.sprintf("%.time%"),
self._elt2sum(self.res[i]))
hexdump(p)
Run Code Online (Sandbox Code Playgroud)
但这只是一个替代方案pkt.hexdump(),其中pkt.summary()包括以下内容hexdump(pkt)
谁能告诉我在哪里找到hexdump(pkt)源代码?
我想要的是hexeded数据包,几乎就像str(pkt[0])(我可以逐字节地检查str(pkt[0])[0]),但除了hexvalues之外别无其他,就像显示在hexdump(pkt).
也许你们可以帮我解决这个问题:)