Pcap Inspection

学习和实践 AWS 黑客技术:HackTricks 培训 AWS 红队专家 (ARTE) 学习和实践 GCP 黑客技术:HackTricks 培训 GCP 红队专家 (GRTE)

支持 HackTricks

RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的事件之一。该大会的 使命是促进技术知识,是各个学科技术和网络安全专业人士的热烈交流平台。

关于 PCAPPCAPNG 的说明:PCAP 文件格式有两个版本;PCAPNG 是较新的,并不是所有工具都支持。您可能需要使用 Wireshark 或其他兼容工具将文件从 PCAPNG 转换为 PCAP,以便在某些其他工具中使用。

在线工具用于 pcap

提取信息

以下工具用于提取统计信息、文件等。

Wireshark

如果您要分析 PCAP,您基本上必须知道如何使用 Wireshark

您可以在以下位置找到一些 Wireshark 技巧:

Wireshark tricks

浏览器中的 pcap 分析。

Xplico Framework

Xplico (仅限 Linux) 可以 分析 一个 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 一样,它是一个 分析和提取 pcaps 中对象 的工具。它有一个免费版,你可以 在这里下载 这里。它适用于 Windows。 这个工具也有助于从数据包中获取 其他信息分析,以便能够更 快速 地了解发生了什么。

NetWitness Investigator

你可以 从这里下载 NetWitness Investigator (适用于 Windows)。 这是另一个有用的工具,分析数据包 并以有用的方式整理信息,以 了解内部发生的事情

  • 提取和编码用户名和密码 (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

您可以使用像 https://github.com/lgandx/PCredz 这样的工具从pcap或实时接口中解析凭据。

RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的事件之一。该大会 旨在促进技术知识,是各个学科技术和网络安全专业人士的热烈交流平台。

Check Exploits/Malware

Suricata

安装和设置

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 创建的日志不是 pcaps。因此,您需要使用 其他工具 来分析包含 pcaps 信息 的日志。

连接信息

#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 分析技巧

DNSCat pcap analysisWifi Pcap AnalysisUSB Keystrokes

RootedCON西班牙 最相关的网络安全事件,也是 欧洲 最重要的活动之一。该大会 旨在促进技术知识,是各个学科技术和网络安全专业人士的热烈交流平台。

学习和实践 AWS 黑客技术:HackTricks Training AWS Red Team Expert (ARTE) 学习和实践 GCP 黑客技术:HackTricks Training GCP Red Team Expert (GRTE)

支持 HackTricks

Last updated