【工具】ubuntu16安装sendip发包工具,模拟发送tcpudpicmp报文

【⼯具】ubuntu16安装sendip发包⼯具,模拟发送tcpudpicmp
报⽂
写在开篇,最近因为测试需求,要使⽤Linux虚机模拟tcp/udp等协议报⽂,⽹上⼀搜,⼯具很多,⽂档不少,看着也不难,结果⼀装⼀堆报错,令⼈头秃。。。
最后翻到这篇⽂章真的是太绝了,瞬间解决安装报错问题,也才发现原来其实并不需要下载安装包再解压之类的操作就可以实现安装使⽤。。。
原⽂链接: (注:本⽂就实际操作中遇到的⼩细节出现的问题做了略微修改,⽐如使⽤apt-get进⾏安装时需要先update更新)
1、发包⼯具
1.1 sendip
是⼀个linux平台的命令⾏发数据包⼯具,⽬前(2018年2⽉)⽀持的协议有ipv4、ipv6、icmp、tcp、udp、bgp、rip、ntp。
安装:
sudo apt-get update
sudo apt-get install sendip
源码下载地址:
简单使⽤:
(举例:
1、发送ICMPv4报⽂,-p icmp 将默认发送ICMP echo request报⽂,-v选项可在终端打印发送的报⽂
微波天线
sendip -v -p ipv4 -is 192.168.2.129 -id 192.168.2.1 -p icmp -d 0xcafecafecafe 192.168.2.1
-v:打印发送报⽂内容
-p:协议(⽀持ipv4/ipv6/icmp/tcp/udp/...)
武士道精神-is:源ip
-id:⽬的Ip
-
d:携带的内容
2、发送TCP报⽂
sendip -v -p ipv4 -is 20.1.1.20 -id 20.1.1.21 -p tcp -ts 1024 -td 1024 -d 0xcafecafecafeabcdef 20.1.1.21
-ts:源端⼝
-td:⽬的端⼝
在⽬的端抓包查看该报⽂:tcpdump host 20.1.1.20 -nei ens160
05:28:54.673093 00:50:56:a6:79:73 > 00:50:56:a6:40:3e, ethertype 802.1Q (0x8100), length 64: vlan 520, p 0, ethertype IPv4, 20.1.1.20.200 > 20.1.1.21.300: Flags [S], seq 2250301441:2250301447, win 65535, length 6
3、发送IPv4 UDP报⽂,发送TCP只需把udp替换为tcp即可
sendip -v -p ipv4 -is 20.1.1.20 -id 20.1.1.21 -p udp -us 200 -ud 300 -d 0xcafecafecafe 20.1.1.21
高斯函数
bbc 抓包:
05:32:30.514950 00:50:56:a6:79:73 > 00:50:56:a6:40:3e, ethertype 802.1Q (0x8100), length 64: vlan 520, p 0, ethertype IPv4, 20.1.1.20.200 > 20.1.1.21.300: UDP, length 6
4、发送IPv6 UDP报⽂,同样发送TCP仅需把udp替换为tcp
sendip -p ipv6 -6s 2::3 -p udp -d 0xcafe 2::1
通⽤选项:
1. -d 要携带的数据。rN随机产⽣N个字节,0x之后带⼗六进制,0之后带8进制。
2. -f 从⽂件中读取要携带的数据。
3. -p 加载协议模块,只有加载了才能使⽤。
4. -v 打印整个发出的包。
ipv4模块:
1. -iv x 版本 Default: 4
2. -ih x ⾸部长度 Default: Correct
3. -iy x 区分服务 Default: 0
4. -il x 总长度 Default: Correct
5. ----------------------------------------------32bit
6. -ii x 标识 Default: Random
7. -ifr x 标志 Default: 0 (options are 0,1,r)
8. -if x ⽚偏移 Default: 0
9. ----------------------------------------------32bit
0. -it x ⽣存时间 Default: 255
1. -ip x 协议 Default: 0, or set by underlying protocol
2. -ic x ⾸部检验和 Default: Correct
3. ----------------------------------------------32bit
4. -is x 源地址 Default: 127.0.0.1
5. ----------------------------------------------32bit
6. -id x ⽬的地址 Default: Correct
7. ----------------------------------------------32bit
8. 下⾯全是可选字段(⽐较少⽤,不译):
19.
0. -ifd x IP don't fragment flag (see README)
1. Default: 0 (options are 0,1,r)
2. -ifm x IP more fragments flag (see README)
3. Default: 0 (options are 0,1,r)
4. -ionum x
5. IP option as string of hex bytes (length is always correct)
6. Default: (no options)
7. -ioeol IP option: end of list
8. -ionop IP option: no-op
永芳化妆品9. -iorr x
0. IP option: record route. Format: pointer:addr1:addr2:...
1. -iots x
2. IP option: timestamp. Format: pointer:overflow:flag:(ip1:)ts1:(ip2:)ts2:...
3. -iolsr x
4. IP option: loose source route. Format: pointer:addr1:addr2:...
5. -iosid x
6. IP option: stream identifier
7. -iossr x
8. IP option: strict source route. Format: pointer:addr1:addr2:...
tcp模块:
1. -ts x 源端⼝ Default: 0
2. -td x ⽬的端⼝ Default: 0
3. ----------------------------------------------32bit
4. -tn x 序号 Default: Random
5. ----------------------------------------------32bit
6. -ta x 确认号 Default: 0
7. ----------------------------------------------32bit
8. -tt x 数据偏移 Default: Correct
9. -tr x 保留(ECN、CWR看rfc2481) Default: 0
0. -tfu x URG Default: 0, or 1 if -tu specified (options are 0,1,r)
1. -tfa x ACK Default: 0, or 1 if -ta specified (options are 0,1,r)
2. -tfp x PSH Default: 0 (options are 0,1,r)
3. -tfr x RST Default: 0 (options are 0,1,r)
4. -tfs x SYN Default: 1 (options are 0,1,r)
5. -tff x FIN Default: 0 (options are 0,1,r)
6. -tw x 窗⼝ Default: 65535
7. ----------------------------------------------32bit
8. -tc x 检验和 Default: Correct
9. -tu x 紧急指针 Default: 0
0. ----------------------------------------------32bit
1. 下⾯全是可选字段(⽐较少⽤,不译):
2. -tonum x TCP option as string of hex bytes (length is always correct)
3. Default: (no options)
4. -toeol TCP option: end of list
5. -tonop TCP option: no op
6. -tomss x
7. TCP option: maximum segment size
8. -towscale x
9. TCP option: window scale (rfc1323)
0. -tosackok
1. TCP option: allow selective ack (rfc2018)
2. -tosack x
3. TCP option: selective ack (rfc2018), format is l_edge1:r_edge1,l_edge2:
4. -tots x
5. TCP option: timestamp (rfc1323), format is tsval:tsecr
udp模块:
1. -us x 源端⼝ Default: 0
2. -ud x ⽬的端⼝ Default: 0
3. -ul x 长度 Default: Correct
4. -uc x 检验和 Default: Correct
要注意,按照从左到右的顺序依次封装报⽂,所以ip报⽂必须写在其他报⽂之前。如果协议中需要检验和之类的就按默认的就⾏了,省去计算的痛苦。下⾯有⼏个例⼦:
1、发送ICMPv4报⽂,-p icmp 将默认发送ICMP echo request报⽂,-v选项可在终端打印发送的报⽂
sendip -v -p ipv4 -is 192.168.2.129 -id 192.168.2.1 -p icmp -d 0xcafecafecafe 192.168.2.1
河北卫视真情旋律2、发送ICMPv6报⽂
sendip -p ipv6 -6s 2::3 -p icmp -d 0xcafecafecafe 2::1
3、发送IPv4 UDP报⽂,发送TCP只需把udp替换为tcp即可
sendip -p ipv4 -is 192.168.2.129 -p udp -d 0xcafe 192.168.2.1
4、发送IPv6 UDP报⽂,同样发送TCP仅需把udp替换为tcp
sendip -p ipv6 -6s 2::3 -p udp -d 0xcafe 2::1
5、将 test⽂件内容发送到udp端⼝
sendip -v -p ipv4 -id 14.215.177.39 -p udp -f test
sendip -p ipv4 -is 192.168.1.2 -id 192.168.1.1 -p icmp -d le
其中主要的结构是sendip ⽹络层上⼀层数据 domain,domain是⽬的主机,可以是或192.168.1.1之类的。如果出现什么错误就会打印出帮助信息,⾥⾯有⼀⾏是提⽰错误原因,别漏看了。⾄于能不能发不规则的包(如数据与报⽂长度不符合、校验和乱写之类的),实际会不会发出去就没进⾏测试了。
1.2 tcpreply
tcpreplay是⼀种pcap包的重放⼯具, 它可以将⽤ethreal, wireshark⼯具抓下来的包原样或经过任意修改后重放回去. 它允许你对报⽂做任意的修改(主要是指对2层, 3层, 4层报⽂头), 指定重放报⽂的速度等, 这样tcpreplay就可以⽤来复现抓包的情景以定位bug, 以极快的速度重放从⽽实现压⼒测试。
安装使⽤⽅法参考:
2、抓包⼯具
2.1、tcpdump
:tcpdump可以将⽹络中传送的数据包完全截获下来提供分析。它⽀持针对⽹络层、协议、主机、⽹络或端⼝的过滤,并提供and、or、not等逻辑语句来帮助你去掉⽆⽤的信息。

本文发布于:2024-09-22 06:40:15,感谢您对本站的认可!

本文链接:https://www.17tex.com/xueshu/14394.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:打印   发送   问题   安装
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议