溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么在shell中發(fā)tcp包

發(fā)布時(shí)間:2021-05-08 17:15:03 來源:億速云 閱讀:273 作者:Leah 欄目:開發(fā)技術(shù)

怎么在shell中發(fā)tcp包?針對(duì)這個(gè)問題,這篇文章詳細(xì)介紹了相對(duì)應(yīng)的分析和解答,希望可以幫助更多想解決這個(gè)問題的小伙伴找到更簡(jiǎn)單易行的方法。

經(jīng)常用tcpdump抓包來倒騰和學(xué)習(xí),但怎么觸發(fā)tcp包呢?寫一個(gè)客戶端程序,然后朝server上發(fā)包,肯定可以,但還有更簡(jiǎn)單的方法:

exec 8<>/dev/tcp/10.100.70.139/19006
echo -e "stats" >&8

用tcpdump抓包的結(jié)果為:

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                ....

關(guān)于怎么在shell中發(fā)tcp包問題的解答就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,如果你還有很多疑惑沒有解開,可以關(guān)注億速云行業(yè)資訊頻道了解更多相關(guān)知識(shí)。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI