SQLMAP无法运行:执行注入命令时打开sqlmap.py而非显示数据库
Hey there, let's troubleshoot why your sqlmap isn't running your database injection test and instead opening the sqlmap.py file directly. This is a common issue tied to either incorrect command usage or system-level Python script associations. Here's how to fix it:
1. Use the Correct Command Syntax
The most likely culprit is that you're not invoking Python to run the script. Instead of just typing sqlmap.py or double-clicking the file, launch it via the command line with your Python interpreter:
- For Python 3:
python3 sqlmap.py -u "http://your-target-url.com/page?id=1" [other flags] - For Python 2.7 (if you're using an older setup):
python sqlmap.py -u "http://your-target-url.com/page?id=1" [other flags]
Replace the URL and flags with your actual target and desired parameters (like --dbs to list databases).
2. Fix Python Script Association (Windows)
If double-clicking sqlmap.py or running it directly in cmd opens a text editor, your system isn't set to use Python to execute .py files:
- Right-click
sqlmap.py→ Open with → Choose another app - Select your installed Python executable (if it doesn't show up, click More apps → Look for another app on this PC and navigate to your Python installation folder, e.g.,
C:\Python39\python.exe) - Check the box that says Always use this app to open .py files
- Now, running
sqlmap.pydirectly in the command line should execute the script instead of opening it.
3. Verify sqlmap Installation Completeness
Make sure you have the full, uncorrupted sqlmap package:
- If you downloaded a ZIP from the official repo, re-extract it to ensure no files were lost during extraction
- If you cloned via Git, run
git pullin the sqlmap directory to make sure you have the latest, complete version
4. Confirm Your Python Environment
sqlmap requires Python 2.7 or 3.x (Python 3 is recommended). Verify your version with:
python --version # Or for Python 3: python3 --version
If you don't have Python installed, grab the latest version from the official Python website before proceeding.
Important Note
Always ensure you have explicit permission to test the target website's database. Unauthorized SQL injection testing violates privacy laws and ethical standards.
内容的提问来源于stack exchange,提问作者Mihir Thakkar

