
SVG Analysis and generation tools for commonly seen SVG attachment phishing
This toolkit contains specialized Python tools for analyzing potentially malicious SVG files and detecting security mechanisms.
The toolkit consists of four main tools:
A pattern-based static analysis tool that decodes obfuscated URLs from malicious SVG files without executing any code. This is the safer option for initial analysis.
String.fromCharCode patterns with numeric calculations# Analyze a single SVG file
python3 extract.py -i malicious.svg
# Verbose output showing decoded JavaScript
python3 extract.py -i malicious.svg -v
# Debug mode with detailed analysis steps
python3 extract.py -i malicious.svg -d
# Read from stdin
python3 extract.py < malicious.svg
String.fromCharCode(115,101,99,...) ("secretkey")for loops with parseInt and XOR operationsdata: URIsatob("base64") + variableName patternsDYNAMIC SVG URL EXTRACTOR
=========================================================
SVG #1 Results:
----------------------------------------
Obfuscation: XOR decoding (key length: 9)
Extracted URLs:
→ https://malicious.example.com/[email protected]
A sophisticated dynamic analysis tool that extracts and analyzes JavaScript embedded in SVG files using box-js. This tool executes JavaScript in a sandboxed environment and is designed to extract final, complete URLs even when built through complex obfuscation.
location, window.open, fetch, XHR, Image.src, etc.# Required: box-js must be installed globally
npm install -g box-js
# Python requirements (optional)
pip install -r requirements.txt
# Basic analysis of a single SVG
python3 extract_dynamic.py -i malicious.svg
# Analyze with custom output directory
python3 extract_dynamic.py -i malicious.svg -o analysis_results
# Analyze directory of SVGs with extended timeout
python3 extract_dynamic.py -i svg_samples/ -t 60
# Keep temporary files for debugging
python3 extract_dynamic.py -i malicious.svg --keep-temp
# Save URL blocklist to file
python3 extract_dynamic.py -i malicious.svg --blocklist-out urls.txt
# Mask email addresses for privacy
python3 extract_dynamic.py -i malicious.svg --mask-emails
The tool injects a comprehensive JavaScript payload that hooks:
location.href, location.assign(), location.replace()window.open(), navigation methodsfetch(), XMLHttpRequest.open()String.prototype.concat, string manipulationatob(), decodeURI(), unescape()eval(), Function(), setTimeout()Automatically detects and handles:
=== Processing: malicious.svg ===
Wrote temp JS -> /tmp/boxjs_svg_ABC/test.boxed.js
Running box-js (timeout 30s) with sink hooks...
[+] box-js finished. Results in: boxjs_out/malicious.svg.boxjs_results
*** FINAL COMPLETE URLs FOUND ***:
→ https://evil.example.com/[email protected]
Emails found:
→ [email protected]
=== FINAL ANALYSIS SUMMARY ===
🎯 COMPLETE URLs EXTRACTED (1 total):
======================================================
→ https://evil.example.com/[email protected]
======================================================
A web reconnaissance tool for detecting Cloudflare security mechanisms including Turnstile, CAPTCHA systems, browser verification, and other protection measures across redirect chains.
pip install requests
pip install brotli # Optional for brotli support
# Check single URL for Cloudflare protections
python3 cf_probe.py https://example.com
# Scan with JavaScript file analysis
python3 cf_probe.py https://example.com --scan-js
# Process multiple URLs from file
python3 cf_probe.py -i urls.txt
# Custom User-Agent and timeout
python3 cf_probe.py https://example.com -A "Custom-Agent" -t 30
# Disable TLS verification (for testing)
python3 cf_probe.py https://example.com --insecure
# Dump HTML/JS for analysis
python3 cf_probe.py https://example.com --dump analysis_dump/
data-sitekey attributesturnstile.render() JavaScript callsturnstile.create() JavaScript callscf-turnstile CSS classes=== Redirect/Navigation Chain (3 steps) ===
[0] URL: https://example.com
Status: 301
Cloudflare Protection: YES (CF Headers)
CF Header: cf-ray: 123abc456def789
[1] URL: https://protected.example.com
Status: 200
Cloudflare Protection: YES (Turnstile, Custom CAPTCHA)
Turnstile Site key(s): 0x1AAA000000000000000
CAPTCHA Evidence: Click the computer to verify
=== Summary ===
Cloudflare Protection Detected: Turnstile with key(s): 0x1AAA000000000000000 | Custom CAPTCHA
Generates obfuscated SVG files with various encoding patterns for testing the analysis tools.
# Generate single pattern
python3 encoder.py -u "https://evil.com/c2" -p 1 -o test.svg
# Generate all patterns in directory
python3 encoder.py --random-all -o test_patterns/
# Custom email address
python3 encoder.py -u "https://evil.com" -e "[email protected]" -p 3 -o custom.svg
Function constructorArray.find() execution$ python3 encoder.py --random-all -o test_suite/
Generated xor_proxy_enhanced: test_suite/pattern_01_xor_proxy_enhanced.svg
URL: https://r4nd0m.example.com/[email protected]
Generated hex_function: test_suite/pattern_02_hex_function.svg
URL: https://evil-site.org/[email protected]
[... 4 more patterns ...]
# Step 1: Generate test cases
python3 encoder.py --random-all -o test_cases/
# Step 2: Static analysis first (safer)
python3 extract.py -i test_cases/pattern_01_*.svg -v > static_results.txt
# Step 3: Dynamic analysis (in isolated environment)
python3 extract_dynamic.py -i test_cases/ -o dynamic_results/ --blocklist-out malicious_urls.txt
# Step 4: Verify Cloudflare protection on extracted URLs (if safe to do so)
python3 cf_probe.py -i malicious_urls.txt
# Clone or download the toolkit
cd svg_tools/
# Install Python dependencies
pip install -r requirements.txt
# Install box-js globally (for dynamic analysis)
npm install -g box-js
# Verify installation
python3 extract.py --help
python3 extract_dynamic.py --help
python3 cf_probe.py --help
python3 encoder.py --help