from
scapy.
all
import
*
import
os
os.system(
"C:\\Windows\\System32\\Npcap\\NpcapHelper.exe /enable"
)
def
packet_callback(packet):
if
TCP
in
packet:
if
packet[IP].dst
=
=
'192.168.1.1'
:
if
Raw
in
packet
and
packet[Raw].load.startswith(b
'\x00\x1C\x42\x8A\x52'
):
print
(
"lanjiedao le"
)
print
(f
"Original packet: {packet.summary()}"
)
if
Raw
in
packet
and
len
(packet[Raw].load) >
=
55
:
modified_payload
=
packet[Raw].load[:
55
]
+
b
'\x00'
+
packet[Raw].load[
56
:]
packet[Raw].load
=
modified_payload
del
packet[IP].chksum
del
packet[TCP].chksum
packet.show()
send(packet,verbose
=
0
)
print
(f
"Modified packet sent: {packet.summary()}"
)
def
main():
sniff(
filter
=
"tcp"
, prn
=
packet_callback, store
=
0
,count
=
0
,iface
=
"Parallels VirtIO Ethernet Adapter"
)
if
__name__
=
=
'__main__'
:
main()