대용량 패킷을 수집할 경우 Tshark
사용
운영방식만 알아두면 Tshark
를 할 줄 알면 TCPdump
도 어렵지 않게 사용할 수 있다.
D:\Wireshark>tshark -D
1. \Device\NPF_{E0BC4D37-73D9-42B6-8BF1-C7BC385E7955} (로컬 영역 연결* 8)
2. \Device\NPF_{5E930F2C-6151-4EC7-9F39-2BEC63F01E71} (로컬 영역 연결* 7)
3. \Device\NPF_{BD68EB55-F12E-43CB-A30B-5C7260395DB0} (로컬 영역 연결* 6)
4. \Device\NPF_{B98EB064-ACAF-4966-B076-CBBA2BB10546} (Bluetooth 네트워크 연결)
5. \Device\NPF_{26726D03-DE7E-43C2-A751-4DF10AF6D9D4} (Wi-Fi)
6. \Device\NPF_{843C2D32-2C1E-4BF5-8070-65DBDF206F0F} (로컬 영역 연결* 10)
7. \Device\NPF_{9A50788C-9CC4-4E45-9D14-A45AFC11E5E4} (로컬 영역 연결* 9)
8. \Device\NPF_{D4711892-69A7-46B6-9750-E0F5E21F1368} (이더넷 2)
9. \Device\NPF_Loopback (Adapter for loopback traffic capture)
10. \Device\NPF_{72D061B5-FD05-49F5-B43E-CD780A0EEA75} (이더넷)
D:\Wireshark>tshark -i 5
Capturing on 'Wi-Fi'
** (tshark:1052) 17:00:01.643859 [Main MESSAGE] -- Capture started.
** (tshark:1052) 17:00:01.648851 [Main MESSAGE] -- File: "C:\Users\USER\AppData\Local\Temp\wireshark_Wi-FiH7YDE2.pcapng"
1 0.000000 172.30.1.94 → 18.182.44.105 UDP 86 51661 → 29805 Len=44
2 0.000701 18.182.44.105 → 172.30.1.94 UDP 149 29805 → 51661 Len=107
3 0.018896 18.182.44.105 → 172.30.1.94 UDP 384 29805 → 51661 Len=342
4 0.022707 18.182.44.105 → 172.30.1.94 UDP 144 29805 → 51661 Len=102
5 0.031836 172.30.1.94 → 18.182.44.105 UDP 121 54302 → 47683 Len=79
...
그만 수집하고 싶다면 Ctrl
+C
D:\Wireshark>tshark -i 5 -w T1.pcapng
Capturing on 'Wi-Fi'
** (tshark:14820) 17:03:07.913271 [Main MESSAGE] -- Capture started.
** (tshark:14820) 17:03:07.916805 [Main MESSAGE] -- File: "T1.pcapng"
7280
tshark:
이렇게 수집한 패킷 파일은 Wireshark
로 분석하면 된다.
tshark -i 5 -a files:3 -b duration:10 -w T2.pcapng
-a file:3
3개 파일 수집 후 자동 정지
-b duration:10
10초 후에 다음 파일을 생성
-w 파일명.pcapng
추적파일명
Capturing on 'Wi-Fi'
** (tshark:2260) 17:10:06.414741 [Main MESSAGE] -- Capture started.
** (tshark:2260) 17:10:06.418559 [Main MESSAGE] -- File: "T2_00001_20231115171006.pcapng"
1563 ** (tshark:2260) 17:10:16.923454 [Main MESSAGE] -- File: "T2_00002_20231115171016.pcapng"
3000 ** (tshark:2260) 17:10:27.118280 [Main MESSAGE] -- File: "T2_00003_20231115171026.pcapng"
4705
tshark:
tshark -i 5 -f "tcp" -w T3.pcapng
-f "tcp"
캡처필터
Capturing on 'Wi-Fi'
** (tshark:3264) 17:13:18.563899 [Main MESSAGE] -- Capture started.
** (tshark:3264) 17:13:18.566405 [Main MESSAGE] -- File: "T3.pcapng"
133
tshark:
# 형식) tshark -r "파일명.pcapng"
tshark -r "T3.pcapng"
1 0.000000 104.18.22.107 → 172.30.1.94 TLSv1.2 84 Application Data
2 0.054291 172.30.1.94 → 104.18.22.107 TCP 54 51500 → 443 [ACK] Seq=1479064710 Ack=1239335656 Win=510 Len=0
3 0.554317 104.18.22.107 → 172.30.1.94 TLSv1.2 86 Application Data
4 0.595210 172.30.1.94 → 104.18.22.107 TCP 54 51500 → 443 [ACK] Seq=1479064710 Ack=1239335688 Win=510 Len=0
5 0.775281 104.18.22.107 → 172.30.1.94 TLSv1.2 84 Application Data
6 0.819280 172.30.1.94 → 104.18.22.107 TCP 54 51500 → 443 [ACK] Seq=1479064710 Ack=1239335718 Win=509 Len=0
7 1.217289 104.18.22.107 → 172.30.1.94 TLSv1.2 86 Application Data
8 1.267853 172.30.1.94 → 104.18.22.107 TCP 54 51500 → 443 [ACK] Seq=1479064710 Ack=1239335750 Win=509 Len=0
9 1.541179 104.18.22.107 → 172.30.1.94 TLSv1.2 182 Application Data
10 1.591488 172.30.1.94 → 104.18.22.107 TCP 54 56204 → 443 [ACK] Seq=528279210 Ack=1420340482 Win=510 Len=0
...
tshark –r “T1.pcapng” –Y “tcp.analysis.flags”
tshark –r “T1.pcapng” –Y “tcp.analysis.flags” –w tcpflag.pcapng
tshark –r “T1.pcapng” –Y “http.request.method == GET”