使用shell来发tcp包的方法
经常用tcpdump抓包来倒腾和学习,但怎么触发tcp包呢?写一个客户端程序,然后朝server上发包,肯定可以,但还有更简单的方法:
exec8<>/dev/tcp/10.100.70.139/19006 echo-e"stats">&8
用tcpdump抓包的结果为:
xxxxxx$sudotcpdump-ianyport19006-Xnlps0 tcpdump:verboseoutputsuppressed,use-vor-vvforfullprotocoldecode listeningonany,link-typeLINUX_SLL(Linuxcooked),capturesize65535bytes 23:56:54.177781IP10.100.70.139.34209>10.100.70.139.19006:Flags[S],seq2048518213,win43690,options[mss65495,sackOK,TSval1173337789ecr0,nop,wscale8],length0 0x0000:4500003c5ef84000400639e60a64468bE..<^.@.@.9..dF. 0x0010:0a64468b85a14a3e7a19e84500000000.dF...J>z..E.... 0x0020:a002aaaaa20c00000204ffd70402080a................ 0x0030:45efb6bd000000000103030800000000E............... 0x0040:000000000000000000000000............ 23:56:54.177794IP10.100.70.139.19006>10.100.70.139.34209:Flags[S.],seq480321333,ack2048518214,win43690,options[mss65495,sackOK,TSval1173337789ecr1173337789,nop,wscale8],length0 0x0000:4500003c00004000400698de0a64468bE..<..@.@....dF. 0x0010:0a64468b4a3e85a11ca11f357a19e846.dF.J>.....5z..F 0x0020:a012aaaaa20c00000204ffd70402080a................ 0x0030:45efb6bd45efb6bd0103030800000000E...E........... 0x0040:000000000000000000000000............ 23:56:54.177802IP10.100.70.139.34209>10.100.70.139.19006:Flags[.],ack1,win171,options[nop,nop,TSval1173337789ecr1173337789],length0 0x0000:450000345ef94000400639ed0a64468bE..4^.@.@.9..dF. 0x0010:0a64468b85a14a3e7a19e8461ca11f36.dF...J>z..F...6 0x0020:801000aba20400000101080a45efb6bd............E... 0x0030:45efb6bd000000000000000000000000E............... 0x0040:00000000.... 23:57:05.744655IP10.100.70.139.34209>10.100.70.139.19006:Flags[P.],seq1:7,ack1,win171,options[nop,nop,TSval1173340681ecr1173337789],length6 0x0000:4500003a5efa4000400639e60a64468bE..:^.@.@.9..dF. 0x0010:0a64468b85a14a3e7a19e8461ca11f36.dF...J>z..F...6 0x0020:801800aba20a00000101080a45efc209............E... 0x0030:45efb6bd68656c6c6f0a000000000000E...hello....... 0x0040:00000000000000000000.......... 23:57:05.744679IP10.100.70.139.19006>10.100.70.139.34209:Flags[.],ack7,win171,options[nop,nop,TSval1173340681ecr1173340681],length0 0x0000:45000034a98b40004006ef5a0a64468bE..4..@.@..Z.dF. 0x0010:0a64468b4a3e85a11ca11f367a19e84c.dF.J>.....6z..L 0x0020:801000aba20400000101080a45efc209............E... 0x0030:45efc209000000000000000000000000E............... 0x0040:00000000.... 23:57:05.744830IP10.100.70.139.19006>10.100.70.139.34209:Flags[F.],seq1,ack7,win171,options[nop,nop,TSval1173340681ecr1173340681],length0 0x0000:45000034a98c40004006ef590a64468bE..4..@.@..Y.dF. 0x0010:0a64468b4a3e85a11ca11f367a19e84c.dF.J>.....6z..L 0x0020:801100aba20400000101080a45efc209............E... 0x0030:45efc209000000000000000000000000E............... 0x0040:00000000.... 23:57:05.748555IP10.100.70.139.34209>10.100.70.139.19006:Flags[.],ack2,win171,options[nop,nop,TSval1173340682ecr1173340681],length0 0x0000:450000345efb4000400639eb0a64468bE..4^.@.@.9..dF. 0x0010:0a64468b85a14a3e7a19e84c1ca11f37.dF...J>z..L...7 0x0020:801000aba20400000101080a45efc20a............E... 0x0030:45efc209000000000000000000000000E............... 0x0040:00000000....
真的是爽歪歪。能用shell搞定的事,绝不用C/C++.
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对毛票票的支持。如果你想了解更多相关内容请查看下面相关链接