Podglądanie sieci

Ten tekst powstał w czasie pandemii gdy zastanawiałem się, jak zaprezentować wyniki działani aprogramu tcpdump w warunkach gdy równocześnie trwa transmisja audio i video z laptopa. Ze względu na ogromne ilości pakietów transmitowane przez komputer — było to niemożliwe.

Wykonałem wszystko w warunkach laboratoryjnych i zapisałem do pliku. Dziś może to być ilustracja gdy zupełnie nic nie wychodzi.

tcpdump

  • Program tcpdump to narzędzie pozwalające podsłuchiwać wszystkie pakiety które „widzi” karta sieciowa.
  • W czasach gdy powszechnie używane są switche (przełączniki sieciowe) ich użyteczność jest mniejsza.
  • Program, do uruchomienia, wymaga uprawnień administratora.

ping

  1. ping to polecenie wysyłające jeden pakiet informacji do wskazanego komputera w sieci.
  2. Komputer powinien „odpowiedzieć” na ten pakiet.
  3. Wysyłający „zapytanie” ping oczekuje na odpowiedź:
    • jeżeli ta nie nadejdzie — można przypuszczać, że zdalny komputer nie funkcjonuje/nie ma do niego dostępu sieciowego;
    • gdy odpowiedź nadejdzie — wyliczany jest czas potrzebny do przejścia pakietu tam-i-z-powrotem (RTT: Round Trip Time).
  4. Pingowany komputer nie musi odpowiadać na pakiety ping: albo je ignoruje (co nie jest dobrą praktyką) albo zapytania ping są odfiltrowywane przez firewall (co jest dosyć częste).

ping — przykłady

Opisana procedura jest następująca

  1. W jednym terminalu program tcpdump nasłuchuje co się dzieje w sieci filtrując pakiety typu ping

    sudo tcpdump -v icmp 
    
  2. W drugim terminalu operator uruchamia polecenie

    ping -c 1 156.17.8.1
    
  3. Odpowiedź programu ping

    64 bytes from 156.17.8.1: icmp_seq=1 ttl=57 time=11.6 ms
    
    --- 156.17.8.1 ping statistics ---
    1 packets transmitted, 1 received, 0% packet loss, time 0ms
    rtt min/avg/max/mdev = 11.606/11.606/11.606/0.000 ms
    

Poniżej informacje zebrane przez tcpdump

tcpdump: listening on wlp1s0, link-type EN10MB (Ethernet), capture size 262144 bytes
08:35:30.016733 IP (tos 0x0, ttl 64, id 44286, offset 0, flags [DF], proto ICMP (1), length 84)
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 2, seq 1, length 64
08:35:30.028304 IP (tos 0x0, ttl 57, id 44729, offset 0, flags [none], proto ICMP (1), length 84)
    ldhpux.immt.pwr.wroc.pl > asusux: ICMP echo reply, id 2, seq 1, length 64

traceroute

  1. traceroute (w Windows zbliżoną funkcjonalność ma program tracert)
  2. Obecnie program jest zastępowany przez znacznie lepszy mtragregujący możliwości narzędzi traceroute i ping.

traceroute — przykłady

traceroute to 156.17.8.1 (156.17.8.1), 30 hops max, 60 byte packets
 1  _gateway (192.168.1.1)  3.326 ms  3.219 ms  3.461 ms
 2  10.150.128.1 (10.150.128.1)  13.564 ms  13.805 ms  14.398 ms
 3  89-75-10-177.infra.chello.pl (89.75.10.177)  18.718 ms  19.620 ms  20.235 ms
 4  chello062179003242.chello.pl (62.179.3.242)  14.525 ms  15.202 ms  15.766 ms
 5  156.17.250.215 (156.17.250.215)  22.584 ms  23.549 ms  23.008 ms
 6  centrum-rtr-karkonosz.wask.wroc.pl (156.17.254.110)  23.989 ms  9.186 ms  10.041 ms
 7  z-wask2-do-pwr2.pwrnet.pwr.wroc.pl (156.17.18.244)  23.429 ms  23.612 ms  23.751 ms
 8  156.17.33.1 (156.17.33.1)  24.114 ms  25.111 ms  24.146 ms
 9  ldhpux.immt.pwr.wroc.pl (156.17.8.1)  25.435 ms  25.116 ms  25.687 ms

Dane zebrane przez tcpdump

tcpdump: listening on wlp1s0, link-type EN10MB (Ethernet), capture size 262144 bytes
10:35:41.293265 IP (tos 0x0, ttl 64, id 1999, offset 0, flags [none], proto ICMP (1), length 56)
    _gateway > asusux: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 57913, offset 0, flags [none], proto UDP (17), length 60)
    asusux.57731 > ldhpux.immt.pwr.wroc.pl.33434: UDP, length 32

10:35:41.305051 IP (tos 0x0, ttl 254, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    10.150.128.1 > asusux: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 57914, offset 0, flags [none], proto UDP (17), length 60)
    asusux.44961 > ldhpux.immt.pwr.wroc.pl.33435: UDP, length 32

10:35:41.305550 IP (tos 0x0, ttl 253, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    89-75-10-177.infra.chello.pl > asusux: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 57915, offset 0, flags [none], proto UDP (17), length 60)
    asusux.34400 > ldhpux.immt.pwr.wroc.pl.33436: UDP, length 32

10:35:41.308726 IP (tos 0x0, ttl 251, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    chello062179003242.chello.pl > asusux: ICMP time exceeded in-transit, length 36
        IP (tos 0x0, ttl 1, id 57916, offset 0, flags [none], proto UDP (17), length 60)
    asusux.59303 > ldhpux.immt.pwr.wroc.pl.33437: UDP, length 32

mtr

Wynik:

HOST: asusux                      Loss%   Snt   Last   Avg  Best  Wrst StDev
  1.|-- _gateway                   0.0%     1    5.6   5.6   5.6   5.6   0.0
  2.|-- 10.150.128.1               0.0%     1   11.5  11.5  11.5  11.5   0.0
  3.|-- 89-75-10-177.infra.chello  0.0%     1   10.8  10.8  10.8  10.8   0.0
  4.|-- chello062179003242.chello  0.0%     1   13.7  13.7  13.7  13.7   0.0
  5.|-- 156.17.250.215             0.0%     1    9.5   9.5   9.5   9.5   0.0
  6.|-- centrum-rtr-karkonosz.was  0.0%     1    9.2   9.2   9.2   9.2   0.0
  7.|-- z-wask2-do-pwr2.pwrnet.pw  0.0%     1   10.5  10.5  10.5  10.5   0.0
  8.|-- 156.17.33.1                0.0%     1   10.2  10.2  10.2  10.2   0.0
  9.|-- ldhpux.immt.pwr.wroc.pl    0.0%     1    9.6   9.6   9.6   9.6   0.0

MTR wysyła na przemian „zwykły” pakiet ping i pakiet o zwiększającym się o 1 czasie życia

Dane zebrane przez tcpdump

tcpdump: listening on wlp1s0, link-type EN10MB (Ethernet), capture size 262144 bytes
11:01:34.510584 IP (tos 0x0, ttl 1, id 36217, offset 0, flags [none], proto ICMP (1), length 64)
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33000, length 44
11:01:34.516019 IP (tos 0x0, ttl 64, id 1999, offset 0, flags [none], proto ICMP (1), length 56)
    
    _gateway > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36217, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33000, length 44
11:01:34.610646 IP (tos 0x0, ttl 2, id 36227, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33001, length 44
11:01:34.622024 IP (tos 0x0, ttl 254, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    
    10.150.128.1 > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36227, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33001, length 44
11:01:34.710838 IP (tos 0x0, ttl 3, id 36242, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33002, length 44
11:01:34.721429 IP (tos 0x0, ttl 253, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    
    89-75-10-177.infra.chello.pl > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36242, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33002, length 44
11:01:34.810989 IP (tos 0x0, ttl 4, id 36248, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33003, length 44
11:01:34.824522 IP (tos 0x0, ttl 251, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    
    chello062179003242.chello.pl > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36248, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33003, length 44
11:01:34.911228 IP (tos 0x0, ttl 5, id 36253, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33004, length 44
11:01:34.920528 IP (tos 0x0, ttl 250, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    
    156.17.250.215 > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36253, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33004, length 44
11:01:35.011564 IP (tos 0x0, ttl 6, id 36274, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33005, length 44
11:01:35.020619 IP (tos 0x0, ttl 250, id 0, offset 0, flags [none], proto ICMP (1), length 56)
    
    centrum-rtr-karkonosz.wask.wroc.pl > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36274, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33005, length 44
11:01:35.111685 IP (tos 0x0, ttl 7, id 36290, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33006, length 44
11:01:35.121994 IP (tos 0x0, ttl 249, id 62999, offset 0, flags [none], proto ICMP (1), length 56)
    
    z-wask2-do-pwr2.pwrnet.pwr.wroc.pl > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36290, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33006, length 44
11:01:35.212161 IP (tos 0x0, ttl 8, id 36292, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33007, length 44
11:01:35.222110 IP (tos 0x0, ttl 249, id 23060, offset 0, flags [none], proto ICMP (1), length 56)
    
    156.17.33.1 > asusux: ICMP time exceeded in-transit, length 36
	IP (tos 0x0, ttl 1, id 36292, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33007, length 44
11:01:35.312489 IP (tos 0x0, ttl 9, id 36302, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33008, length 44
11:01:35.321943 IP (tos 0x0, ttl 57, id 44729, offset 0, flags [none], proto ICMP (1), length 64)
    
    ldhpux.immt.pwr.wroc.pl > asusux: ICMP echo reply, id 37544, seq 33008, length 44
11:01:35.412881 IP (tos 0x0, ttl 10, id 36309, offset 0, flags [none], proto ICMP (1), length 64)
    
    asusux > ldhpux.immt.pwr.wroc.pl: ICMP echo request, id 37544, seq 33009, length 44
11:01:35.421685 IP (tos 0x0, ttl 57, id 44730, offset 0, flags [none], proto ICMP (1), length 64)
    
    ldhpux.immt.pwr.wroc.pl > asusux: ICMP echo reply, id 37544, seq 33009, length 44
^C
20 packets captured

W powyższym należy zwrócić uwagę na zwiększający się parametr TTL pakietów wysyłanych (te odbierane maj a zazwyczaj większe wartości, ale ponieważ wysyłane są z coraz „odleglejszych” węzłów — tam wartości się zmniejszają).

Pakiety UDP (nslookup)

  1. O protokole UDP będzie mowa na wykładzie

  2. Teraz warto tylko popatrzeć jak działa jedna z usług używająca tego protokołu: nslookoup (Name Service Lookup)

    • znając nazwę komputera możemy dostać adres numeryczny
    • znając adres numeryczny — dostajemy nazwę

    Nazywa się to „rozwiązywaniem nazw”.

host www.pw.edu.pl
www.pw.edu.pl is an alias for www-virt6.ci.pw.edu.pl.
www-virt6.ci.pw.edu.pl has address 194.29.151.9

(nie korzystam z programu nslookup, tylko prostszego host)

Odpowiedź tcpdump

11:23:52.696958 IP asusux.39246 > pl-war-dns02.chello.pl.domain: 13377+ A? www.pw.edu.pl. (31)
11:23:52.722929 IP pl-war-dns02.chello.pl.domain > asusux.36867: 34543 1/0/1 PTR pl-war-dns02.chello.pl. (89)
11:23:52.722930 IP pl-war-dns02.chello.pl.domain > asusux.39246: 13377 2/0/0 CNAME www-virt6.ci.pw.edu.pl., A 194.29.151.9 (74)

I jeszcze

host 156.17.8.1

i odpowiedź tcpdump

11:25:55.932289 IP asusux.32980 > pl-war-dns02.chello.pl.domain: 22783+ PTR? 1.8.17.156.in-addr.arpa. (41)
11:25:56.002376 IP pl-war-dns02.chello.pl.domain > asusux.32980: 22783 1/0/0 PTR ldhpux.immt.pwr.wroc.pl. (78)

Nieszyfrowane połączenie ze stroną WWW

  • To zadanie najlepiej jest wykonywać na komputerze, który nie korzysta z sieci (o co jest bardzo trudno).
  • Nie korzystam z przeglądarki WWW, bo one zazwyczaj prowadzą bardzo intensywne żucie sieciowe.
  • Używam prostego programu do ściągania zawartości stron WWW na dysk.
wget http://temisto.immt.pwr.wroc.pl

Zanim przejdziemy do wymiany pakietów kilka dodatkowych informacji na temat symboli po Flags (w nawiasach kwadratowych)

  • S — informacja o chęci nawiązania połączenia
  • . (kropka)
    • w pakiecie ack potwierdzenie i zgoda
    • w innym potwierdzenie
  • P — pakiet z danymi
  • F — informacja o chęci zakończenia sesji

Odpowiedź tcpdump

11:47:02.308215 IP asusux.54408 > temisto.http: Flags [S], seq 4090288363, win 64240, options [mss 1460,sackOK,TS val 1383357383 ecr 0,nop,wscale 7], length 0

11:47:02.316142 IP temisto.http > asusux.54408: Flags [S.], seq 1197007796, ack 4090288364, win 28960, options [mss 1380,sackOK,TS val 1623938242 ecr 1383357383,nop,wscale 7], length 0

11:47:02.316204 IP asusux.54408 > temisto.http: Flags [.], ack 1, win 502, options [nop,nop,TS val 1383357391 ecr 1623938242], length 0

To było nawiązanie połączenia. Teraz zapytanie

11:47:02.316370 IP asusux.54408 > temisto.http: Flags [P.], seq 1:152, ack 1, win 502, options [nop,nop,TS val 1383357392 ecr 1623938242], length 151: HTTP: GET / HTTP/1.1

11:47:02.326364 IP temisto.http > asusux.54408: Flags [.], ack 152, win 235, options [nop,nop,TS val 1623938245 ecr 1383357392], length 0

temisto potwierdza odebranie pakietu i przysyła odpowiedź

11:47:02.327009 IP temisto.http > asusux.54408: Flags [P.], seq 1:417, ack 152, win 235, options [nop,nop,TS val 1623938245 ecr 1383357392], length 416: HTTP: HTTP/1.1 200 OK

11:47:02.327057 IP asusux.54408 > temisto.http: Flags [.], ack 417, win 499, options [nop,nop,TS val 1383357402 ecr 1623938245], length 0

asusux potwierdza odebranie informacji i zamyka sesję

11:47:02.329091 IP asusux.54408 > temisto.http: Flags [F.], seq 152, ack 417, win 501, options [nop,nop,TS val 1383357404 ecr 1623938245], length 0

11:47:02.338999 IP temisto.http > asusux.54408: Flags [F.], seq 417, ack 153, win 235, options [nop,nop,TS val 1623938247 ecr 1383357404], length 0

11:47:02.339038 IP asusux.54408 > temisto.http: Flags [.], ack 418, win 501, options [nop,nop,TS val 1383357414 ecr 1623938247], length 0

Szyfrowane połączenie ze stroną WWW

Użyjemy polecenia

wget https://temisto.immt.pwr.wroc.pl/

Program tcpdump nasłuchuje nie na porcie 80 tylko 443

sudo tcpdump port 443

I odpowiedź

12:04:11.362596 IP asusux.41014 > temisto.https: Flags [S], seq 2120569497, win 64240, options [mss 1460,sackOK,TS val 1384386438 ecr 0,nop,wscale 7], length 0

12:04:11.371467 IP temisto.https > asusux.41014: Flags [S.], seq 650623595, ack 2120569498, win 28960, options [mss 1380,sackOK,TS val 1624195506 ecr 1384386438,nop,wscale 7], length 0

12:04:11.371550 IP asusux.41014 > temisto.https: Flags [.], ack 1, win 502, options [nop,nop,TS val 1384386447 ecr 1624195506], length 0

Pierwsze trzy pakiety prawie identyczne jak poprzednio, ale zapytanie wygląda inaczej: nie widać żądnej treści i wymiana pakietów danych trwa dłużej

12:04:11.372858 IP asusux.41014 > temisto.https: Flags [P.], seq 1:405, ack 1, win 502, options [nop,nop,TS val 1384386448 ecr 1624195506], length 404

12:04:11.380830 IP temisto.https > asusux.41014: Flags [.], ack 405, win 235, options [nop,nop,TS val 1624195508 ecr 1384386448], length 0

12:04:11.388293 IP temisto.https > asusux.41014: Flags [.], seq 1:2737, ack 405, win 235, options [nop,nop,TS val 1624195510 ecr 1384386448], length 2736

12:04:11.388353 IP asusux.41014 > temisto.https: Flags [.], ack 2737, win 481, options [nop,nop,TS val 1384386464 ecr 1624195510], length 0

12:04:11.389098 IP temisto.https > asusux.41014: Flags [P.], seq 2737:2905, ack 405, win 235, options [nop,nop,TS val 1624195510 ecr 1384386448], length 168

12:04:11.389140 IP asusux.41014 > temisto.https: Flags [.], ack 2905, win 480, options [nop,nop,TS val 1384386464 ecr 1624195510], length 0

12:04:11.391134 IP asusux.41014 > temisto.https: Flags [P.], seq 405:531, ack 2905, win 501, options [nop,nop,TS val 1384386466 ecr 1624195510], length 126

12:04:11.401064 IP temisto.https > asusux.41014: Flags [P.], seq 2905:3195, ack 531, win 235, options [nop,nop,TS val 1624195513 ecr 1384386466], length 290

12:04:11.401106 IP asusux.41014 > temisto.https: Flags [.], ack 3195, win 499, options [nop,nop,TS val 1384386476 ecr 1624195513], length 0

12:04:11.401539 IP asusux.41014 > temisto.https: Flags [P.], seq 531:711, ack 3195, win 501, options [nop,nop,TS val 1384386477 ecr 1624195513], length 180

12:04:11.409080 IP temisto.https > asusux.41014: Flags [P.], seq 3195:3669, ack 711, win 243, options [nop,nop,TS val 1624195515 ecr 1384386477], length 474

12:04:11.409137 IP asusux.41014 > temisto.https: Flags [.], ack 3669, win 498, options [nop,nop,TS val 1384386484 ecr 1624195515], length 0

Tu (wreszcie) zamknięcie połączenia

12:04:11.412132 IP asusux.41014 > temisto.https: Flags [F.], seq 711, ack 3669, win 501, options [nop,nop,TS val 1384386487 ecr 1624195515], length 0

12:04:11.421071 IP temisto.https > asusux.41014: Flags [F.], seq 3669, ack 712, win 243, options [nop,nop,TS val 1624195518 ecr 1384386487], length 0

12:04:11.421132 IP asusux.41014 > temisto.https: Flags [.], ack 3670, win 501, options [nop,nop,TS val 1384386496 ecr 1624195518], length 0

Inspekcja danych w pakietach

Gdybyśmy chcieli zajrzeć do wnętrza pakietów, trzeba użyć polecenia (-v znaczy verbose)

sudo tcpdum -v port 80

(zadziała to tylko w przypadku połączenia nieszyfrowanego)

Pierwsze trzy pakiety tak samo

12:26:04.793229 IP (tos 0x0, ttl 64, id 33362, offset 0, flags [DF], proto TCP (6), length 60)
    asusux.54548 > temisto.http: Flags [S], cksum 0x8f2e (correct), seq 2951505262, win 64240, options [mss 1460,sackOK,TS val 1385699868 ecr 0,nop,wscale 7], length 0
12:26:04.805204 IP (tos 0x0, ttl 57, id 0, offset 0, flags [DF], proto TCP (6), length 60)
    temisto.http > asusux.54548: Flags [S.], cksum 0x5282 (correct), seq 3433125101, ack 2951505263, win 28960, options [mss 1380,sackOK,TS val 1624523864 ecr 1385699868,nop,wscale 7], length 0
12:26:04.805294 IP (tos 0x0, ttl 64, id 33363, offset 0, flags [DF], proto TCP (6), length 52)
    asusux.54548 > temisto.http: Flags [.], cksum 0xf01c (correct), ack 1, win 502, options [nop,nop,TS val 1385699880 ecr 1624523864], length 0

Zwiększona liczba danych związanych z przesyłaniem zawartości spowodowana jest czynnościami, które wymagane są podczas procesu szyfrowania: wymiana kluczy.

Kolejne to zapytanie HTTP

12:26:04.805538 IP (tos 0x0, ttl 64, id 33364, offset 0, flags [DF], proto TCP (6), length 203)
    asusux.54548 > temisto.http: Flags [P.], cksum 0x6ecc (correct), seq 1:152, ack 1, win 502, options [nop,nop,TS val 1385699881 ecr 1624523864], length 151: HTTP, length: 151
	GET / HTTP/1.1
	User-Agent: Wget/1.20.3 (linux-gnu)
	Accept: */*
	Accept-Encoding: identity
	Host: temisto.immt.pwr.wroc.pl
	Connection: Keep-Alive
	
12:26:04.815743 IP (tos 0x0, ttl 57, id 18534, offset 0, flags [DF], proto TCP (6), length 52)
    temisto.http > asusux.54548: Flags [.], cksum 0xf08b (correct), ack 152, win 235, options [nop,nop,TS val 1624523868 ecr 1385699881], length 0
12:26:04.816387 IP (tos 0x0, ttl 57, id 18535, offset 0, flags [DF], proto TCP (6), length 468)
    temisto.http > asusux.54548: Flags [P.], cksum 0x9734 (correct), seq 1:417, ack 152, win 235, options [nop,nop,TS val 1624523868 ecr 1385699881], length 416: HTTP, length: 416
	HTTP/1.1 200 OK
	Date: Sun, 07 Mar 2021 11:26:04 GMT
	Server: Apache/2.4.7 (Ubuntu)
	Last-Modified: Tue, 09 Aug 2016 13:27:53 GMT
	ETag: "60-539a37ff88840"
	Accept-Ranges: bytes
	Content-Length: 96
	Vary: Accept-Encoding
	Keep-Alive: timeout=5, max=100
	Connection: Keep-Alive
	Content-Type: text/html; charset=UTF-8
	
	<h1>
	Przerwa techniczna
	<br>
	Maintenance
	</h1>
	
	<a href="https://e.immt.pwr.wroc.pl">Poczta</a>
12:26:04.816436 IP (tos 0x0, ttl 64, id 33365, offset 0, flags [DF], proto TCP (6), length 52)
    asusux.54548 > temisto.http: Flags [.], cksum 0xedd8 (correct), ack 417, win 499, options [nop,nop,TS val 1385699892 ecr 1624523868], length 0	

I ostatnie trzy pakiety zamykające połączenie

12:26:04.819015 IP (tos 0x0, ttl 64, id 33366, offset 0, flags [DF], proto TCP (6), length 52)
    asusux.54548 > temisto.http: Flags [F.], cksum 0xedd3 (correct), seq 152, ack 417, win 501, options [nop,nop,TS val 1385699894 ecr 1624523868], length 0
12:26:04.831250 IP (tos 0x0, ttl 57, id 18536, offset 0, flags [DF], proto TCP (6), length 52)
    temisto.http > asusux.54548: Flags [F.], cksum 0xeed9 (correct), seq 417, ack 153, win 235, options [nop,nop,TS val 1624523871 ecr 1385699894], length 0
12:26:04.831329 IP (tos 0x0, ttl 64, id 33367, offset 0, flags [DF], proto TCP (6), length 52)
    asusux.54548 > temisto.http: Flags [.], cksum 0xedc2 (correct), ack 418, win 501, options [nop,nop,TS val 1385699907 ecr 1624523871], length 0

Zapytanie HTTPS

Zajrzymy teraz do wnętrza przesyłanych pakietów pakietów:

Polecenie tcpdump pozwalające na to:

sudo tcpdump -nvXSs 100 src 192.168.1.174 and dst port 80 or src port 80

Tym razem tylko jeden pakiet

  1. HTTP

    0:00:22.682785 IP (tos 0x0, ttl 64, id 14432, offset 0, flags [DF], proto TCP (6), length 139)
        192.168.1.174.50454 &gt; 35.232.111.17.80: Flags [P.], seq 1779109549:1779109636, ack 3172692635, win 502, options [nop,nop,TS val 2253686267 ecr 1277045758], length 87: HTTP, length: 87
    	GET / HTTP/1.1
    	Host: connectivity[!http]
    	0x0000:  4500 008b 3860 4000 4006 acbd c0a8 01ae  E...8`@.@.......
    	0x0010:  23e8 6f11 c516 0050 6a0b 0ead bd1b 729b  #.o....Pj.....r.
    	0x0020:  8018 01f6 6b8e 0000 0101 080a 8654 85fb  ....k........T..
    	0x0030:  4c1e 2bfe 4745 5420 2f20 4854 5450 2f31  L.+.GET./.HTTP/1
    	0x0040:  2e31 0d0a 486f 7374 3a20 636f 6e6e 6563  .1..Host:.connec
    	0x0050:  7469 7669 7479                           tivity
    
  2. HTTPS

    20:00:54.215930 IP (tos 0x0, ttl 57, id 20347, offset 0, flags [DF], proto TCP (6), length 1420)
        156.17.8.5.443 > 192.168.1.174.41210: Flags [.], seq 1974306042:1974307410, ack 1530574748, win 235, options [nop,nop,TS val 1631346249 ecr 1386932936], length 1368
    	0x0000:  4500 058c 4f7b 4000 3906 8684 9c11 0805  E...O{@.9.......
    	0x0010:  c0a8 01ae 01bb a0fa 75ad 84fa 5b3a b79c  ........u...[:..
    	0x0020:  8010 00eb 0e0f 0000 0101 080a 613c 5e49  ............a<^I
    	0x0030:  52aa eac8 1603 0300 4102 0000 3d03 032e  R.......A...=...
    	0x0040:  2744 0fa4 4a88 9cf6 6595 aaa7 6ee7 de78  'D..J...e...n..x
    	0x0050:  1a19 fa56 eb3d                           ...V.=
    

Formularze i hasła

  1. Bardzo często wypełniamy w przeglądarce jakieś formularze (przekazując istotne informacje).

  2. Warto zadbać, żeby w takim przypadku połączenie ze stroną było szyfrowane, gdyż istnieją spore szanse, że ktoś będzie je mógł odczytać…

  3. Dziś już chyba nie ma stron wystawiających formularze na stronach nieszyfrowanych… Ale…

  4. Przygotowałem odpowiednią stronę pod adresem http://temisto.immt.pwr.wroc.pl/~myszka/auth/

  5. Uruchamiamy program tcpdump

    tcpdump port http or port ftp or port smtp or port imap or \
    port pop3 -l -A | \
    egrep -i 'pass=|pwd=|log=|login=|user=|username=|pw=\
    |passw=|passwd=|password=|pass:|user:|username:|\
    password:|login:|pass |user '\
    --color=auto --line-buffered -B20
    

    Efekt będzie taki:

    20:11:47.941340 IP asusux.54794 > temisto.http: Flags [P.], seq 1:716, ack 1, win 502, options [nop,nop,TS val 1387586677 ecr 1631509681], length 715: HTTP: POST /~myszka/auth/action.php HTTP/1.1
    E.....@.@............
    .PI..s.$^.....A......
    R..ua>..POST /~myszka/auth/action.php HTTP/1.1
    Host: temisto.immt.pwr.wroc.pl
    Connection: keep-alive
    Content-Length: 26
    Cache-Control: max-age=0
    Origin: http://temisto.immt.pwr.wroc.pl
    Upgrade-Insecure-Requests: 1
    DNT: 1
    Content-Type: application/x-www-form-urlencoded
    User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.82 Safari/537.36
    Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    Referer: http://temisto.immt.pwr.wroc.pl/~myszka/auth/
    Accept-Encoding: gzip, deflate
    Accept-Language: pl-PL,pl;q=0.9,en-US;q=0.8,en;q=0.7
    sec-gpc: 1
    
    user=Mickey&password=Mouse
    
Poprzedni
Następny