Sendip 命令行發包工具,支持IP、TCP、UDP等

Sendip是一個linux平臺的命令行發數據包工具,目前(2018年2月)支持的協議有ipv四、ipv六、icmp、tcp、udp、bgp、rip、ntp,做者表示其餘協議將會後面支持,當他有空寫的時候。Sendip很強大,它支持自定義頭部和數據(也就是IP層以上的整個包),沒有過多的限制,因此連源IP均可以隨意寫,並且裏面也提供了一些默認的選項,能夠擇需而發,很是方便。又由於它是命令行的,還支持從文件中直接讀取整個packet發送,因此適合用腳本批量測試。它只是個發包工具,對於發出去的包,收到了什麼樣的回覆,Sendip是不知道的,因此要獲得回覆的包就只能用抓包工具了。它的源碼也很簡單,沒有過多平臺相關的代碼,若是不理解也能夠看源碼。html

其實這個工具已經知足了個人要求,以前下載的PackETH是GUI版的,連數據鏈路層(link layer)都支持,也要求必須提供這一層的相關信息才能發包,這一層通常不太關心,它又不提供自動封裝,總的來講不太適合用。linux

Sendip簡單使用

常見協議報頭可參考常見協議TCP、UDP、IP圖ios

通用選項:git

-d    要攜帶的數據。rN隨機產生N個字節,0x以後帶十六進制,0以後帶8進制。
-f    從文件中讀取要攜帶的數據。
-p    加載協議模塊,只有加載了才能使用。
-v    打印整個發出的包。

ipv4模塊:github

-iv x      版本               Default: 4
-ih x      首部長度       Default: Correct
-iy x      區分服務       Default: 0
-il x      總長度           Default: Correct
----------------------------------------------32bit
-ii x      標識               Default: Random
-ifr x     標誌               Default: 0 (options are 0,1,r)
-if x      片偏移           Default: 0
----------------------------------------------32bit
-it x      生存時間       Default: 255
-ip x      協議             Default: 0, or set by underlying protocol
-ic x      首部檢驗和   Default: Correct
----------------------------------------------32bit
-is x      源地址          Default: 127.0.0.1
----------------------------------------------32bit
-id x      目的地址      Default: Correct
----------------------------------------------32bit
下面全是可選字段(比較少用,不譯):

-ifd x IP don't fragment flag (see README)
       Default: 0 (options are 0,1,r)
-ifm x IP more fragments flag (see README)
       Default: 0 (options are 0,1,r)
-ionum x
       IP option as string of hex bytes (length is always correct)
       Default: (no options)
-ioeol IP option: end of list
-ionop IP option: no-op
-iorr x
       IP option: record route. Format: pointer:addr1:addr2:...
-iots x
       IP option: timestamp. Format: pointer:overflow:flag:(ip1:)ts1:(ip2:)ts2:...
-iolsr x
       IP option: loose source route. Format: pointer:addr1:addr2:...
-iosid x
       IP option: stream identifier
-iossr x
       IP option: strict source route. Format: pointer:addr1:addr2:...

tcp模塊:網絡

-ts x  源端口       Default: 0
-td x  目的端口       Default: 0
----------------------------------------------32bit
-tn x  序號       Default: Random
----------------------------------------------32bit
-ta x  確認號       Default: 0
----------------------------------------------32bit
-tt x  數據偏移       Default: Correct
-tr x  保留(ECN、CWR看rfc2481)       Default: 0
-tfu x URG       Default: 0, or 1 if -tu specified (options are 0,1,r)
-tfa x ACK       Default: 0, or 1 if -ta specified (options are 0,1,r)
-tfp x PSH       Default: 0 (options are 0,1,r)
-tfr x RST       Default: 0 (options are 0,1,r)
-tfs x SYN       Default: 1 (options are 0,1,r)
-tff x FIN       Default: 0 (options are 0,1,r)
-tw x  窗口       Default: 65535
----------------------------------------------32bit
-tc x  檢驗和       Default: Correct
-tu x  緊急指針       Default: 0
----------------------------------------------32bit
下面全是可選字段(比較少用,不譯):
-tonum x       TCP option as string of hex bytes (length is always correct)
       Default: (no options)
-toeol TCP option: end of list
-tonop TCP option: no op
-tomss x
       TCP option: maximum segment size
-towscale x
       TCP option: window scale (rfc1323)
-tosackok
       TCP option: allow selective ack (rfc2018)
-tosack x
       TCP option: selective ack (rfc2018), format is l_edge1:r_edge1,l_edge2:r_edge2...
-tots x
       TCP option: timestamp (rfc1323), format is tsval:tsecr

udp模塊:dom

-us x  源端口    Default: 0
-ud x  目的端口    Default: 0
-ul x 長度    Default: Correct
-uc x  檢驗和    Default: Correct

要注意,按照從左到右的順序依次封裝報文,因此ip報文必須寫在其餘報文以前。若是協議中須要檢驗和之類的就按默認的就好了,省去計算的痛苦。下面有幾個例子:tcp

  • sendip -v -p ipv4 -id 14.215.177.39 -p udp -f test www.baidu.com
  • sendip -p ipv4 -is 192.168.1.2 -id 192.168.1.1 -p icmp -d 0x89ABCDEF www.google.com

其中主要的結構是sendip 網絡層 上一層 數據 domain,domain是目的主機,能夠是www.baidu.com192.168.1.1之類的。若是出現什麼錯誤就會打印出幫助信息,裏面有一行是提示錯誤緣由,別漏看了。至於能不能發不規則的包(如數據與報文長度不符合、校驗和亂寫之類的),實際會不會發出去就沒進行測試了。ide

相關文章
相關標籤/搜索