在显示字符时遇到一些问题
我从协议请求中收到了有效负载:
538cb9350404521a6c44020404563b152606102001085800020002aabb0000563b1526000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
长度为509
我要显示的是前4个字节,然后是1个字节,然后是1个字节
538cb935
04
04
目前正在查看我正在执行以下操作的有效负载:
tm = struct.unpack(">L", payload[0:4])
print "Time : ", tm
ouroripv = struct.unpack(">b", payload[5])
print "Our onion address : "
print "Ip version : ", ouroripv
ouroraddrlen = struct.unpack(">b", payload[6]) # Giving a length of 82 etc atm
print "Ip length : ", ouroraddrlen
我得到了结果:
Time : (1401731381,)
Our onion address :
Ip version : (4,)
Ip length : (82,)
正如你可以看到Ip长度,有效载荷上的第6个字节显示的是82而不是它应该是4,显示它需要的正确struct.unpack
命令是什么?
我该怎么做?
谢谢你们
答案 0 :(得分:2)
payload[0:4]
占用前4个字节,从0到3。
payload[3]
是第四个字节
payload[4]
是第五个字节