Overview
Theheader_randomizer module provides HTTP header randomization capabilities to help beacons evade network detection. It supports four levels of randomization, from fully deterministic (level 0) to highly randomized (level 3).
Module: evasion.header_randomizer
Functions
get_headers()
Parameters
Randomization level (0-3):
- 0: Fixed Chrome UA, fixed language, fixed encoding
- 1: Random UA, fixed language, fixed encoding
- 2: Random UA, random language, fixed encoding
- 3: Random UA, random language, random encoding, shuffled header order
Returns
Dictionary of HTTP headers with the following keys:
Host: Server hostname (with port if non-standard)Content-Type: Alwaysapplication/octet-streamUser-Agent: Browser user agent stringAccept-Language: Language preferenceAccept-Encoding: Supported encodingsAccept: Content type acceptance (always*/*)Connection: Connection type (alwayskeep-alive)
Raises
ValueError: If level is not in range 0-3
Example
Constants
USER_AGENTS
- Chrome 122 on Windows 10
- Firefox 123 on Windows 10
- Edge 121 on Windows 10
- Safari 17.2 on macOS 14.3
ACCEPT_LANGUAGES
- English (US)
- English (GB)
- French (France)
- German (Germany)
- Japanese (Japan)
- Chinese (Simplified, China)
- Portuguese (Brazil)
ACCEPT_ENCODINGS
Randomization Levels
Level 0: Deterministic
- User-Agent: Fixed Chrome UA
- Accept-Language:
en-US,en;q=0.9 - Accept-Encoding:
gzip, deflate, br - Header Order: Fixed
- Use Case: Testing, environments where consistency is required
Level 1: Basic Rotation
- User-Agent: Random from
USER_AGENTS - Accept-Language:
en-US,en;q=0.9(fixed) - Accept-Encoding:
gzip, deflate, br(fixed) - Header Order: Fixed
- Use Case: Light evasion with predictable language/encoding
Level 2: Medium Randomization
- User-Agent: Random from
USER_AGENTS - Accept-Language: Random from
ACCEPT_LANGUAGES - Accept-Encoding:
gzip, deflate, br(fixed) - Header Order: Fixed
- Use Case: Balanced evasion, mimics diverse user base
Level 3: Maximum Randomization
- User-Agent: Random from
USER_AGENTS - Accept-Language: Random from
ACCEPT_LANGUAGES - Accept-Encoding: Random from
ACCEPT_ENCODINGS - Header Order: Shuffled (except
HostandContent-Typealways first) - Use Case: Maximum evasion, makes fingerprinting difficult
Notes
HostandContent-Typeheaders are always present and always appear firstHostincludes port number if non-standard (not 80 or 443)- Port is read from
config.SERVER_PORT - All randomization uses Python’s
randommodule