-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate_traffic.py
More file actions
66 lines (52 loc) · 3.07 KB
/
Copy pathsimulate_traffic.py
File metadata and controls
66 lines (52 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import requests
import random
import time
# Change this if your WAF is running on a different port
TARGET_URL = "http://127.0.0.1:5000"
# Generic, non-weaponized test payloads that trigger WAF regex rules
PAYLOADS = [
# Safe / Normal Traffic
{"url": "/", "headers": {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"}, "type": "Normal"},
{"url": "/about", "headers": {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)"}, "type": "Normal"},
{"url": "/contact", "headers": {"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X)"}, "type": "Normal"},
# SQL Injection (SQLi)
{"url": "/login?user=admin' OR '1'='1' --", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "SQLi"},
{"url": "/search?q=1; DROP TABLE users", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "SQLi"},
# Cross-Site Scripting (XSS)
{"url": "/blog?id=<script>alert(document.cookie)</script>", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "XSS"},
{"url": "/profile?name=<img src=x onerror=alert('XSS')>", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "XSS"},
# Local File Inclusion (LFI)
{"url": "/download?file=../../../../etc/passwd", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "LFI"},
{"url": "/view?page=C:\\Windows\\System32\\drivers\\etc\\hosts", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "LFI"},
# OS Command Injection
{"url": "/ping?ip=127.0.0.1; cat /etc/shadow", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "OS Command"},
{"url": "/api/status?cmd=whoami | awk '{print $1}'", "headers": {"User-Agent": "Mozilla/5.0"}, "type": "OS Command"},
# Malicious Bots / Scanners
{"url": "/", "headers": {"User-Agent": "sqlmap/1.5.4.11#dev"}, "type": "Scanner Bot"},
{"url": "/admin.php", "headers": {"User-Agent": "Nikto/2.1.6"}, "type": "Scanner Bot"},
{"url": "/.env", "headers": {"User-Agent": "python-requests/2.25.1"}, "type": "Scanner Bot"}
]
print(f"🚀 Starting WAF Traffic Simulator against {TARGET_URL}...")
print("Press Ctrl+C to stop.\n")
try:
while True:
# Pick a random attack or normal request
attack = random.choice(PAYLOADS)
full_url = TARGET_URL + attack["url"]
try:
# Send the request
response = requests.get(full_url, headers=attack["headers"], timeout=3)
# Print the result to the terminal
if response.status_code == 403:
print(f"[BLOCKED] 🛡️ WAF intercepted {attack['type']}")
elif response.status_code == 429:
print(f"[BANNED] 🛑 Rate Limiter kicked in!")
else:
print(f"[ALLOWED] ✅ Normal traffic passed: {attack['type']}")
except requests.exceptions.ConnectionError:
print("❌ Connection Error. Is WAF running?")
break
# Random delay between 0.1 and 2 seconds to make the EKG line look organic
time.sleep(random.uniform(0.1, 2.0))
except KeyboardInterrupt:
print("\n🛑 Traffic Simulation Stopped.")