iT邦幫忙

2018 iT 邦幫忙鐵人賽
DAY 21
2
Security

鯊魚咬電纜:30天玩Wireshark系列 第 26

[Day 21] Wireshark動作太慢?來試試tshark吧

今天要介紹的是如何使用指令介面的方式來使用Wireshark,也就是tshark這個指令。

tshark的功能大致上就是Wireshark的基本功能,例如擷取流量及下過濾式等,一些統計圖表或檔案匯出等需要使用者介面的較進階功能就無法用tshark來實現,那使用介面就無法使用使用tshark有什麼好處呢?像是之前曾經稍微提到過,如果封包檔案很大的話,不論是怎樣的操作,直接使用Wireshark的圖形化介面都會造成處理速度很慢,所以如果想要處理比較大的檔案,或是想要在寫程式時使用Wireshark功能的時候,都很適合直接使用tshark這個指令來處理。

那tshark的位置在哪裡呢?首先必須先知道Wireshark是安裝在哪個資料夾底下,以我的電腦為例,Wireshark的安裝路徑是C:\Program Files\Wireshark,而我們就可以在同樣的路徑中找到一個叫做tshark.exe的應用程式,這也就是我們要用到的tshark位置啦。

https://ithelp.ithome.com.tw/upload/images/20180109/20107304hyiuowWYt8.png

順帶一題,同樣的路徑下除了今天介紹的tshark外,還有很多Wireshark提供可以在cmd執行的小工具可以使用,之後會再介紹給大家。

確認路徑後,我們就可以打開cmd,首先先下「cd C:\Program Files\Wireshark」的指令,把目錄移到放有tshark.exe的目錄下,如下圖紅框,接著就可以開始使用tshark的功能了,使用方式也很簡單,就是依需求下「tshark -指令」這樣的指令即可,例如我們想要先看tshark有哪些參數可以下,就可以下「tshark -help」的指令,如下圖綠框,畫面就會回傳所有可以下的指令列表。

https://ithelp.ithome.com.tw/upload/images/20180109/20107304p24ZuowZkr.png

以下是tshark目前可以使用的參數列表,如果想要看各個參數更詳細的介紹,可以到官網介紹頁面(網址:https://www.wireshark.org/docs/man-pages/tshark.html ),也可以使用剛剛的「tshark -help」這個指令來觀看喔。

tshark [ -2 ] [ -a <capture autostop condition> ] ... [ -b <capture ring buffer option>] ... [ -B <capture buffer size> ] [ -c <capture packet count> ] [ -C <configuration profile> ][ -d <layer type>==<selector>,<decode-as protocol> ] [ -D ] [ -e <field> ] [ -E <field print option> ] [ -f <capture filter> ] [ -F <file format> ] [ -g ] [ -h ] [ -H <input hosts file> ][ -i <capture interface>|- ] [ -j <protocol match filter> ] [ -I ] [ -K <keytab> ] [ -l ] [ -L ] [ -n ] [ -N <name resolving flags> ] [ -o <preference setting> ] ... [ -O <protocols> ] [ -p ] [ -P ][ -q ] [ -Q ] [ -r <infile> ] [ -R <Read filter> ] [ -s <capture snaplen> ] [ -S <separator> ] [ -t a|ad|adoy|d|dd|e|r|u|ud|udoy ] [ -T ek|fields|json|pdml|ps|psml|tabs|text ] [ -u <seconds type>][ -U <tap_name>] [ -v ] [ -V ] [ -w <outfile>|- ] [ -W <file format option>] [ -x ] [ -X <eXtension option>] [ -y <capture link type> ] [ -Y <displaY filter> ] [ -M <auto session reset> ][ -z <statistics> ] [ --capture-comment <comment> ] [ --export-objects <protocol>,<destdir> ] [ --enable-protocol <proto_name> ] [ --disable-protocol <proto_name> ][ --enable-heuristic <short_name> ] [ --disable-heuristic <short_name> ] [ <capture filter> ]

tshark -G [ <report type> ]

今天先把tshark的概念介紹給大家,明天會再介紹一些如何實際使用tshark的範例,敬請期待囉。


上一篇
[Day 20] 解解題 Puzzle #6: Ann’s Aurora
下一篇
[Bonus Day 19] 台灣資安管理法草案 Information Security Management Bill Introduction
系列文
鯊魚咬電纜:30天玩Wireshark51
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言