内容简介:[TCP/IP] 构造并发送ICMP echo包
安装 dpkt
dpkt is a python module for fast, simple packet creation / parsing, with definitions for the basic TCP/IP protocols.
pip install dpkt
构造Echo packet
import socket
import dpkt
echo = dpkt.icmp.ICMP.Echo()
echo.id = 10086
echo.seq = 1
echo.data = 'hello world'
icmp = dpkt.icmp.ICMP()
icmp.type = dpkt.icmp.ICMP_ECHO
icmp.data = echo
s = socket.socket(socket.AF_INET, socket.SOCK_RAW, dpkt.ip.IP_PROTO_ICMP)
s.connect(('10.10.10.10', 1))
sent = s.send(str(icmp))
print('sent %d bytes' % sent)
监听echo包
# sudo tcpdump -i eth0 icmp and icmp[icmptype]=icmp-echo tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes 08:26:32.397922 IP 10.10.10.9 > 10.10.10.10: ICMP echo request, id 10086, seq 1, length 19
参考
| Bits | 160-167 | 168-175 | 176-183 | 184-191 |
|---|---|---|---|---|
| 160 | Type | Code | 校验码(checksum) | |
| 192 | ID | 序号(sequence) | ||
0
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Algorithms for Image Processing and Computer Vision
Parker, J. R. / 2010-12 / 687.00元
A cookbook of algorithms for common image processing applications Thanks to advances in computer hardware and software, algorithms have been developed that support sophisticated image processing with......一起来看看 《Algorithms for Image Processing and Computer Vision》 这本书的介绍吧!