鲨鱼 抓包 oracle,ubuntu下网络抓包工具wireshark tcpdump的使用
需要以下幾個步驟,
1.安裝,sudo apt-get install wireshark
2.運行,sudo wireshark。注意:抓包需要root權限。
3.
4.點擊file下面的那個圖標,列出當前活動的網卡,選擇你需要監控的網卡,點擊start就開始抓包了。
5.監控界面
6.在filter中可以編輯一些規則來過濾掉我們不需要的包類型,只留下我們關心的數據包。
今天在一哥們的Ubuntu虛擬機上裝wireshark怎么都搞不定,只好把這個命令行的東西再拿出來了……
—–
Ubuntu默認是安裝好了tcpdump工具的,如果沒有安裝的話使用sudo apt-get install tcpdump即可下載安裝。
(如果遇到tcpdump: no suitable device found的問題,檢查一下是不是在用root權限下
安裝好tcpdump之后,運行tcpdump:
1. tcpdump -D 獲取網絡適配器列表,以下是在Ubuntu上獲取到的結果:
root@holmesian-laptop:~# tcpdump -D
1.eth0
2.wlan0
3.usbmon1 (USB bus number 1)
4.usbmon2 (USB bus number 2)
5.usbmon3 (USB bus number 3)
6.
7.usbmon5 (USB bus number 5)
8.any (Pseudo-device that captures on all interfaces)
9.lo
2. tcpdump -i 需要監控的網絡適配器編號,例如我想監控我的無線網卡wlan0,則使用tcpdump -i 2。
root@holmesian-laptop:~# tcpdump -i 2
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on wlan0, link-type EN10MB (Ethernet), capture size 96 bytes
21:24:14.578430 00:24:f9:05:78:00 (oui Unknown) Unknown SSAP 0x78 00:1f:3a:18:fa:06 (oui Unknown) Unknown DSAP 0xd8 Inform
21:24:14.578447 00:24:f9:05:78:00 (oui Unknown) Unknown SSAP 0x78 00:1f:3a:18:fa:06 (oui Unknown) Unknown DSAP 0xd8 Information, send seq 0, rcv seq 16, Flags [Command], length 223
21:24:14.995603 00:24:f9:05:78:00 (oui Unknown) Unknown SSAP 0x20 78:dd:08:d1:b2:ca (oui Unknown) Unknown DSAP 0x76 Information, send seq 0, rcv seq 16, Flags [
21:24:15.019811 00:24:f9:05:78:00 (oui Unknown) Unknown SSAP 0xa6 2c:81:58:ec:9c:54 (oui Unknown) Unknown DSAP 0x0a Information, send seq 0, rcv seq 16, Flags [Command], length 72
如果不使用-i來定義監控適配器的話,默認使用列表中的第一個;
3. 使用無線網卡wlan0監控IP地址為172.16.86.111上443端口的tcp協議:
tcpdump -i 2 host 172.16.86.111 and tcp port 443
4. 如果想要顯示數據包的內容,需要使用-X參數,如,我想要顯示捕獲的https數據包http header的內容:
tcpdump -X -i 2 host 172.16.86.111 and tcp port 443
顯示結果如下:
21:27:53.662741 IP holmesian-laptop.local.44239 172.16.86.111.https: Flags [S], seq 24296623, win 5840, options [mss 1460,sackOK,TS val 153804 ecr 0,nop,wscale 6], length 0
0x0000: 4500 003c e463 4000 4006 514a ac10 567e E…c@.@.QJ..V~
0x0010: ac10 566f accf 01bb 0172 bcaf 0000 0000 ..Vo…..r……
0x0020: a002 16d0 66a8 0000 0204 05b4 0402 080a ….f………..
0x0030: 0002 58cc 0000 0000 0103 0306 ..X………
21:27:56.660488 IP holmesian-laptop.local.44239 172.16.86.111.https: Flags [S], seq 24296623, win 5840, options [mss 1460,sackOK,TS val 154554 ecr 0,nop,wscale 6], length 0
0x0000: 4500 003c e464 4000 4006 5149 ac10 567e E…d@.@.QI..V~
0x0010: ac10 566f accf 01bb 0172 bcaf 0000 0000 ..Vo…..r……
0x0020: a002 16d0 63ba 0000 0204 05b4 0402 080a ….c………..
0x0030: 0002 5bba 0000 0000 0103 0306 ..[………
.c
可以看到該結果只顯示了https頭的一部分,沒有顯示全,是因為tcpdump默認將顯示的數據長度截斷了,可以使用-s后面加數據長度,來設置數據顯示長度:
tcpdump -X -s 0 -i 2 host 172.16.86.111 and tcp port 443
以上的例子中,-s 0 表示自動設置長度使其能夠顯示所有數據。
5. 捕獲的數據太多,不斷刷屏,可能需要將數據內容記錄到文件里,需要使用-w參數:
tcpdump -X -s 0 -w aaa host 192.9.200.59 and tcp port 8000
則將之前顯示在屏幕中的內容,寫入tcpdump可執行文件同級目錄下的aaa文件中。
文件查看方式如下,需要使用-r參數:
tcpdump -X -s 0 -i 2 -r holmesian host 172.16.86.111 and tcp port 443
如果這樣寫:
tcpdump -r holmesian
則只能看到最簡
6.總結
總結一下,tcpdump的參數分兩個部分,選項(Options)和表達式(expression):
root@holmesian-laptop:~# tcpdump -h
tcpdump version 4.0.0
libpcap version 1.0.0
Usage: tcpdump [-aAdDefIKlLnNOpqRStuUvxX] [ -B size ] [ -c count ]
[ -C file_size ] [ -E algo:secret ] [ -F file ] [ -G seconds ]
[ -i interface ] [ -M secret ] [ -r file ]
[ -s snaplen ] [ -T type ] [ -w file ] [ -W filecount ]
[ -y datalinktype ] [ -z command ] [ -Z user ]
[ expression ]
總結
以上是生活随笔為你收集整理的鲨鱼 抓包 oracle,ubuntu下网络抓包工具wireshark tcpdump的使用的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 什么是携式超限汽车检测磅?
- 下一篇: 宝马740废气阀更换多少钱?