内容简介:[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
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- [ActionScript 3.0] AS向php发送二进制数据方法之——在URLRequest中构造HTTP协议发送数据
- Java类 静态代码块、构造代码块、构造函数初始化顺序
- TS 的构造签名和构造函数类型是啥?傻傻分不清楚
- 只有你能 new 出来!.NET 隐藏构造函数的 n 种方法(Builder Pattern / 构造器模式)
- 构造函数、原型、原型链、继承
- Vue源码: 构造函数入口
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Masterminds of Programming
Federico Biancuzzi、Chromatic / O'Reilly Media / 2009-03-27 / USD 39.99
Description Masterminds of Programming features exclusive interviews with the creators of several historic and highly influential programming languages. Think along with Adin D. Falkoff (APL), Jame......一起来看看 《Masterminds of Programming》 这本书的介绍吧!