Executable Atomic Red Team test cases for exercising this technique in a lab. Copy a command, run it on the listed platform, confirm your detections fire.
bashelevatedlinuxPacket Capture Linux using tshark or tcpdump
Perform a PCAP. Wireshark will be required for tshark. TCPdump may already be installed.
Upon successful execution, tshark or tcpdump will execute and capture 5 packets on interface ens33.
tcpdump -c 5 -nnni #{interface}
tshark -c 5 -i #{interface}
shelevatedlinuxPacket Capture FreeBSD using tshark or tcpdump
Perform a PCAP. Wireshark will be required for tshark. TCPdump may already be installed.
Upon successful execution, tshark or tcpdump will execute and capture 5 packets on interface ens33.
tcpdump -c 5 -nnni #{interface}
tshark -c 5 -i #{interface}
bashelevatedmacosPacket Capture macOS using tcpdump or tshark
Perform a PCAP on macOS. This will require Wireshark/tshark to be installed. TCPdump may already be installed.
Upon successful execution, tshark or tcpdump will execute and capture 5 packets on interface en0A.
sudo tcpdump -c 5 -nnni #{interface}
if [ -x "$(command -v tshark)" ]; then sudo tshark -c 5 -i #{interface}; fi;
command_promptelevatedwindowsPacket Capture Windows Command Prompt
Perform a packet capture using the windows command prompt. This will require a host that has Wireshark/Tshark
installed.
Upon successful execution, tshark will execute and capture 5 packets on interface "Ethernet".
"c:\Program Files\Wireshark\tshark.exe" -i #{interface} -c 5
command_promptelevatedwindowsWindows Internal Packet Capture
Uses the built-in Windows packet capture
After execution you should find a file named trace.etl and trace.cab in the temp directory
netsh trace start capture=yes tracefile=%temp%\trace.etl maxsize=10
command_promptelevatedwindowsWindows Internal pktmon capture
Will start a packet capture and store log file as t1040.etl.
https://lolbas-project.github.io/lolbas/Binaries/Pktmon/
pktmon.exe start --etw -f %TEMP%\t1040.etl
TIMEOUT /T 5 >nul 2>&1
pktmon.exe stop
command_promptelevatedwindowsWindows Internal pktmon set filter
Select Desired ports for packet capture
https://lolbas-project.github.io/lolbas/Binaries/Pktmon/
pktmon.exe filter add -p 445
bashelevatedmacosPacket Capture macOS using /dev/bpfN with sudo
Opens a /dev/bpf file (O_RDONLY) and captures packets for a few seconds.
sudo #{program_path} -i #{ifname} -t 3
bashelevatedmacosFiltered Packet Capture macOS using /dev/bpfN with sudo
Opens a /dev/bpf file (O_RDONLY), sets BPF filter for 'udp' and captures packets for a few seconds.
sudo #{program_path} -f -i #{ifname} -t 3
shelevatedlinuxPacket Capture FreeBSD using /dev/bpfN with sudo
Opens a /dev/bpf file (O_RDONLY) and captures packets for a few seconds.
sudo #{program_path} -i #{ifname} -t 3
shelevatedlinuxFiltered Packet Capture FreeBSD using /dev/bpfN with sudo
Opens a /dev/bpf file (O_RDONLY), sets BPF filter for 'udp' and captures packets for a few seconds.
sudo #{program_path} -f -i #{ifname} -t 3
bashelevatedlinuxPacket Capture Linux socket AF_PACKET,SOCK_RAW with sudo
Captures packets with domain=AF_PACKET, type=SOCK_RAW for a few seconds.
sudo #{program_path} -a -t 3
bashelevatedlinuxPacket Capture Linux socket AF_INET,SOCK_RAW,TCP with sudo
Captures packets with domain=AF_INET,type=SOCK_RAW,protocol=TCP for a few seconds.
sudo #{program_path} -4 -p 6 -t 3
bashelevatedlinuxPacket Capture Linux socket AF_INET,SOCK_PACKET,UDP with sudo
Captures packets with domain=AF_INET,type=SOCK_PACKET,protocol=UDP for a few seconds.
SOCK_PACKET is "obsolete" according to the man page, but still works on Ubuntu 20.04
sudo #{program_path} -4 -P -p 17 -t 3
bashelevatedlinuxPacket Capture Linux socket AF_PACKET,SOCK_RAW with BPF filter for UDP with sudo
Captures packets with domain=AF_PACKET,type=SOCK_RAW for a few seconds.
Sets a BPF filter on the socket to filter for UDP traffic.
sudo #{program_path} -a -f -t 3
powershellelevatedwindowsPowerShell Network Sniffing
PowerShell Built-in Cmdlets to capture network traffic.
https://learn.microsoft.com/en-us/powershell/module/neteventpacketcapture/new-neteventsession?view=windowsserver2022-ps
New-NetEventSession -Name Capture007 -LocalFilePath "$ENV:Temp\sniff.etl"
Add-NetEventPacketCaptureProvider -SessionName Capture007 -TruncationLength 100
Start-NetEventSession -Name Capture007
Stop-NetEventSession -Name Capture007
Remove-NetEventSession -Name Capture007