Operational Security (OPSEC) Knowledge Base
OPSEC ensures the red team engagement remains covert, controlled, and within authorized scope. Poor OPSEC burns the engagement — detected scans alert the blue team, taint findings, and waste client resources. This skill applies across all recon phases.
1. Core OPSEC Principles
The OPSEC Mindset
- Every packet is a signal — assume the target has IDS/IPS, SIEM, and SOC analysts
- Minimize footprint — collect only what you need, no more
- Blend with normal traffic — timing, volume, and patterns should look legitimate
- Know your tools' signatures — every scanner has a fingerprint
- Document everything — if you can't prove it was authorized, it wasn't
Engagement Scope Awareness
Before ANY active operation:
2. Network OPSEC
Scan Rate Limiting
| Target Type |
Recommended Rate |
Timing Flag |
| Production web server |
5-10 req/sec |
nmap -T2 |
| Internal network |
50-100 req/sec |
nmap -T3 |
| Development/staging |
100+ req/sec |
nmap -T4 |
| High-security target |
1-2 req/sec |
nmap -T1 |
| WAF-protected |
1-5 req/sec |
Custom delays |
Traffic Shaping
# nmap with specific rate limiting
nmap -sS --max-rate 10 --max-retries 1 -p 80,443 <target>
# ffuf with rate limiting
ffuf -u https://<target>/FUZZ -w wordlist.txt -rate 5
# nuclei with rate limiting
nuclei -u https://<target> -rl 5 -c 2
# curl with delay between requests
for url in $(cat urls.txt); do
curl -s -o /dev/null -w "%{http_code} $url\n" "$url"
sleep 2
done
Timing Considerations
- Business hours (9am-5pm target timezone): Higher baseline traffic → scanning blends in
- Weekends/holidays: Lower baseline → scans stand out more
- Maintenance windows: If known, ideal for aggressive scanning
- Burst vs sustained: Short bursts with long pauses are less detectable than sustained scanning
3. HTTP OPSEC
User-Agent Management
Important: User-Agent strings become stale quickly. Always use current browser version strings that match real-world traffic at the time of engagement. Check your own browser's UA or query a live UA database before starting.
# Step 1: Get a current, real User-Agent from your own browser or a live source
# Option A: Copy from your browser's DevTools (Network tab → Request Headers)
# Option B: Use a curated list — update version numbers to match current releases
# Step 2: Build a rotation list with CURRENT versions
# Template — replace <CHROME_VER> and <FIREFOX_VER> with latest stable versions
UA_LIST=(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/<CHROME_VER> Safari/537.36"
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/<CHROME_VER> Safari/537.36"
"Mozilla/5.0 (X11; Linux x86_64; rv:<FIREFOX_VER>) Gecko/20100101 Firefox/<FIREFOX_VER>"
"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:<FIREFOX_VER>) Gecko/20100101 Firefox/<FIREFOX_VER>"
)
UA="${UA_LIST[$RANDOM % ${#UA_LIST[@]}]}"
curl -s -A "$UA" https://<target>/
# ffuf with custom user agent
ffuf -u https://<target>/FUZZ -w wordlist.txt -H "User-Agent: $UA"
Header Hygiene
# Avoid tool-specific headers that reveal scanner identity
# BAD: Default tool user agents
# - "Nmap Scripting Engine"
# - "nikto"
# - "gobuster"
# - "sqlmap"
# GOOD: Mimic real browser headers (use current browser versions!)
curl -s https://<target>/ \
-H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/<CURRENT_VER> Safari/537.36" \
-H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
-H "Accept-Language: en-US,en;q=0.9" \
-H "Accept-Encoding: gzip, deflate, br"
4. Tool Signature Awareness
Common IDS/WAF Signatures
| Tool |
Detection Signature |
Mitigation |
| nmap |
SYN scan pattern, probe ordering |
Use -T2, --data-length |
| nikto |
Default User-Agent, predictable paths |
Custom UA, selective tuning |
| sqlmap |
Parameter tampering patterns |
Not applicable to recon phase |
| ffuf |
Rapid sequential requests |
Rate limiting (-rate) |
| nuclei |
Template-specific payloads |
Rate limiting (-rl), selective templates |
| gobuster |
Sequential path enumeration |
Randomize wordlist, rate limit |
Reducing Scanner Fingerprint
# nmap — add random data to packets
nmap -sS --data-length 24 -T2 <target>
# nmap — randomize host order (for multi-target)
nmap -sS --randomize-hosts -iL targets.txt
# nmap — spoof source port (use common ports)
nmap -sS -g 53 <target> # Appear as DNS traffic
nmap -sS -g 80 <target> # Appear as HTTP traffic
5. Source Management
IP Awareness
- Know your egress IP:
curl -s ifconfig.me
- Single source: All scans originate from the sandbox — the target will see one IP
- VPN/proxy considerations: If engagement allows, rotate exit nodes
- Cloud instances: Ephemeral cloud VMs provide disposable IPs
DNS OPSEC
# Use public resolvers to avoid leaking internal DNS queries
dig @8.8.8.8 <target> A +short
dig @1.1.1.1 <target> A +short
# Don't use target's own DNS servers for recon queries
# (they may log all queries from unknown sources)
6. Evidence & Data Handling
Engagement Documentation
Every action should be logged:
| Timestamp (UTC) | Action | Target | Tool | Justification |
|-----------------|--------|--------|------|---------------|
| <YYYY-MM-DD HH:MM> | SYN scan top 1000 | 10.0.1.50 | nmap | Passive recon identified as primary web server |
| <YYYY-MM-DD HH:MM> | Dir fuzzing | api.example.com | ffuf | Port 443 open, REST API suspected |
Data Classification
- Workspace files: All scan output goes to the engagement directory — treat as engagement artifacts
- Credentials found: NEVER store in plaintext — immediately document and encrypt
- PII discovered: Note existence, do not exfiltrate — document for client
- Client data: Handle per engagement contract data handling requirements
Clean-Up Protocol
After engagement:
7. Scope Enforcement
Automated Scope Checking
# Before scanning, verify target is in scope
SCOPE_FILE="scope.txt"
TARGET="10.0.1.50"
if grep -q "$TARGET" "$SCOPE_FILE" 2>/dev/null; then
echo "IN SCOPE — proceed"
else
echo "WARNING: $TARGET not found in scope file!"
echo "Verify before proceeding."
fi
Scope Boundaries
- IP ranges: Only scan IPs explicitly listed in scope document
- Domains: Only enumerate subdomains of authorized root domains
- Cloud resources: Only test resources confirmed as client-owned
- Third-party services: DO NOT test shared infrastructure (CDNs, SaaS platforms)
- Physical scope: Only applicable if physical penetration test is authorized
Accidental Out-of-Scope
If you accidentally touch an out-of-scope system:
- Stop immediately
- Document the incident (timestamp, target, action taken)
- Notify the engagement lead
- Do NOT attempt to "clean up" evidence — this makes it worse
8. Detection Indicators to Monitor
Signs You've Been Detected
- Connection resets: Target suddenly dropping connections → firewall rule added
- Rate limiting: 429 responses where 200s were before → WAF triggered
- IP block: Timeouts on previously responsive hosts → IP banned
- Honeypot indicators: Unusually easy targets, too-good-to-be-true services
- Tarpit responses: Extremely slow responses → deliberately slowing scanner
Response to Detection
- Pause all scanning — at least 30 minutes
- Assess what triggered detection — review recent scan patterns
- Reduce scan rate by 50-75%
- Consider different approach — passive only for a period
- Document the detection event for engagement report
9. OPSEC Checklist (Pre-Engagement)
1---
2name: opsec
3description: "Operational security management — traffic shaping, scan rate limiting, source IP management, tool signature avoidance, evidence handling, anti-detection patterns."
4allowed-tools: Bash Read
5metadata:
6 source: https://skillmd.com/skills/aibot88/opsec
7 subdomain: opsec
8 when_to_use: "OPSEC check, rate limit, stealth, detection avoidance, scan timing, user-agent, scope check, evidence handling, clean up, anti-detection"
9 tags: opsec, stealth, rate-limit, user-agent, scope-check, evidence-handling, anti-detection
10 mitre_attack: T1562, T1070, T1036
11---
12
13# Operational Security (OPSEC) Knowledge Base
14
15OPSEC ensures the red team engagement remains covert, controlled, and within authorized scope. Poor OPSEC burns the engagement — detected scans alert the blue team, taint findings, and waste client resources. This skill applies across all recon phases.
16
17## 1. Core OPSEC Principles
18
19### The OPSEC Mindset
201. **Every packet is a signal** — assume the target has IDS/IPS, SIEM, and SOC analysts
212. **Minimize footprint** — collect only what you need, no more
223. **Blend with normal traffic** — timing, volume, and patterns should look legitimate
234. **Know your tools' signatures** — every scanner has a fingerprint
245. **Document everything** — if you can't prove it was authorized, it wasn't
25
26### Engagement Scope Awareness
27Before ANY active operation:
28- [ ] Written Rules of Engagement (ROE) on file
29- [ ] Target IP ranges and domains explicitly listed
30- [ ] Out-of-scope assets clearly identified
31- [ ] Testing window defined (dates, times)
32- [ ] Emergency contact for the client (for accidental impact)
33- [ ] Get-out-of-jail letter accessible
34
35## 2. Network OPSEC
36
37### Scan Rate Limiting
38
39| Target Type | Recommended Rate | Timing Flag |
40|-------------|-----------------|-------------|
41| Production web server | 5-10 req/sec | nmap `-T2` |
42| Internal network | 50-100 req/sec | nmap `-T3` |
43| Development/staging | 100+ req/sec | nmap `-T4` |
44| High-security target | 1-2 req/sec | nmap `-T1` |
45| WAF-protected | 1-5 req/sec | Custom delays |
46
47### Traffic Shaping
48```bash
49# nmap with specific rate limiting
50nmap -sS --max-rate 10 --max-retries 1 -p 80,443 <target>
51
52# ffuf with rate limiting
53ffuf -u https://<target>/FUZZ -w wordlist.txt -rate 5
54
55# nuclei with rate limiting
56nuclei -u https://<target> -rl 5 -c 2
57
58# curl with delay between requests
59for url in $(cat urls.txt); do
60 curl -s -o /dev/null -w "%{http_code} $url\n" "$url"
61 sleep 2
62done
63```
64
65### Timing Considerations
66- **Business hours (9am-5pm target timezone)**: Higher baseline traffic → scanning blends in
67- **Weekends/holidays**: Lower baseline → scans stand out more
68- **Maintenance windows**: If known, ideal for aggressive scanning
69- **Burst vs sustained**: Short bursts with long pauses are less detectable than sustained scanning
70
71## 3. HTTP OPSEC
72
73### User-Agent Management
74
75> **Important**: User-Agent strings become stale quickly. Always use **current** browser version strings that match real-world traffic at the time of engagement. Check your own browser's UA or query a live UA database before starting.
76
77```bash
78# Step 1: Get a current, real User-Agent from your own browser or a live source
79# Option A: Copy from your browser's DevTools (Network tab → Request Headers)
80# Option B: Use a curated list — update version numbers to match current releases
81
82# Step 2: Build a rotation list with CURRENT versions
83# Template — replace <CHROME_VER> and <FIREFOX_VER> with latest stable versions
84UA_LIST=(
85 "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/<CHROME_VER> Safari/537.36"
86 "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/<CHROME_VER> Safari/537.36"
87 "Mozilla/5.0 (X11; Linux x86_64; rv:<FIREFOX_VER>) Gecko/20100101 Firefox/<FIREFOX_VER>"
88 "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:<FIREFOX_VER>) Gecko/20100101 Firefox/<FIREFOX_VER>"
89)
90UA="${UA_LIST[$RANDOM % ${#UA_LIST[@]}]}"
91
92curl -s -A "$UA" https://<target>/
93
94# ffuf with custom user agent
95ffuf -u https://<target>/FUZZ -w wordlist.txt -H "User-Agent: $UA"
96```
97
98### Header Hygiene
99```bash
100# Avoid tool-specific headers that reveal scanner identity
101# BAD: Default tool user agents
102# - "Nmap Scripting Engine"
103# - "nikto"
104# - "gobuster"
105# - "sqlmap"
106
107# GOOD: Mimic real browser headers (use current browser versions!)
108curl -s https://<target>/ \
109 -H "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/<CURRENT_VER> Safari/537.36" \
110 -H "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8" \
111 -H "Accept-Language: en-US,en;q=0.9" \
112 -H "Accept-Encoding: gzip, deflate, br"
113```
114
115## 4. Tool Signature Awareness
116
117### Common IDS/WAF Signatures
118
119| Tool | Detection Signature | Mitigation |
120|------|-------------------|------------|
121| nmap | SYN scan pattern, probe ordering | Use `-T2`, `--data-length` |
122| nikto | Default User-Agent, predictable paths | Custom UA, selective tuning |
123| sqlmap | Parameter tampering patterns | Not applicable to recon phase |
124| ffuf | Rapid sequential requests | Rate limiting (`-rate`) |
125| nuclei | Template-specific payloads | Rate limiting (`-rl`), selective templates |
126| gobuster | Sequential path enumeration | Randomize wordlist, rate limit |
127
128### Reducing Scanner Fingerprint
129```bash
130# nmap — add random data to packets
131nmap -sS --data-length 24 -T2 <target>
132
133# nmap — randomize host order (for multi-target)
134nmap -sS --randomize-hosts -iL targets.txt
135
136# nmap — spoof source port (use common ports)
137nmap -sS -g 53 <target> # Appear as DNS traffic
138nmap -sS -g 80 <target> # Appear as HTTP traffic
139```
140
141## 5. Source Management
142
143### IP Awareness
144- **Know your egress IP**: `curl -s ifconfig.me`
145- **Single source**: All scans originate from the sandbox — the target will see one IP
146- **VPN/proxy considerations**: If engagement allows, rotate exit nodes
147- **Cloud instances**: Ephemeral cloud VMs provide disposable IPs
148
149### DNS OPSEC
150```bash
151# Use public resolvers to avoid leaking internal DNS queries
152dig @8.8.8.8 <target> A +short
153dig @1.1.1.1 <target> A +short
154
155# Don't use target's own DNS servers for recon queries
156# (they may log all queries from unknown sources)
157```
158
159## 6. Evidence & Data Handling
160
161### Engagement Documentation
162Every action should be logged:
163```markdown
164| Timestamp (UTC) | Action | Target | Tool | Justification |
165|-----------------|--------|--------|------|---------------|
166| <YYYY-MM-DD HH:MM> | SYN scan top 1000 | 10.0.1.50 | nmap | Passive recon identified as primary web server |
167| <YYYY-MM-DD HH:MM> | Dir fuzzing | api.example.com | ffuf | Port 443 open, REST API suspected |
168```
169
170### Data Classification
171- **Workspace files**: All scan output goes to the engagement directory — treat as engagement artifacts
172- **Credentials found**: NEVER store in plaintext — immediately document and encrypt
173- **PII discovered**: Note existence, do not exfiltrate — document for client
174- **Client data**: Handle per engagement contract data handling requirements
175
176### Clean-Up Protocol
177After engagement:
178- [ ] All tools stopped
179- [ ] No persistent connections to target
180- [ ] Scan data secured per client requirements
181- [ ] Temporary files cleaned from sandbox
182- [ ] No data left on third-party services (Shodan searches, etc.)
183
184## 7. Scope Enforcement
185
186### Automated Scope Checking
187```bash
188# Before scanning, verify target is in scope
189SCOPE_FILE="scope.txt"
190TARGET="10.0.1.50"
191
192if grep -q "$TARGET" "$SCOPE_FILE" 2>/dev/null; then
193 echo "IN SCOPE — proceed"
194else
195 echo "WARNING: $TARGET not found in scope file!"
196 echo "Verify before proceeding."
197fi
198```
199
200### Scope Boundaries
201- **IP ranges**: Only scan IPs explicitly listed in scope document
202- **Domains**: Only enumerate subdomains of authorized root domains
203- **Cloud resources**: Only test resources confirmed as client-owned
204- **Third-party services**: DO NOT test shared infrastructure (CDNs, SaaS platforms)
205- **Physical scope**: Only applicable if physical penetration test is authorized
206
207### Accidental Out-of-Scope
208If you accidentally touch an out-of-scope system:
2091. **Stop immediately**
2102. **Document the incident** (timestamp, target, action taken)
2113. **Notify the engagement lead**
2124. **Do NOT attempt to "clean up" evidence** — this makes it worse
213
214## 8. Detection Indicators to Monitor
215
216### Signs You've Been Detected
217- **Connection resets**: Target suddenly dropping connections → firewall rule added
218- **Rate limiting**: 429 responses where 200s were before → WAF triggered
219- **IP block**: Timeouts on previously responsive hosts → IP banned
220- **Honeypot indicators**: Unusually easy targets, too-good-to-be-true services
221- **Tarpit responses**: Extremely slow responses → deliberately slowing scanner
222
223### Response to Detection
2241. **Pause all scanning** — at least 30 minutes
2252. **Assess what triggered detection** — review recent scan patterns
2263. **Reduce scan rate** by 50-75%
2274. **Consider different approach** — passive only for a period
2285. **Document the detection event** for engagement report
229
230## 9. OPSEC Checklist (Pre-Engagement)
231
232- [ ] ROE document reviewed and understood
233- [ ] Scope file created at `scope.txt`
234- [ ] Emergency client contact accessible
235- [ ] Egress IP noted: `curl -s ifconfig.me`
236- [ ] Tool user agents configured (non-default)
237- [ ] Scan rate limits configured per target type
238- [ ] Output directory structure created
239- [ ] Evidence logging template ready
240- [ ] Clean-up protocol documented