Systém pre automatický záznam incidentov zachytil približne hodinu sieťovej prevádzky pochádzajúcej z IP rozsahu AI-CSIRT. Mám analyzovať, či sú tu nejaké incidenty a zahlásiť ich cez AI-CSIRT webové rozhranie na http://incident-report.csirt.ai.tcc/
tip: IP rozsahy pre AI-CSIRT sú 10.99.224.0/24 a 2001:db8:7cc::a1:0/112.
Po stiahnutí a rozbalení záznamu dostanem 326MB veľký PCAP súbor, čo vie dať časovo pri spracovaní zabrať.
Snažím sa robiť všetko cez vzdialené ssh prihlásenie, preto miesto klasického GUI Wireshark použijem command line utilitu Tshark.
Šlo by tiež použiť Snort, avšak pri poslednej verzii som mal problém s tým, že veľa pravidiel na internete funguje iba na staršej verzii a mám problém ako nastaviť premennú pre domácu sieť v prípade analýzy pcap súboru.
Ako prvé si spravím prehľad štatistikou protokolov:
$ tshark -nr incident_reporting.pcap -qz io,phs
===================================================================
Protocol Hierarchy Statistics
eth frames:458595 bytes:311177761
ipv6 frames:457566 bytes:311021679
icmpv6 frames:140728 bytes:12075704
tcp frames:316837 bytes:298945873
http frames:119008 bytes:84528801
data-text-lines frames:59145 bytes:72417495
tcp.segments frames:12971 bytes:35533530
media frames:2 bytes:2854
tcp.segments frames:2 bytes:2854
urlencoded-form frames:1225 bytes:344553
udp frames:1 bytes:102
mdns frames:1 bytes:102
arp frames:568 bytes:23856
ip frames:461 bytes:132226
tcp frames:461 bytes:132226
http frames:45 bytes:102562
data-text-lines frames:22 bytes:96536
===================================================================
parametre:
-n - neprekladať DNS, výrazne zrýchli spracovanie
-r - čítať pcap súbor [názov]
-q - nevypisuj jednotlivé pakety, vhodné pre štatistiku
-z - štatistika, s parametrom help zobrazí možnosti
Hore je časť IPv6, až 457tis. paketov, dole je IP (v4), iba 461 paketov.
Ako je vidieť, v IPv6 máme ICMPv6, 140tis, zaujímavé, inak je všetko HTTP TCP. ICMP sa používa pri problémoch s doručením na sieti, pre začiatok ho odignorujem.
1. Enumerácia
Sústredím sa na TCP a konkrétne HTTP, skúsim štatistiku:
$ tshark -nr incident_reporting.pcap -qz http,stat
==========================================================
HTTP Statistics
* HTTP Response Status Codes Packets
301 Moved Permanently 1
200 OK 13031
403 Forbidden 1
404 Not Found 46136
* HTTP Request Methods Packets
GET 58659
POST 1225
==========================================================
$ tshark -nr incident_reporting.pcap -qz http_req,tree
$ tshark -nr incident_reporting.pcap -Y http -t ud | more
...
19332 2024-09-26 08:48:18.649547 2001:db8:7cc::a1:210 HTTP 212 2001:db8:7cc::acdc:24:a160 GET /randomfile1 HTTP/1.1
19335 2024-09-26 08:48:18.649676 2001:db8:7cc::acdc:24:a160 HTTP 796 2001:db8:7cc::a1:210 HTTP/1.1 404 Not Found (text/html)
19338 2024-09-26 08:48:18.650443 2001:db8:7cc::a1:210 HTTP 207 2001:db8:7cc::acdc:24:a160 GET /frand2 HTTP/1.1
19339 2024-09-26 08:48:18.650558 2001:db8:7cc::acdc:24:a160 HTTP 796 2001:db8:7cc::a1:210 HTTP/1.1 404 Not Found (text/html)
t - formát času, "u" je pre UTC a "d" je s dátumom (bežne bez dátumu, resp miesto UTC je to iba čas od začiatku záznamu v sekundách)
$ tshark -nr incident_reporting.pcap -Y http -t ud | grep \ 404\ | tail -3
165729 2024-09-26 08:49:45.147220 2001:db8:7cc::acdc:24:a160 HTTP 796 2001:db8:7cc::a1:210 HTTP/1.1 404 Not Found
165732 2024-09-26 08:49:45.149390 2001:db8:7cc::acdc:24:a160 HTTP 796 2001:db8:7cc::a1:210 HTTP/1.1 404 Not Found
165735 2024-09-26 08:49:45.151223 2001:db8:7cc::acdc:24:a160 HTTP 796 2001:db8:7cc::a1:210 HTTP/1.1 404 Not Found
$ tshark -nr incident_reporting.pcap -Y http | grep a1:210\ | grep 24:a160\ | grep \ GET\ | wc -l
46142
- Web service enumeration
- Offending IP: 2001:db8:7cc::a1:210
Target IP: 2001:db8:7cc::acdc:24:a160
First UTC: 2024-09-26 08:48:18
Last UTC: 2024-09-26 08:49:45 - Number of enumerated URL: 10000-49999
$ echo "NC80OiBkNWtNfQ==" | base64 -d
4/4: d5kM}
2. Brute force
$ tshark -nr incident_reporting.pcap -Y http -t ud | awk '{ print $3" "$8" "$9 }' | grep -v HTTP > http_req.txt
$ grep \/login$ http_req.txt |head -5
08:48:40.560969 GET /login
08:49:23.917282 GET /TEMP/login
08:55:20.250840 GET /login
08:55:20.250952 GET /login
08:55:20.251098 GET /login
$ grep \/login$ http_req.txt |tail -3
08:55:43.259406 POST /login
08:55:43.259506 POST /login
08:55:43.332428 POST /login
$ grep \/login$ http_req.txt |wc -l
2452
$ tshark -nr incident_reporting.pcap -Y http -t ud | grep acdc:24:beef
...
225899 2024-09-26 08:55:43.263261 2001:db8:7cc::acdc:24:beef HTTP 2157 2001:db8:7cc::a1:210 HTTP/1.1 200 OK (text/html)
225910 2024-09-26 08:55:43.275794 2001:db8:7cc::acdc:24:beef HTTP 2732 2001:db8:7cc::a1:210 HTTP/1.1 200 OK (text/html)
225934 2024-09-26 08:55:43.332428 2001:db8:7cc::a1:210 HTTP 282 2001:db8:7cc::acdc:24:beef POST /login HTTP/1.0 (application/x-www-form-urlencoded)
225940 2024-09-26 08:55:43.337605 2001:db8:7cc::acdc:24:beef HTTP 2157 2001:db8:7cc::a1:210 HTTP/1.1 200 OK (text/html)
- Brute force attack
- Offending IP: 2001:db8:7cc::a1:210
Target IP: 2001:db8:7cc::acdc:24:beef
First UTC: 2024-09-26 08:55:20
Last UTC: 2024-09-26 08:55:43 - Number of attempts: 1000-4999
Result: success
$ echo "MS80OiBGTEFHe2xFOA==" | base64 -d
1/4: FLAG{lE8
3. DOS
$ grep check_status http_req.txt | head -4
08:58:49.834150 GET /check_status.php
08:59:09.874637 GET /check_status.php
08:59:09.874696 GET /check_status.php
08:59:09.874714 GET /check_status.php
$ grep check_status http_req.txt | tail -3
09:46:43.578017 GET /check_status.php
09:46:43.768747 GET /check_status.php
09:46:44.171255 GET /check_status.php
$ tshark -nr incident_reporting.pcap -Y http -t ud | grep -A5 08:59:09.874637
242120 2024-09-26 08:59:09.874637 2001:db8:7cc::a1:d055 HTTP 144 2001:db8:7cc::acdc:24:911 GET /check_status.php HTTP/1.1
242122 2024-09-26 08:59:09.874696 2001:db8:7cc::a1:d055 HTTP 144 2001:db8:7cc::acdc:24:911 GET /check_status.php HTTP/1.1
242124 2024-09-26 08:59:09.874714 2001:db8:7cc::a1:d055 HTTP 144 2001:db8:7cc::acdc:24:911 GET /check_status.php HTTP/1.1
242126 2024-09-26 08:59:09.874728 2001:db8:7cc::a1:d055 HTTP 144 2001:db8:7cc::acdc:24:911 GET /check_status.php HTTP/1.1
242128 2024-09-26 08:59:09.874741 2001:db8:7cc::a1:d055 HTTP 144 2001:db8:7cc::acdc:24:911 GET /check_status.php HTTP/1.1
242130 2024-09-26 08:59:09.874755 2001:db8:7cc::a1:d055 HTTP 144 2001:db8:7cc::acdc:24:911 GET /check_status.php HTTP/1.1
- (D)DOS
- Offending IP: 2001:db8:7cc::a1:d055
Target IP: 2001:db8:7cc::acdc:24:911
First UTC: 2024-09-26 08:59:09
Last UTC: 2024-09-26 09:46:44 - Affected protocol: HTTP
$ echo "Mi80OiBzLVVrb3g=" | base64 -d
2/4: s-Ukox
4. Scan
$ tshark -nr incident_reporting.pcap -qz help
4.1 ARP pakety (slepá cesta)
$ tshark -nr incident_reporting.pcap -Y arp -t ud > arp_all.txt
$ cat arp_all.txt | awk '{ print $4" "$7 }' | sort | uniq -c
201 02:42:0a:63:00:0d 02:42:0a:63:e0:d2
3 02:42:0a:63:00:0d 02:42:0a:63:e0:f0
2 02:42:0a:63:7c:c7 02:42:0a:63:e0:f0
64 02:42:0a:63:7c:c7 02:42:ac:11:02:20
200 02:42:0a:63:e0:d2 02:42:0a:63:00:0d
1 02:42:0a:63:e0:d2 ff:ff:ff:ff:ff:ff
2 02:42:0a:63:e0:f0 02:42:0a:63:00:0d
1 02:42:0a:63:e0:f0 02:42:0a:63:7c:c7
2 02:42:0a:63:e0:f0 ff:ff:ff:ff:ff:ff
63 02:42:ac:11:02:20 02:42:0a:63:7c:c7
13 02:42:ac:11:02:20 02:42:df:6c:c1:39
2 02:42:ac:11:02:20 ff:ff:ff:ff:ff:ff
14 02:42:df:6c:c1:39 02:42:ac:11:02:20
$ grep Who arp_all.txt | awk '{ print $4" "$7" "$10" "$12 }' | sort | uniq -c
97 02:42:0a:63:00:0d 02:42:0a:63:e0:d2 10.99.224.210? 10.99.0.13
1 02:42:0a:63:00:0d 02:42:0a:63:e0:f0 10.99.224.240? 10.99.0.13
1 02:42:0a:63:7c:c7 02:42:0a:63:e0:f0 10.99.224.240? 10.99.124.199
2 02:42:0a:63:7c:c7 02:42:ac:11:02:20 10.99.224.220? 10.99.124.199
103 02:42:0a:63:e0:d2 02:42:0a:63:00:0d 10.99.0.13? 10.99.224.210
1 02:42:0a:63:e0:d2 ff:ff:ff:ff:ff:ff 10.99.0.13? 10.99.224.210
1 02:42:0a:63:e0:f0 02:42:0a:63:00:0d 10.99.0.13? 10.99.224.240
1 02:42:0a:63:e0:f0 ff:ff:ff:ff:ff:ff 10.99.0.13? 10.99.224.240
1 02:42:0a:63:e0:f0 ff:ff:ff:ff:ff:ff 10.99.124.199? 10.99.224.240
61 02:42:ac:11:02:20 02:42:0a:63:7c:c7 10.99.124.199? 10.99.224.220
13 02:42:ac:11:02:20 02:42:df:6c:c1:39 10.99.0.1? 10.99.224.220
1 02:42:ac:11:02:20 ff:ff:ff:ff:ff:ff 10.99.0.1? 10.99.224.220
1 02:42:ac:11:02:20 ff:ff:ff:ff:ff:ff 10.99.124.199? 10.99.224.220
4.2 ICMP pakety (lepšie, stále nie všetko)
$ tshark -nr incident_reporting.pcap -Y icmpv6 |grep -v Solicitation | awk '{ print $3 }' | sort | uniq -c | sort -n | tail -5
51 fe80::42:acff:fe11:222
52 fe80::42:acff:fe11:221
105 fe80::42:aff:fe63:7cc7
149 2001:db8:7cc::acdc:24:911
1811 2001:db8:7cc::1
$ tshark -nr incident_reporting.pcap -Y icmpv6 -t ud > icmp_scan.txt
$ grep 2001:db8:7cc::a1:42 icmp_scan.txt| grep ff24 | tail -4
363488 2024-09-26 09:16:55.584839 2001:db8:7cc::a1:42 ICMPv6 86 ff02::1:ff24:fdd0 Neighbor Solicitation for 2001:db8:7cc::acdc:24:fdd0 from 02:42:ac:11:02:20
363489 2024-09-26 09:16:55.585038 2001:db8:7cc::a1:42 ICMPv6 86 ff02::1:ff24:fe2a Neighbor Solicitation for 2001:db8:7cc::acdc:24:fe2a from 02:42:ac:11:02:20
363490 2024-09-26 09:16:55.681571 2001:db8:7cc::a1:42 ICMPv6 86 ff02::1:ff24:f017 Neighbor Solicitation for 2001:db8:7cc::acdc:24:f017 from 02:42:ac:11:02:20
363495 2024-09-26 09:16:55.744091 2001:db8:7cc::a1:42 ICMPv6 86 ff02::1:ff24:d Neighbor Solicitation for 2001:db8:7cc::24:d from 02:42:ac:11:02:20
$ grep Advertisement icmp_scan.txt| grep a1:42\ N | wc -l
262
4.3 TCP flags
$ tshark -nr incident_reporting.pcap -Y tcp -t ud -T fields -e tcp.dstport -e ipv6.addr -Y "tcp.dstport < 9000 and tcp.dstport != 80"
...
22 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:6b10
22 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:8170
22 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:e469
22 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:f017
$ tshark -nr incident_reporting.pcap -Y tcp -t ud -T fields -e frame.time_utc -e tcp.dstport -e ipv6.addr -Y "ipv6.src == 2001:db8:7cc::a1:42 and tcp.dstport < 9000" > portscan.txt
$ head -2 portscan.txt
Sep 26, 2024 09:17:08.768528000 UTC 21 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:230
Sep 26, 2024 09:17:08.768914000 UTC 21 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:231
$ tail -2 portscan.txt
Sep 26, 2024 09:17:08.779328000 UTC 22 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:f017
Sep 26, 2024 09:17:09.875883000 UTC 80 2001:db8:7cc::a1:42,2001:db8:7cc::acdc:24:911
$ wc -l portscan.txt
207 portscan.txt
$ cat portscan.txt | awk '{ print $6 }' | sort -n | uniq
21
22
53
80
443
8080
- 20 - URG
- 10 - ACK
- 08 - PSH
- 04 - RST
- 02 - SYN
- 01 - FIN
-> SYN (2)<- SYN,ACK (12)-> ACK (10)
-> SYN (2)<- RST,ACK (14)
$ tshark -nr incident_reporting.pcap -Y tcp -t ud -T fields -e frame.time_utc -e tcp.dstport -e ipv6.addr -e tcp.flags -Y "ipv6.dst == 2001:db8:7cc::a1:42 or ipv6.src == 2001:db8:7cc::a1:42 and tcp.dstport < 9000" > portscan.txt
$ grep 12$ portscan.txt | awk '{ print $6" "$7 }' | sort | uniq | wc -l
25
- Scanning
- Offending IP: 2001:db8:7cc::a1:42
Target scan range: 2001:db8:7cc::acdc:24:0/112 (7skupín = 14bajtov = 112bitov)
First UTC: 2024-09-26 08:44:29 (prvý scan hostov z časti ICMP)
Last UTC: 2024-09-26 09:17:09 (posledný scan portu) - Details - Target ports: 21, 22, 53, 80, 443, 8080
Number of found and scanned targets: 20-99
$ echo "My80OiAtYTBRZi0=" | base64 -d
3/4: -a0Qf-
Žiadne komentáre:
Zverejnenie komentára