# lab10 Display Filter (Wireshark) 예시 모음
# 사용처: Wireshark 상단 필터 바 · tshark -Y
# 적용 시점: 캡처 후 표시단 (페이로드 디코딩 가능 — http / dns / tls / kerberos)

# ─── 호스트 / IP ─────────────────────────────────────────────
ip.addr == 192.168.1.10
ip.src == 192.168.1.10
ip.dst == 192.168.1.10
ip.addr == 192.168.1.10 || ip.addr == 10.0.0.5
!(ip.addr == 192.168.1.10)
ip.src in {192.168.1.10, 192.168.1.20, 192.168.1.30}

# ─── 네트워크 / 서브넷 ───────────────────────────────────────
ip.addr == 192.168.1.0/24
ip.src == 10.0.0.0/8

# ─── 포트 ────────────────────────────────────────────────────
tcp.port == 80
tcp.srcport == 80
tcp.dstport == 443
udp.port == 53
tcp.port in {80, 443, 8080}

# ─── 프로토콜 (페이로드 디코딩) ──────────────────────────────
tcp
udp
icmp
arp
http
http2
dns
tls
ssh
smb / smb2
kerberos
quic
ntp
mqtt

# ─── TCP 플래그 ──────────────────────────────────────────────
tcp.flags.syn == 1                            # SYN
tcp.flags.syn == 1 && tcp.flags.ack == 0      # 첫 SYN (3-way 시작)
tcp.flags.syn == 1 && tcp.flags.ack == 1      # SYN-ACK
tcp.flags.ack == 1
tcp.flags.fin == 1                            # FIN (정상 종료)
tcp.flags.reset == 1                          # RST (비정상)
tcp.flags.push == 1

# ─── TCP 비정상 / 분석 ───────────────────────────────────────
tcp.analysis.retransmission                   # 재전송
tcp.analysis.fast_retransmission              # 빠른 재전송
tcp.analysis.duplicate_ack                    # 중복 ACK
tcp.analysis.zero_window                      # Zero Window
tcp.analysis.window_full                      # 윈도우 가득
tcp.analysis.out_of_order                     # 순서 어긋남
tcp.analysis.lost_segment                     # 세그먼트 손실
tcp.analysis.keep_alive
tcp.window_size < 1000
tcp.time_delta > 1                            # 1초 이상 패킷 간격

# ─── HTTP ────────────────────────────────────────────────────
http.request                                  # 요청만
http.response                                 # 응답만
http.request.method == "POST"
http.request.method == "GET"
http.request.uri contains "/login"
http.request.uri matches "^/api/v[12]/"
http.host == "example.com"
http.user_agent contains "curl"
http.response.code == 500
http.response.code >= 400
http.referer contains "google"
http.content_type contains "json"

# ─── DNS ─────────────────────────────────────────────────────
dns.qry.name == "google.com"
dns.qry.name contains "naver"
dns.qry.type == 1                             # A   (1=A, 28=AAAA, 15=MX, 16=TXT, 5=CNAME)
dns.qry.type == 28                            # AAAA
dns.flags.response == 0                       # 질의만
dns.flags.response == 1                       # 응답만
dns.flags.rcode != 0                          # 응답 에러 (3=NXDOMAIN)

# ─── TLS ─────────────────────────────────────────────────────
tls.handshake.type == 1                       # Client Hello
tls.handshake.type == 2                       # Server Hello
tls.handshake.type == 11                      # Certificate
tls.record.version == 0x0303                  # TLS 1.2
tls.handshake.extensions_server_name == "example.com"

# ─── ICMP ────────────────────────────────────────────────────
icmp                                          # 전체
icmp.type == 0                                # echo reply
icmp.type == 3                                # destination unreachable
icmp.type == 8                                # echo request (ping)
icmp.type == 11                               # TTL exceeded (traceroute)

# ─── ARP ─────────────────────────────────────────────────────
arp
arp.opcode == 1                               # request
arp.opcode == 2                               # reply

# ─── 비교 연산자 ─────────────────────────────────────────────
frame.len > 1000                              # 크기
frame.time_delta > 1
ip.ttl < 10                                   # TTL 작음
tcp.window_size < 1000

# ─── 다중 조건 ───────────────────────────────────────────────
ip.addr == 10.0.0.1 && tcp.port == 22
ip.addr == 10.0.0.1 || ip.addr == 10.0.0.2
tcp && !(tcp.port == 22)
http.request.method == "POST" && http.host == "example.com"

# ─── 운영 1-liner ────────────────────────────────────────────
# IP 별 SYN 갯수 (포트 스캔 / SYN flood 탐지)
# tshark -r FILE -Y 'tcp.flags.syn==1 && tcp.flags.ack==0' -T fields -e ip.src | sort | uniq -c | sort -rn

# HTTP 응답 코드별 분포
# tshark -r FILE -q -z http,tree

# URI 별 호출 수
# tshark -r FILE -q -z http_req,tree

# TCP 대화 별 바이트
# tshark -r FILE -q -z conv,tcp
