使用shell来发tcp包的方法
程序员文章站
2024-02-04 12:47:52
经常用tcpdump抓包来倒腾和学习,但怎么触发tcp包呢?写一个客户端程序,然后朝server上发包,肯定可以,但还有更简单的方法:
exec 8<>...
经常用tcpdump抓包来倒腾和学习,但怎么触发tcp包呢?写一个客户端程序,然后朝server上发包,肯定可以,但还有更简单的方法:
exec 8<>/dev/tcp/10.100.70.139/19006 echo -e "stats" >&8
用tcpdump抓包的结果为:
xxxxxx$ sudo tcpdump -iany port 19006 -xnlps0 tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on any, link-type linux_sll (linux cooked), capture size 65535 bytes 23:56:54.177781 ip 10.100.70.139.34209 > 10.100.70.139.19006: flags [s], seq 2048518213, win 43690, options [mss 65495,sackok,ts val 1173337789 ecr 0,nop,wscale 8], length 0 0x0000: 4500 003c 5ef8 4000 4006 39e6 0a64 468b e..<^.@.@.9..df. 0x0010: 0a64 468b 85a1 4a3e 7a19 e845 0000 0000 .df...j>z..e.... 0x0020: a002 aaaa a20c 0000 0204 ffd7 0402 080a ................ 0x0030: 45ef b6bd 0000 0000 0103 0308 0000 0000 e............... 0x0040: 0000 0000 0000 0000 0000 0000 ............ 23:56:54.177794 ip 10.100.70.139.19006 > 10.100.70.139.34209: flags [s.], seq 480321333, ack 2048518214, win 43690, options [mss 65495,sackok,ts val 1173337789 ecr 1173337789,nop,wscale 8], length 0 0x0000: 4500 003c 0000 4000 4006 98de 0a64 468b e..<..@.@....df. 0x0010: 0a64 468b 4a3e 85a1 1ca1 1f35 7a19 e846 .df.j>.....5z..f 0x0020: a012 aaaa a20c 0000 0204 ffd7 0402 080a ................ 0x0030: 45ef b6bd 45ef b6bd 0103 0308 0000 0000 e...e........... 0x0040: 0000 0000 0000 0000 0000 0000 ............ 23:56:54.177802 ip 10.100.70.139.34209 > 10.100.70.139.19006: flags [.], ack 1, win 171, options [nop,nop,ts val 1173337789 ecr 1173337789], length 0 0x0000: 4500 0034 5ef9 4000 4006 39ed 0a64 468b e..4^.@.@.9..df. 0x0010: 0a64 468b 85a1 4a3e 7a19 e846 1ca1 1f36 .df...j>z..f...6 0x0020: 8010 00ab a204 0000 0101 080a 45ef b6bd ............e... 0x0030: 45ef b6bd 0000 0000 0000 0000 0000 0000 e............... 0x0040: 0000 0000 .... 23:57:05.744655 ip 10.100.70.139.34209 > 10.100.70.139.19006: flags [p.], seq 1:7, ack 1, win 171, options [nop,nop,ts val 1173340681 ecr 1173337789], length 6 0x0000: 4500 003a 5efa 4000 4006 39e6 0a64 468b e..:^.@.@.9..df. 0x0010: 0a64 468b 85a1 4a3e 7a19 e846 1ca1 1f36 .df...j>z..f...6 0x0020: 8018 00ab a20a 0000 0101 080a 45ef c209 ............e... 0x0030: 45ef b6bd 6865 6c6c 6f0a 0000 0000 0000 e...hello....... 0x0040: 0000 0000 0000 0000 0000 .......... 23:57:05.744679 ip 10.100.70.139.19006 > 10.100.70.139.34209: flags [.], ack 7, win 171, options [nop,nop,ts val 1173340681 ecr 1173340681], length 0 0x0000: 4500 0034 a98b 4000 4006 ef5a 0a64 468b e..4..@.@..z.df. 0x0010: 0a64 468b 4a3e 85a1 1ca1 1f36 7a19 e84c .df.j>.....6z..l 0x0020: 8010 00ab a204 0000 0101 080a 45ef c209 ............e... 0x0030: 45ef c209 0000 0000 0000 0000 0000 0000 e............... 0x0040: 0000 0000 .... 23:57:05.744830 ip 10.100.70.139.19006 > 10.100.70.139.34209: flags [f.], seq 1, ack 7, win 171, options [nop,nop,ts val 1173340681 ecr 1173340681], length 0 0x0000: 4500 0034 a98c 4000 4006 ef59 0a64 468b e..4..@.@..y.df. 0x0010: 0a64 468b 4a3e 85a1 1ca1 1f36 7a19 e84c .df.j>.....6z..l 0x0020: 8011 00ab a204 0000 0101 080a 45ef c209 ............e... 0x0030: 45ef c209 0000 0000 0000 0000 0000 0000 e............... 0x0040: 0000 0000 .... 23:57:05.748555 ip 10.100.70.139.34209 > 10.100.70.139.19006: flags [.], ack 2, win 171, options [nop,nop,ts val 1173340682 ecr 1173340681], length 0 0x0000: 4500 0034 5efb 4000 4006 39eb 0a64 468b e..4^.@.@.9..df. 0x0010: 0a64 468b 85a1 4a3e 7a19 e84c 1ca1 1f37 .df...j>z..l...7 0x0020: 8010 00ab a204 0000 0101 080a 45ef c20a ............e... 0x0030: 45ef c209 0000 0000 0000 0000 0000 0000 e............... 0x0040: 0000 0000 ....
真的是爽歪歪。 能用shell搞定的事, 绝不用c/c++.
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接