[包编辑]移除TCP Option里的某个选项
示例中为移除TCP Option里的Time Stamp选项,该脚本也可以用于编辑其他的tcp option
import sys
from scapy.all import *
capture = rdpcap(sys.argv[1])
for packet in capture:
print(packet[TCP].options)
new_opt = []
for key, value in packet[TCP].options:
if key != 'Timestamp':
new_opt.append((key, value))
print('new')
print(new_opt)
packet[TCP].options = new_opt
if packet[Ether].type == 0x8100:
del packet[IP].chksum
del packet[IP].len
else:
del packet[IPv6].chksum
del packet[IPv6].plen
del packet[TCP].chksum
del packet[TCP].dataofs
wrpcap(sys.argv[2], capture)