Getting Started

Getting Started

December 4, 2025

Wireshark라는 Packet sniffer 프로그램의 기본적인 사용법을 익힙니다.

Packet sniffer의 원리

Packet sniffer는 커널에서 구현된 네트워크 관련 동작부에서 Data frame을 복사해옵니다. 네트워크의 중간에 껴서 받은 후에 대신 전달하는게 아닙니다.

Data frame은 커널에 어떻게 저장되길래 가져올 수 있는걸까요?

  1. NIC라는 하드웨어 장치가 하드웨어적으로 구현된 과정(CPU가 Clock을 소모하는 것이 아님)을 통해 Frame을 읽어서 DMA buffer에 써줍니다.
  2. NIC가 발생시킨 interrupt로 인해 적절한 Interrupt service Routine이 실행되면서 DMA buffer에서 데이터를 읽어서 내 컴퓨터의 메모리에 올린다. Kernel이 다루는 sk_buff라는 형태로 저장됩니다.
  3. Wireshark의 libpcapsocket(AF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); 같은 방법으로 socket을 엽니다. 이 소켓은 L2 raw frame을 받을 수 있는 특별한 소켓이며, 소켓을 열면 커널은 수신된 sk_buff의 패킷 데이터를 복사해서 해당 Packet Socket의 receive queue에 넣어줍니다.

Internet Protocols의 의미

Transport, Netowrk, Link, Physical 이 4개의 추상적인 Layer를 묶어서 Internet Protocols이라고 부른다고 합니다.

GoodbyeDPI의 http 패킷 변조

GoodbyeDPI

  • TCP-level fragmentation for first data packet
  • TCP-level fragmentation for persistent (keep-alive) HTTP sessions
  • Replacing Host header with hoSt
  • Removing space between header name and value in Host header
  • Adding additional space between HTTP Method (GET, POST etc) and URI
  • Mixing case of Host header value
  • Sending fake HTTP/HTTPS packets with low Time-To-Live value, incorrect checksum or incorrect TCP Sequence/Acknowledgement numbers to fool DPI and prevent delivering them to the destination

이런 기법으로 DPI를 우회하고 있다고 합니다. Wireshark lab을 진행할 때는 끄고 진행해야겠습니다.

hoSt:gaia.cs.umass.edu\r\n

HTTP 표준엔 맞지만 대소문자와 공백을 미묘하게 바꿔서 DPI를 피하고 있습니다. 그런데, HTTPS에서는 HTTP 헤더가 암호화되어있기 때문에 이런 방법으로 DPI가 차단하는 것이 아니라 SNI 필드를 통해서 한다고 합니다.

Getting Started

No. Time Source Destination Protocol Length Info
49 3.154279 192.168.100.16 128.119.245.12 HTTP 257 GET /wireshark-labs/INTRO-wireshark-file1.html HTTP/1.1
0000   70 5d cc e8 b3 b8 a8 a1 59 f1 df 23 08 00 45 00   p]......Y..#..E.
0010   00 f3 9b 74 40 00 80 06 00 00 c0 a8 64 10 80 77   ...t@.......d..w
0020   f5 0c ef 23 00 50 a3 d7 1c 3f 4a ca 8d 1c 50 18   ...#.P...?J...P.
0030   ff ff 9b 22 00 00 47 45 54 20 2f 77 69 72 65 73   ..."..GET /wires
0040   68 61 72 6b 2d 6c 61 62 73 2f 49 4e 54 52 4f 2d   hark-labs/INTRO-
0050   77 69 72 65 73 68 61 72 6b 2d 66 69 6c 65 31 2e   wireshark-file1.
0060   68 74 6d 6c 20 48 54 54 50 2f 31 2e 31 0d 0a 55   html HTTP/1.1..U
0070   73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c   ser-Agent: Mozil
0080   6c 61 2f 35 2e 30 20 28 57 69 6e 64 6f 77 73 20   la/5.0 (Windows 
0090   4e 54 3b 20 57 69 6e 64 6f 77 73 20 4e 54 20 31   NT; Windows NT 1
00a0   30 2e 30 3b 20 6b 6f 2d 4b 52 29 20 57 69 6e 64   0.0; ko-KR) Wind
00b0   6f 77 73 50 6f 77 65 72 53 68 65 6c 6c 2f 35 2e   owsPowerShell/5.
00c0   31 2e 32 36 31 30 30 2e 37 30 31 39 0d 0a 48 6f   1.26100.7019..Ho
00d0   73 74 3a 20 67 61 69 61 2e 63 73 2e 75 6d 61 73   st: gaia.cs.umas
00e0   73 2e 65 64 75 0d 0a 43 6f 6e 6e 65 63 74 69 6f   s.edu..Connectio
00f0   6e 3a 20 4b 65 65 70 2d 41 6c 69 76 65 0d 0a 0d   n: Keep-Alive...
0100   0a                                                .
No. Time Source Destination Protocol Length Info
54 3.359879 128.119.245.12 192.168.100.16 HTTP 495 HTTP/1.1 200 OK (text/html)
0000   a8 a1 59 f1 df 23 70 5d cc e8 b3 b8 08 00 45 00   ..Y..#p]......E.
0010   01 e1 5e 27 40 00 24 06 5c b3 80 77 f5 0c c0 a8   ..^'@.$.\..w....
0020   64 10 00 50 ef 23 4a ca 8d 1c a3 d7 1d 0a 50 18   d..P.#J.......P.
0030   fa 25 b1 95 00 00 48 54 54 50 2f 31 2e 31 20 32   .%....HTTP/1.1 2
0040   30 30 20 4f 4b 0d 0a 44 61 74 65 3a 20 46 72 69   00 OK..Date: Fri
0050   2c 20 30 35 20 44 65 63 20 32 30 32 35 20 30 35   , 05 Dec 2025 05
0060   3a 35 37 3a 32 31 20 47 4d 54 0d 0a 53 65 72 76   :57:21 GMT..Serv
0070   65 72 3a 20 41 70 61 63 68 65 2f 32 2e 34 2e 36   er: Apache/2.4.6
0080   32 20 28 41 6c 6d 61 4c 69 6e 75 78 29 20 4f 70   2 (AlmaLinux) Op
0090   65 6e 53 53 4c 2f 33 2e 35 2e 31 20 6d 6f 64 5f   enSSL/3.5.1 mod_
00a0   66 63 67 69 64 2f 32 2e 33 2e 39 20 6d 6f 64 5f   fcgid/2.3.9 mod_
00b0   70 65 72 6c 2f 32 2e 30 2e 31 32 20 50 65 72 6c   perl/2.0.12 Perl
00c0   2f 76 35 2e 33 32 2e 31 0d 0a 4c 61 73 74 2d 4d   /v5.32.1..Last-M
00d0   6f 64 69 66 69 65 64 3a 20 54 75 65 2c 20 32 38   odified: Tue, 28
00e0   20 4f 63 74 20 32 30 32 35 20 30 35 3a 35 39 3a    Oct 2025 05:59:
00f0   30 31 20 47 4d 54 0d 0a 45 54 61 67 3a 20 22 35   01 GMT..ETag: "5
0100   31 2d 36 34 32 33 31 62 36 37 31 35 37 37 37 22   1-64231b6715777"
0110   0d 0a 41 63 63 65 70 74 2d 52 61 6e 67 65 73 3a   ..Accept-Ranges:
0120   20 62 79 74 65 73 0d 0a 43 6f 6e 74 65 6e 74 2d    bytes..Content-
0130   4c 65 6e 67 74 68 3a 20 38 31 0d 0a 4b 65 65 70   Length: 81..Keep
0140   2d 41 6c 69 76 65 3a 20 74 69 6d 65 6f 75 74 3d   -Alive: timeout=
0150   35 2c 20 6d 61 78 3d 31 30 30 0d 0a 43 6f 6e 6e   5, max=100..Conn
0160   65 63 74 69 6f 6e 3a 20 4b 65 65 70 2d 41 6c 69   ection: Keep-Ali
0170   76 65 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65   ve..Content-Type
0180   3a 20 74 65 78 74 2f 68 74 6d 6c 3b 20 63 68 61   : text/html; cha
0190   72 73 65 74 3d 55 54 46 2d 38 0d 0a 0d 0a 3c 68   rset=UTF-8....<h
01a0   74 6d 6c 3e 0a 43 6f 6e 67 72 61 74 75 6c 61 74   tml>.Congratulat
01b0   69 6f 6e 73 21 20 20 59 6f 75 27 76 65 20 64 6f   ions!  You've do
01c0   77 6e 6c 6f 61 64 65 64 20 74 68 65 20 66 69 72   wnloaded the fir
01d0   73 74 20 57 69 72 65 73 68 61 72 6b 20 6c 61 62   st Wireshark lab
01e0   20 66 69 6c 65 21 0a 3c 2f 68 74 6d 6c 3e 0a       file!.</html>.

주고 받은 두 프레임입니다. 지금 이해되는건 http 패킷뿐입니다. L2 헤더와 L3 헤더가 HTTP 헤더에 비해서 훨씬 짧은 것을 알 수 있습니다.

  1. Which of the following protocols are shown as appearing (i.e., are listed in the Wireshark “protocol” column) in your trace file: TCP, QUIC, HTTP, DNS, UDP, TLSv1.2?

    TCP 스트림 따라가기 기능으로 tcp.stream eq 10를 검색하니 다음 패킷을 확인할 수 있습니다.

    No. Time Source Destination Protocol Length Info
    46 2.948847 192.168.100.16 128.119.245.12 TCP 62 61219 → 80 [SYN] Seq=0 Win=65535 Len=0 MSS=1364 SACK_PERM
    47 3.153487 128.119.245.12 192.168.100.16 TCP 62 80 → 61219 [SYN, ACK] Seq=0 Ack=1 Win=64240 Len=0 MSS=1460
    48 3.153598 192.168.100.16 128.119.245.12 TCP 54 61219 → 80 [ACK] Seq=1 Ack=1 Win=65535 Len=0
    49 3.154279 192.168.100.16 128.119.245.12 HTTP 257 GET /wireshark-labs/INTRO-wireshark-file1.html HTTP/1.1
    53 3.359353 128.119.245.12 192.168.100.16 TCP 60 80 → 61219 [ACK] Seq=1 Ack=204 Win=64037 Len=0
    54 3.359879 128.119.245.12 192.168.100.16 HTTP 495 HTTP/1.1 200 OK (text/html)
    55 3.402180 192.168.100.16 128.119.245.12 TCP 54 61219 → 80 [ACK] Seq=204 Ack=442 Win=65094 Len=0
    367 8.361408 128.119.245.12 192.168.100.16 TCP 60 80 → 61219 [FIN, ACK] Seq=442 Ack=204 Win=64037 Len=0
    368 8.361555 192.168.100.16 128.119.245.12 TCP 54 61219 → 80 [ACK] Seq=204 Ack=443 Win=65094 Len=0
    7009 103.464350 192.168.100.16 128.119.245.12 TCP 54 61219 → 80 [FIN, ACK] Seq=204 Ack=443 Win=65094 Len=0

    Protocol은 TCPHTTP가 보입니다. 아마 curl이 TCP 연결을 명시적으로 끊지 않아서 자동으로 커널이 정리한 것으로 보입니다.

  2. How long did it take from when the HTTP GET message was sent until the HTTP OK reply was received? (By default, the value of the Time column in the packetlisting window is the amount of time, in seconds, since Wireshark tracing began. (If you want to display the Time field in time-of-day format, select the Wireshark View pull down menu, then select Time Display Format, then select Time-of-day.)

    No. Time Source Destination Protocol Length Info
    49 3.154279 192.168.100.16 128.119.245.12 HTTP 257 GET /wireshark-labs/INTRO-wireshark-file1.html HTTP/1.1
    53 3.359353 128.119.245.12 192.168.100.16 TCP 60 80 → 61219 [ACK] Seq=1 Ack=204 Win=64037 Len=0
    54 3.359879 128.119.245.12 192.168.100.16 HTTP 495 HTTP/1.1 200 OK (text/html)

    패킷 캡쳐를 시작하고 3.15초가 지난 시점에 HTTP 패킷이 보내졌고, 3.35초에 응답이 도착했습니다. 0.2초 걸렸습니다.

  3. What is the Internet address of the gaia.cs.umass.edu (also known as www-net.cs.umass.edu)? What is the Internet address of your computer or (if you are using the trace file) the computer that sent the HTTP GET message?

    제 컴퓨터는 공유기를 통해 인터넷에 연결되어 있습니다. 내부 IP 주소는 192.168.100.16입니다. gaia.cs.umass.edu의 주소는 128.119.245.12입니다.

    실제로 웹서버에 도착했을 때 IP datagram의 헤더에는 내부 IP가 아닌 공유기가 중간에서 바꿔준 공유기의 IP가 적혀있었을 것이고, 웹서버는 해당 IP로 응답했을 것입니다.

  4. Expand the information on the HTTP message in the Wireshark “Details of selected packet” window (see Figure 3 above) so you can see the fields in the HTTP GET request message. What type of Web browser issued the HTTP request? The answer is shown at the right end of the information following the “User-Agent:” field in the expanded HTTP message display. [This field value in the HTTP message is how a web server learns what type of browser you are using.]

    User-Agent: Mozilla/5.0 (Windows NT; Windows NT 10.0; ko-KR) WindowsPowerShell/5.1.26100.7019\r\n

    브라우저가 HTTP 요청을 자꾸 HTTPS로 리다이렉트해서 Powershell로 직접 curl로 요청했습니다.

  5. Expand the information on the Transmission Control Protocol for this packet in the Wireshark “Details of selected packet” window (see Figure 3 in the lab writeup) so you can see the fields in the TCP segment carrying the HTTP message. What is the destination port number (the number following “Dest Port:” for the TCP segment containing the HTTP request) to which this HTTP request is being sent?

    Transmission Control Protocol, Src Port: 61219, Dst Port: 80, Seq: 1, Ack: 1, Len: 203

    TCP는 혼잡 제어 역할 뿐만 아니라 Multiplexing을 구현하는 역할을 합니다. 서로 다른 앱을 구분하기 위한 방법으로 Port를 사용합니다.

    • IP Layer에 Port까지 역할을 위임시켜서 TCP에서는 혼잡제어만 하게 디자인하면 안됐을까? 어떤 장/단점이 있는지 잘 모르겠습니다.
  6. Print the two HTTP messages (GET and OK) referred to in question 2 above. To do so, select Print from the Wireshark File command menu, and select the “Selected Packet Only” and “Print as displayed” radial buttons, and then click OK.

    PDF 다운로드

느낀 점

네트워크 스택을 Layered 방식으로 추상화하면 이점이 있는 것은 알겠는데, 이제 각 Layer의 구분을 왜 이렇게 해야 좋은지는 잘 와닿지 않습니다.