Pcap Inspection
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
Tip
PCAP์ PCAPNG์ ๋ํ ์ฃผ์ ์ฌํญ: PCAP ํ์ผ ํ์์๋ ๋ ๊ฐ์ง ๋ฒ์ ์ด ์์ต๋๋ค; PCAPNG๋ ๋ ์ต์ ์ด๋ฉฐ ๋ชจ๋ ๋๊ตฌ์์ ์ง์๋์ง ์์ต๋๋ค. ๋ค๋ฅธ ๋๊ตฌ์์ ์์ ํ๊ธฐ ์ํด Wireshark ๋๋ ๋ค๋ฅธ ํธํ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ฌ PCAPNG์์ PCAP๋ก ํ์ผ์ ๋ณํํด์ผ ํ ์๋ ์์ต๋๋ค.
pcaps๋ฅผ ์ํ ์จ๋ผ์ธ ๋๊ตฌ
- pcap์ ํค๋๊ฐ ์์๋ ๊ฒฝ์ฐ ๋ค์์ ์ฌ์ฉํ์ฌ ์์ ํด ๋ณด์ญ์์ค: http://f00l.de/hacking/pcapfix.php
- PacketTotal์์ pcap ๋ด๋ถ์ ์ ๋ณด๋ฅผ ์ถ์ถํ๊ณ ์ ์ฑ ์ํํธ์จ์ด๋ฅผ ๊ฒ์ํ์ญ์์ค.
- www.virustotal.com ๋ฐ www.hybrid-analysis.com์์ ์ ์์ ์ธ ํ๋์ ๊ฒ์ํ์ญ์์ค.
- https://apackets.com/์์ ๋ธ๋ผ์ฐ์ ์์ ์ ์ฒด pcap ๋ถ์์ ์ํํ์ญ์์ค.
์ ๋ณด ์ถ์ถ
๋ค์ ๋๊ตฌ๋ ํต๊ณ, ํ์ผ ๋ฑ์ ์ถ์ถํ๋ ๋ฐ ์ ์ฉํฉ๋๋ค.
Wireshark
Tip
PCAP์ ๋ถ์ํ๋ ค๋ฉด ๊ธฐ๋ณธ์ ์ผ๋ก Wireshark๋ฅผ ์ฌ์ฉํ๋ ๋ฐฉ๋ฒ์ ์์์ผ ํฉ๋๋ค.
๋ค์์์ Wireshark ํ์ ์ฐพ์ ์ ์์ต๋๋ค:
https://apackets.com/
๋ธ๋ผ์ฐ์ ์์ pcap ๋ถ์.
Xplico Framework
Xplico _(๋ฆฌ๋ ์ค ์ ์ฉ)_๋ pcap์ ๋ถ์ํ๊ณ ๊ทธ๋ก๋ถํฐ ์ ๋ณด๋ฅผ ์ถ์ถํ ์ ์์ต๋๋ค. ์๋ฅผ ๋ค์ด, pcap ํ์ผ์์ Xplico๋ ๊ฐ ์ด๋ฉ์ผ(POP, IMAP ๋ฐ SMTP ํ๋กํ ์ฝ), ๋ชจ๋ HTTP ์ฝํ ์ธ , ๊ฐ VoIP ํตํ(SIP), FTP, TFTP ๋ฑ์ ์ถ์ถํฉ๋๋ค.
์ค์น
sudo bash -c 'echo "deb http://repo.xplico.org/ $(lsb_release -s -c) main" /etc/apt/sources.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 791C25CE
sudo apt-get update
sudo apt-get install xplico
์คํ
/etc/init.d/apache2 restart
/etc/init.d/xplico start
_127.0.0.1:9876_์ xplico:xplico ์๊ฒฉ ์ฆ๋ช ์ผ๋ก ์ ๊ทผํฉ๋๋ค.
๊ทธ๋ฐ ๋ค์ ์ ์ฌ๋ก๋ฅผ ๋ง๋ค๊ณ , ์ฌ๋ก ๋ด์์ ์ ์ธ์ ์ ์์ฑํ ํ pcap ํ์ผ์ ์ ๋ก๋ํฉ๋๋ค.
NetworkMiner
Xplico์ ๋ง์ฐฌ๊ฐ์ง๋ก pcap์์ ๊ฐ์ฒด๋ฅผ ๋ถ์ํ๊ณ ์ถ์ถํ๋ ๋๊ตฌ์
๋๋ค. ๋ฌด๋ฃ ๋ฒ์ ์ด ์์ผ๋ฉฐ, ์ฌ๊ธฐ์ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค. Windows์์ ์๋ํฉ๋๋ค.
์ด ๋๊ตฌ๋ ํจํท์์ ๋ถ์๋ ๋ค๋ฅธ ์ ๋ณด๋ฅผ ์ป๋ ๋ฐ๋ ์ ์ฉํ์ฌ ๋ ๋น ๋ฅด๊ฒ ๋ฌด์จ ์ผ์ด ์ผ์ด๋๊ณ ์๋์ง ์ ์ ์์ต๋๋ค.
NetWitness Investigator
์ฌ๊ธฐ์ NetWitness Investigator๋ฅผ ๋ค์ด๋ก๋ํ ์ ์์ต๋๋ค (Windows์์ ์๋ํฉ๋๋ค).
์ด๊ฒ์ ํจํท์ ๋ถ์ํ๊ณ ์ ๋ณด๋ฅผ ์ ์ฉํ ๋ฐฉ์์ผ๋ก ์ ๋ฆฌํ์ฌ ๋ด๋ถ์์ ๋ฌด์จ ์ผ์ด ์ผ์ด๋๊ณ ์๋์ง ์ ์ ์๊ฒ ํด์ฃผ๋ ๋ ๋ค๋ฅธ ์ ์ฉํ ๋๊ตฌ์
๋๋ค.
BruteShark
- ์ฌ์ฉ์ ์ด๋ฆ ๋ฐ ๋น๋ฐ๋ฒํธ ์ถ์ถ ๋ฐ ์ธ์ฝ๋ฉ (HTTP, FTP, Telnet, IMAP, SMTPโฆ)
- ์ธ์ฆ ํด์ ์ถ์ถ ๋ฐ Hashcat์ ์ฌ์ฉํ์ฌ ํฌ๋ (Kerberos, NTLM, CRAM-MD5, HTTP-Digestโฆ)
- ์๊ฐ์ ๋คํธ์ํฌ ๋ค์ด์ด๊ทธ๋จ ๊ตฌ์ถ (๋คํธ์ํฌ ๋ ธ๋ ๋ฐ ์ฌ์ฉ์)
- DNS ์ฟผ๋ฆฌ ์ถ์ถ
- ๋ชจ๋ TCP ๋ฐ UDP ์ธ์ ์ฌ๊ตฌ์ฑ
- ํ์ผ ์กฐ๊ฐํ
Capinfos
capinfos capture.pcap
Ngrep
pcap ๋ด์์ ๋ฌด์ธ๊ฐ๋ฅผ ์ฐพ๊ณ ์๋ค๋ฉด ngrep์ ์ฌ์ฉํ ์ ์์ต๋๋ค. ๋ค์์ ์ฃผ์ ํํฐ๋ฅผ ์ฌ์ฉํ๋ ์์ ๋๋ค:
ngrep -I packets.pcap "^GET" "port 80 and tcp and host 192.168 and dst host 192.168 and src host 192.168"
Carving
์ผ๋ฐ์ ์ธ ์นด๋น ๊ธฐ์ ์ ์ฌ์ฉํ๋ฉด pcap์์ ํ์ผ๊ณผ ์ ๋ณด๋ฅผ ์ถ์ถํ๋ ๋ฐ ์ ์ฉํ ์ ์์ต๋๋ค:
File/Data Carving & Recovery Tools
Capturing credentials
pcap ๋๋ ๋ผ์ด๋ธ ์ธํฐํ์ด์ค์์ ์๊ฒฉ ์ฆ๋ช ์ ๊ตฌ๋ฌธ ๋ถ์ํ๊ธฐ ์ํด https://github.com/lgandx/PCredz์ ๊ฐ์ ๋๊ตฌ๋ฅผ ์ฌ์ฉํ ์ ์์ต๋๋ค.
Check Exploits/Malware
Suricata
Install and setup
apt-get install suricata
apt-get install oinkmaster
echo "url = http://rules.emergingthreats.net/open/suricata/emerging.rules.tar.gz" >> /etc/oinkmaster.conf
oinkmaster -C /etc/oinkmaster.conf -o /etc/suricata/rules
pcap ํ์ธ
suricata -r packets.pcap -c /etc/suricata/suricata.yaml -k none -v -l log
YaraPcap
YaraPCAP๋ ๋ค์๊ณผ ๊ฐ์ ๊ธฐ๋ฅ์ ๊ฐ์ง ๋๊ตฌ์ ๋๋ค.
- PCAP ํ์ผ์ ์ฝ๊ณ Http ์คํธ๋ฆผ์ ์ถ์ถํฉ๋๋ค.
- gzip์ผ๋ก ์์ถ๋ ์คํธ๋ฆผ์ ํด์ ํฉ๋๋ค.
- yara๋ก ๋ชจ๋ ํ์ผ์ ์ค์บํฉ๋๋ค.
- report.txt๋ฅผ ์์ฑํฉ๋๋ค.
- ์ ํ์ ์ผ๋ก ์ผ์นํ๋ ํ์ผ์ ๋๋ ํ ๋ฆฌ์ ์ ์ฅํฉ๋๋ค.
Malware Analysis
์๋ ค์ง ์ ์ฑ์ฝ๋์ ์ง๋ฌธ์ ์ฐพ์ ์ ์๋์ง ํ์ธํ์ธ์:
Zeek
Zeek์ ์๋์ ์ด๊ณ ์คํ ์์ค์ธ ๋คํธ์ํฌ ํธ๋ํฝ ๋ถ์๊ธฐ์ ๋๋ค. ๋ง์ ์ด์์๋ค์ด Zeek์ ๋คํธ์ํฌ ๋ณด์ ๋ชจ๋ํฐ(NSM)๋ก ์ฌ์ฉํ์ฌ ์์ฌ์ค๋ฌ์ด ๋๋ ์ ์์ ์ธ ํ๋์ ๋ํ ์กฐ์ฌ๋ฅผ ์ง์ํฉ๋๋ค. Zeek์ ๋ณด์ ๋๋ฉ์ธ์ ๋์ด ์ฑ๋ฅ ์ธก์ ๋ฐ ๋ฌธ์ ํด๊ฒฐ์ ํฌํจํ ๋ค์ํ ํธ๋ํฝ ๋ถ์ ์์ ์ ์ง์ํฉ๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก zeek์ ์ํด ์์ฑ๋ ๋ก๊ทธ๋ pcap์ด ์๋๋๋ค. ๋ฐ๋ผ์ pcap์ ๋ํ ์ ๋ณด๊ฐ ํฌํจ๋ ๋ก๊ทธ๋ฅผ ๋ถ์ํ๊ธฐ ์ํด ๋ค๋ฅธ ๋๊ตฌ๋ฅผ ์ฌ์ฉํด์ผ ํฉ๋๋ค.
Connections Info
#Get info about longest connections (add "grep udp" to see only udp traffic)
#The longest connection might be of malware (constant reverse shell?)
cat conn.log | zeek-cut id.orig_h id.orig_p id.resp_h id.resp_p proto service duration | sort -nrk 7 | head -n 10
10.55.100.100 49778 65.52.108.225 443 tcp - 86222.365445
10.55.100.107 56099 111.221.29.113 443 tcp - 86220.126151
10.55.100.110 60168 40.77.229.82 443 tcp - 86160.119664
#Improve the metrics by summing up the total duration time for connections that have the same destination IP and Port.
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p proto duration | awk 'BEGIN{ FS="\t" } { arr[$1 FS $2 FS $3 FS $4] += $5 } END{ for (key in arr) printf "%s%s%s\n", key, FS, arr[key] }' | sort -nrk 5 | head -n 10
10.55.100.100 65.52.108.225 443 tcp 86222.4
10.55.100.107 111.221.29.113 443 tcp 86220.1
10.55.100.110 40.77.229.82 443 tcp 86160.1
#Get the number of connections summed up per each line
cat conn.log | zeek-cut id.orig_h id.resp_h duration | awk 'BEGIN{ FS="\t" } { arr[$1 FS $2] += $3; count[$1 FS $2] += 1 } END{ for (key in arr) printf "%s%s%s%s%s\n", key, FS, count[key], FS, arr[key] }' | sort -nrk 4 | head -n 10
10.55.100.100 65.52.108.225 1 86222.4
10.55.100.107 111.221.29.113 1 86220.1
10.55.100.110 40.77.229.82 134 86160.1
#Check if any IP is connecting to 1.1.1.1
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p proto service | grep '1.1.1.1' | sort | uniq -c
#Get number of connections per source IP, dest IP and dest Port
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p proto | awk 'BEGIN{ FS="\t" } { arr[$1 FS $2 FS $3 FS $4] += 1 } END{ for (key in arr) printf "%s%s%s\n", key, FS, arr[key] }' | sort -nrk 5 | head -n 10
# RITA
#Something similar can be done with the tool rita
rita show-long-connections -H --limit 10 zeek_logs
+---------------+----------------+--------------------------+----------------+
| SOURCE IP | DESTINATION IP | DSTPORT:PROTOCOL:SERVICE | DURATION |
+---------------+----------------+--------------------------+----------------+
| 10.55.100.100 | 65.52.108.225 | 443:tcp:- | 23h57m2.3655s |
| 10.55.100.107 | 111.221.29.113 | 443:tcp:- | 23h57m0.1262s |
| 10.55.100.110 | 40.77.229.82 | 443:tcp:- | 23h56m0.1197s |
#Get connections info from rita
rita show-beacons zeek_logs | head -n 10
Score,Source IP,Destination IP,Connections,Avg Bytes,Intvl Range,Size Range,Top Intvl,Top Size,Top Intvl Count,Top Size Count,Intvl Skew,Size Skew,Intvl Dispersion,Size Dispersion
1,192.168.88.2,165.227.88.15,108858,197,860,182,1,89,53341,108319,0,0,0,0
1,10.55.100.111,165.227.216.194,20054,92,29,52,1,52,7774,20053,0,0,0,0
0.838,10.55.200.10,205.251.194.64,210,69,29398,4,300,70,109,205,0,0,0,0
DNS ์ ๋ณด
#Get info about each DNS request performed
cat dns.log | zeek-cut -c id.orig_h query qtype_name answers
#Get the number of times each domain was requested and get the top 10
cat dns.log | zeek-cut query | sort | uniq | rev | cut -d '.' -f 1-2 | rev | sort | uniq -c | sort -nr | head -n 10
#Get all the IPs
cat dns.log | zeek-cut id.orig_h query | grep 'example\.com' | cut -f 1 | sort | uniq -c
#Sort the most common DNS record request (should be A)
cat dns.log | zeek-cut qtype_name | sort | uniq -c | sort -nr
#See top DNS domain requested with rita
rita show-exploded-dns -H --limit 10 zeek_logs
๋ค๋ฅธ pcap ๋ถ์ ํ
โ
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


