python Verified current stable Not installed? Security

Python / Select Random User Agent

Select Random User Agent

Randomly selects a User-Agent string for requests to obscure testing identity.

$
Terminal
python sqlmap.py -u "{http://www.example.com/vuln.php}" --random-agent

When To Use

When conducting automated tests against web applications to prevent blocking by fixed User-Agent strings.

Pro Tip

Monitor requests to identify if certain User-Agents lead to different server responses; prefer frequently used browsers.

Anatomy of Output

Understanding the result

[05:15:10] [INFO] using a random User-Agent Info

Indicates that a random User-Agent will be employed.

[05:15:11] [INFO] sent request with User-Agent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3' User-Agent Sent

Displays the specific User-Agent used for the request.

[05:15:12] [SUCCESS] response received Request Result

Shows that the request was successfully sent and a response received.

Power User Variants

Optimized versions

python sqlmap.py -u 'http://www.example.com/vuln.php' --random-agent --level=5

Increase the aggressiveness of the testing.

python sqlmap.py -u 'http://www.example.com/vuln.php' --random-agent --cookie='session=abc123'

Send a session cookie while using random User-Agent.

Troubleshooting

Common pitfalls

sqlmap -u '...' --random-agent - ERROR: No response received

Solution: Check target URL for availability and proper endpoint status.

sqlmap -u '...' --random-agent - ERROR: Unsupported User-Agent

Solution: Verify that custom User-Agent, if provided, is correctly formatted.

sqlmap -u '...' --random-agent - ERROR: Blocking detected

Solution: Consider reducing request frequency or using more diverse User-Agents.

Command Breakdown

What each part is doing

python
Base Command
The executable that performs this operation. Here it runs Python before the shell applies any redirect operators.
-u
u| url
The URL supplied to this command.
{http://www.example.com/vuln.php}
http: www.example.com vuln.php
The value supplied for http: www.example.com vuln.php.
-u
Command Option
Tool-specific option used by this command invocation.
--random-agent
Command Option
Tool-specific option used by this command invocation.

Alternative Approaches

Comparable commands in other tools

Alternative security tools for the same job.