python练习题【二】
问题:使用struct来构建tcp数据包
#coding=utf-8 from random import randint import struct #源端口 source_port = randint(1,65535); #目的端口 dst_port = 23; #32位确认序号 ack_sn=0; #32序号 sn=randint(1,65535*65535); #数据包窗口 windows=4096 data=struct.pack(‘>HHIIBBH‘,source_port,dst_port,sn,ack_sn,80,2,windows); hd = open(‘data.bin‘,‘wb‘); hd.write(data); hd.close();
相关推荐
YENCSDN 2020-11-17
lsjweiyi 2020-11-17
houmenghu 2020-11-17
Erick 2020-11-17
HeyShHeyou 2020-11-17
以梦为马不负韶华 2020-10-20
lhtzbj 2020-11-17
夜斗不是神 2020-11-17
pythonjw 2020-11-17
dingwun 2020-11-16
lhxxhl 2020-11-16
坚持是一种品质 2020-11-16
染血白衣 2020-11-16
huavhuahua 2020-11-20
meylovezn 2020-11-20
逍遥友 2020-11-20
weiiron 2020-11-16