คลัง
playbooks

Wireshark Playbook

Wireshark เป็นเครื่องมือวิเคราะห์ network packet ที่ทรงพลังที่สุด คู่มือนี้รวบรวม display filter ที่ใช้บ่อยทั้งหมด, การ follow stream, export objects, การถอด protocol เฉพาะ (HTTP/DNS/USB/TLS), และเทคนิควิเคราะห์แบบใช้งานจริงทั้ง GUI และ tshark

IntermediateAdvanced#wireshark#pcap#network#display-filter#playbook#ctf

1. Display filters (cheat sheet)

filter ที่ใช้บ่อย
# Protocol
http / dns / tcp / udp / icmp / arp / tls / ftp / smb2

# IP / port
ip.addr == 10.0.0.5            # เกี่ยวกับ IP นี้ (src หรือ dst)
ip.src == 10.0.0.5             # เฉพาะ source
tcp.port == 80 / udp.port == 53
tcp.stream eq 5               # stream เฉพาะ

# HTTP
http.request.method == "POST"
http.request.uri contains "admin"
http.response.code == 200
http.host == "target.com"

# ค้นเนื้อหา (หา flag)
frame contains "flag"
tcp contains "password"
http.file_data contains "FLAG"

# ตัด noise
!(arp || icmp || dns)

# DNS
dns.qry.name contains "exfil"
dns.qry.type == 16            # TXT (มัก tunneling/exfil)

# size/time
frame.len > 1000
tcp.flags.syn == 1 && tcp.flags.ack == 0    # SYN (scan)
display filter (กรองที่แสดง) ต่างจาก capture filter (กรองตอนจับ); ใช้ frame contains หา keyword เร็ว

2. Follow Stream + Export Objects

  • Follow TCP/HTTP Stream: คลิกขวา packet → Follow → TCP/HTTP Stream — เห็นบทสนทนาเต็ม(ปุ่มสลับ ASCII/Hex/Raw)
  • Export Objects: File → Export Objects → HTTP/SMB/TFTP — ดึงไฟล์ที่โอนผ่าน network ออกมา
  • Follow แล้ว save: ใน Follow Stream กด Save As ดึง raw data (เช่นไฟล์ที่ถูกส่ง)
  • credential: filter http.request.method==POST → Follow ดู username/password

3. ถอด protocol เฉพาะ

  • HTTP: Export Objects ดึงไฟล์/รูป; ดู POST data หา credential
  • DNS tunneling: filter dns.qry.type==16 (TXT) หรือ query ยาวผิดปกติ = exfil; รวม subdomain แต่ละ query มา decode
  • USB (HID keyboard): filter usb.capdata — ดึง keystroke แล้ว map HID code → ข้อความที่พิมพ์
  • TLS decrypt: Preferences → Protocols → TLS → (Pre)-Master-Secret log filename → ใส่ SSLKEYLOGFILE → เห็น HTTPS plaintext
  • ICMP tunneling: ดู data field ของ ICMP echo (อาจมีข้อมูลซ่อน)
  • FTP: ftp filter ดู USER/PASS (plaintext); ftp-data ดึงไฟล์
tshark (CLI) สำหรับ automateLinux
# protocol hierarchy (ดูว่ามีอะไรบ้าง)
tshark -r cap.pcap -q -z io,phs
# ดึง field เฉพาะ
tshark -r cap.pcap -Y "http.request" -T fields -e http.host -e http.request.uri
# ดึง DNS query ทั้งหมด
tshark -r cap.pcap -Y "dns" -T fields -e dns.qry.name | sort -u
# follow stream เฉพาะ
tshark -r cap.pcap -q -z follow,tcp,ascii,5

4. Workflow วิเคราะห์ pcap

  1. 1Statistics → Protocol Hierarchy — ดูภาพรวม protocol
  2. 2Statistics → Conversations — ใครคุยกับใคร, ปริมาณ
  3. 3filter protocol ที่น่าสนใจ (http/dns/ftp/usb)
  4. 4frame contains 'flag' — ค้น keyword ตรงๆ
  5. 5Follow Stream อ่านบทสนทนา; Export Objects ดึงไฟล์
  6. 6protocol พิเศษ: USB keystroke, DNS/ICMP tunneling, TLS decrypt

5. Quick Reference

  • filter: http / ip.addr==X / tcp.port==N / tcp.stream eq N
  • หา flag: frame contains 'flag'; http.file_data contains
  • POST: http.request.method=='POST' → Follow ดู credential
  • Follow TCP/HTTP Stream; Export Objects ดึงไฟล์
  • DNS tunnel: dns.qry.type==16; USB: usb.capdata (keystroke)
  • TLS decrypt: ใส่ SSLKEYLOGFILE; tshark สำหรับ automate

🧭 จับมือทำทีละขั้น (มีแค่ Kali) + ถ้าติดไปไหนต่อ

สมมติได้ไฟล์ .pcap/.pcapng มาจากโจทย์ (network forensics) มีแค่ Kali เปล่าๆ ทำตามนี้ทีละขั้นเพื่อหา flag/หลักฐาน

  1. 1เช็คว่ามี Wireshark ไหม: `wireshark --version` (Kali มีมาให้แล้ว) ถ้าไม่มี `sudo apt install wireshark -y`
  2. 2เปิดไฟล์: `wireshark cap.pcapng` หรือดูเร็วๆ ก่อนด้วย tshark: `tshark -r cap.pcapng -q -z io,phs` (ดู protocol hierarchy)
  3. 3ดู Statistics → Conversations เพื่อรู้ว่าใครคุยกับใครเยอะสุด
  4. 4ลองค้น keyword ตรงๆ ก่อน: พิมพ์ในช่อง filter `frame contains "flag"` แล้วกด Enter
  5. 5ถ้าไม่เจอ ลองกรองเฉพาะ protocol ที่น่าสนใจ เช่น http หรือ ftp หรือ dns
  6. 6เจอ HTTP POST → คลิกขวา packet → Follow → HTTP Stream ดู credential/ข้อมูลที่ส่ง
  7. 7มีไฟล์แนบผ่าน HTTP/FTP → File → Export Objects → HTTP (หรือ TFTP/SMB) ดึงไฟล์ออกมาดู
  8. 8ถ้า DNS query เยอะผิดปกติ/ยาวแปลกๆ → สงสัย DNS tunneling ลอง `dns.qry.type == 16` หรือ export query มาต่อกัน decode
  9. 9ถ้ามี USB capture → filter `usb.capdata` ดู keystroke แล้วแปลง HID code เป็นตัวอักษร
  10. 10ยังไม่เจออะไร → ลองใช้ tshark ดึงทุก field ที่น่าสงสัยมา grep ต่อ: `tshark -r cap.pcapng -Y http.request -T fields -e http.host -e http.request.uri`
จับมือหา flag ใน pcap
เปิดไฟล์ + ดู protocol hierarchy
wireshark cap.pcapng / tshark -z io,phs
ลอง frame contains 'flag'
✅ เจอ flag ตรงๆ→ จบเลย
❌ ไม่เจอ→ กรอง protocol เฉพาะ (http/dns/ftp) ต่อ
มี HTTP/FTP traffic ไหม
✅ มี→ Follow Stream / Export Objects
❌ ไม่มี→ เช็ค protocol แปลกอื่น (DNS/USB/ICMP)
DNS query ผิดปกติ (ยาว/เยอะ)?
✅ ใช่ สงสัย tunneling→ export query มา decode (base32/hex)
❌ ปกติ→ เช็ค USB capture แทน
มี USB capture?
✅ มี usb.capdata→ ถอด HID keystroke
❌ ไม่มี→ ใช้ tshark ดึงทุก field มา grep เพิ่ม
เจอ flag/หลักฐาน
ขั้นตอน/งานเครื่องมือใน Kaliติดตั้งเพิ่ม (ถ้าไม่มี)เครื่องมือออนไลน์
เปิด/วิเคราะห์ pcapwireshark, tshark-cloudshark.org (อัปโหลดดูออนไลน์)
ดู protocol hierarchytshark -z io,phs--
Follow stream หา credentialWireshark GUI--
ดึงไฟล์แนบออกมาExport Objects (HTTP/TFTP/SMB)--
decode DNS tunneling--cyberchef (from base32/hex)
ถอด USB keystrokeusb.capdata filter-ค้นหา USB HID keycode table
ดู TLS แบบ decryptSSLKEYLOGFILE--
🚑 ถ้าตันสนิท ลองท่าถัดไป: (1) ไฟล์ pcap ใหญ่มากหา flag ด้วยตาไม่ไหว → ไป PCAP Analysis ดูเทคนิค automate ด้วย tshark/scripts (2) เจอไฟล์ที่ดึงออกมาแล้วดูเหมือนถูกซ่อนอีกชั้น → ไป Steganography ต่อ (3) เจอ TLS encrypted ทั้งหมดไม่มี key log → ต้องหา key จากที่อื่นในโจทย์ (4) เจอ protocol แปลกที่ไม่คุ้น → ลองค้น protocol name ใน Wireshark wiki ก่อนเดา

โน้ตของฉัน

ยังไม่มีโน้ตสำหรับหัวข้อนี้