保定免费做网站,云羽网络做网站怎么样,故事型软文广告,做网站企业经营范围一、简介 sqlmap 是一款开源的渗透测试工具#xff0c;可以自动化进行SQL注入的检测、利用#xff0c;并能接管数据库服务器。它具有功能强大的检测引擎,为渗透测试人员提供了许多专业的功能并且可以进行组合#xff0c;其中包括数据库指纹识别、数据读取和访问底层文件系统…一、简介 sqlmap 是一款开源的渗透测试工具可以自动化进行SQL注入的检测、利用并能接管数据库服务器。它具有功能强大的检测引擎,为渗透测试人员提供了许多专业的功能并且可以进行组合其中包括数据库指纹识别、数据读取和访问底层文件系统甚至可以通过带外数据连接的方式执行系统命令。 官网下载地址GitHub - sqlmapproject/sqlmap: Automatic SQL injection and database takeover tool
使用方法
python sqlmap.py 参数Windows
sqlmap 参数Linux
sqlmap可以运行在python2.6、2.7和3.x的任何平台上。
官方文档
Usage · sqlmapproject/sqlmap Wiki (github.com)
二、使用方法
Options模块 1、 -h, --help
显示基础帮助信息。
python sqlmap.py -h
2、 -hh
显示高级帮助信息。
python sqlmap.py -h
3、 --version
显示版本信息。
python sqlmap.py -version
4、 -v VERBOSE
指定的输出信息的内容等级0-6 python sqlmap.py -u http://ctf/sql_labs/Less-1/?id1 -v 5
运行结果 Target模块 1、 -u URL, --urlURL
需要进行注入检测的目标URL。
python sqlmap.py -u http://ctf/sql_labs/Less-1/?id1
2、 -d DIRECT
通过字符串直连数据库。 争对不同的数据库有不同的连接字符串方式。 案例
python sqlmap.py -d mysql://root:root127.0.0.1:3306/testdb
3、 -l LOGFILE
从Burp或者WebScarab的代理日志中解析目标。 指定一个Burp或WebScarab的代理日志文件Sqlmap将从日志文件中解析出可能的攻击目标并逐个尝试进行注入。个人没尝试过 4、 -m BULKFILE
扫描文本文件提供的多个目标URL目标。 文本文件中包含多个URL目标针对多个目标时候使用。 案例
python sqlmap.py -m url.txt
5、 -r REQUESTFILE
从文件中加载HTTP请求。 将一个HTTP请求保存在文件中然后使用参数“-r”加载该文件这样可以跳过其他一些选项的使用例如设置Cookie发布数据等以该文件中HTTP请求目标为攻击目标进行测试。 案例:
python sqlmap.py -r a.txt
6、 -g GOOGLRFORK 将谷歌查询结果作为目标URL。 将谷歌搜索的前一百条结果作为检测注入目标需要科学上网翻墙 值Google hack语句
实例
sqlmap -g inurl:\.php?id1\
7、 -c CONFIGFILE 从配置conf文件获取注入目标。 打开配置文件模板填写需要的参数到模板使用以下代码进行注入。 python sqlmap.py -c a.conf Request模块 指定http请求的相关参数感觉可以通过使用-r参数从文件中加载http请求更合适。 Request:These options can be used to specify how to connect to the target URL--methodMETHOD Force usage of given HTTP method (e.g. PUT)--dataDATA Data string to be sent through POST (e.g. id1)--param-delPARA.. Character used for splitting parameter values (e.g. )--cookieCOOKIE HTTP Cookie header value (e.g. PHPSESSIDa8d127e..)--cookie-delCOO.. Character used for splitting cookie values (e.g. ;)--live-cookiesL.. Live cookies file used for loading up-to-date values--load-cookiesL.. File containing cookies in Netscape/wget format--drop-set-cookie Ignore Set-Cookie header from response-A AGENT, --user.. HTTP User-Agent header value--mobile Imitate smartphone through HTTP User-Agent header--random-agent Use randomly selected HTTP User-Agent header value--hostHOST HTTP Host header value--refererREFERER HTTP Referer header value--headersHEADERS Extra headers (e.g. Accept-Language: fr\nETag: 123)-H HEADER, --hea.. Extra header (e.g. X-Forwarded-For: 127.0.0.1)--auth-typeAUTH.. HTTP authentication type (Basic, Digest, Bearer, ...)--auth-credAUTH.. HTTP authentication credentials (name:password)--auth-fileAUTH.. HTTP authentication PEM cert/private key file--abort-codeABO.. Abort on (problematic) HTTP error code(s) (e.g. 401)--ignore-codeIG.. Ignore (problematic) HTTP error code(s) (e.g. 401)--ignore-proxy Ignore system default proxy settings--ignore-redirects Ignore redirection attempts--ignore-timeouts Ignore connection timeouts--proxyPROXY Use a proxy to connect to the target URL--proxy-credPRO.. Proxy authentication credentials (name:password)--proxy-filePRO.. Load proxy list from a file--proxy-freqPRO.. Requests between change of proxy from a given list--tor Use Tor anonymity network--tor-portTORPORT Set Tor proxy port other than default--tor-typeTORTYPE Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default))--check-tor Check to see if Tor is used properly--delayDELAY Delay in seconds between each HTTP request--timeoutTIMEOUT Seconds to wait before timeout connection (default 30)--retriesRETRIES Retries when the connection timeouts (default 3)--retry-onRETRYON Retry request on regexp matching content (e.g. drop)--randomizeRPARAM Randomly change value for given parameter(s)--safe-urlSAFEURL URL address to visit frequently during testing--safe-postSAFE.. POST data to send to a safe URL--safe-reqSAFER.. Load safe HTTP request from a file--safe-freqSAFE.. Regular requests between visits to a safe URL--skip-urlencode Skip URL encoding of payload data--csrf-tokenCSR.. Parameter used to hold anti-CSRF token--csrf-urlCSRFURL URL address to visit for extraction of anti-CSRF token--csrf-methodCS.. HTTP method to use during anti-CSRF token page visit--csrf-dataCSRF.. POST data to send during anti-CSRF token page visit--csrf-retriesC.. Retries for anti-CSRF token retrieval (default 0)--force-ssl Force usage of SSL/HTTPS--chunked Use HTTP chunked transfer encoded (POST) requests--hpp Use HTTP parameter pollution method--evalEVALCODE Evaluate provided Python code before the request (e.g.import hashlib;id2hashlib.md5(id).hexdigest())1、 --methodMETHOD
指定请求的方法。 指定HTTP请求的方法。一般情况下会自动检测请求的方法。在某些特定的情况下需要强制指定方法。 案例
python sqlmap.py -u “https://www.baidu.com/a.php?id1” --methodput
2、 --dataDATA
指定POST请求提交的参数 当我们使用data参数则HTTP会使用post方法将参数当作HTTP data提交同时也会检测此参数有没有注入漏洞。 案例
python sqlmap.py -u “https://www.baidu.com/a.php?id1” --dataid1
3、 -param-delPARAM
指定参数分割符。 一般情况下网站会用作为参数的分隔符这也是SQLMAP默认使用的分隔符如果有些web application不使用作为分隔符的话那么就使用–param-del去告诉sqlmap分隔符是什么。 案例
python sqlmap.py -u “http://www.xxxxx.com/a.php?id1;food2” --param-del”;”
4、 cookie相关 需要指定Cookie的情况 1、网站需要Cookie信息 2、检测并利用cookie注入。当–level设置为2或者更高的时候sqlmap会检测cookie是否存在注入漏洞。 参数解释--cookie指定cookie的内容--cookie-del 指定cookie的分割符--live-cookies从指定的cookie文件中读取当前的cookie信息--load-cookies 指定以 Netscape/wget 格式存放 cookies 的文件--drop-set-cookie 忽略 HTTP 响应中的 Set-Cookie 参数
5、 user-agent相关
设置用户代理 默认情况下sqlmap使用的User-Agent是sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org) 。当 --level设置为3或者更高时sqlmap会自动检测user-agent是否存在注入漏洞 参数解释-A AGENT自定义User-Agent--random-agent 从sqlmap自带的文本文件中随机选择一个user-agent。这个文件是 ./txt/user-agents.txt--mobile模拟手机发送请求
6、 header相关
参数解释--hostHOST指定HTTP请求的HOST字段--refererREFERER指定HTTP请求的REFERER字段--headersHEADERS添加额外的HTTP请求字段信息 案例
python sqlmap.py -u “http://www.xxx.com/a.php?id1” --headers”X-A : A \nX-B : B”
7、 --auth相关 --auth-typeAUTH.. HTTP authentication type (Basic, Digest, Bearer, ...) --auth-credAUTH.. HTTP authentication credentials (name:password) --auth-fileAUTH.. HTTP authentication PEM cert/private key file 后端 Web 服务器实现的 HTTP 协议认证时所有向目标程序发起 HTTP 请求都需要有效凭据来访问。这种情况可以通过使用以下选项来指定有效凭证信息。 参数解释--auth-typeAUTHHTTP请求认证类型BasicDigestBearer--auth-credAUTHHTTP请求认证证书格式name:password--auth-fileAUTHHTTP请求认证文件PEM格式
案例
python sqlmap.py -u http://192.168.136.131/sqlmap/mysql/basic/get_int.php?id\
1 --auth-typeBasic --auth-credtestuser:testpass
8、 --igore相关 --abort-codeABO.. Abort on (problematic) HTTP error code(s) (e.g. 401) --ignore-codeIG.. Ignore (problematic) HTTP error code(s) (e.g. 401) --ignore-proxy Ignore system default proxy settings --ignore-redirects Ignore redirection attempts --ignore-timeouts Ignore connection timeouts
参数解释--abort-codeABO遇到指定HTTP错误码中断注入--ignore-codeIG忽略指定的HTTP错误码--ignore-proxy忽略系统默认代理设置--ignore-redirects忽略重定向请求--ignore-timeouts忽略连接超时
9、 --proxy相关 --proxyPROXY Use a proxy to connect to the target URL --proxy-credPRO.. Proxy authentication credentials (name:password) --proxy-filePRO.. Load proxy list from a file --proxy-freqPRO.. Requests between change of proxy from a given list
参数解释--proxyPROXY使用代理连接目标URL--proxy-credPRO指定代理认证证书--proxy-filePRO 指定一个包含有代理列表的文件在连接时会依次使用文件里面的代理 当代理无效时会自动调到下一个代理 --proxy-freqPRO指定请求代理的频率
10、 --tor相关 假如因为相关原因需要保持匿名可以根据 Tor 安装指南配置一个 Tor 客户端和 Privoxy或类似的进行代理而不是使用单个预定义的 HTTP(S) 代理服务器。接着就可以使用开关 --tor 来让 sqlmap 尝试自动设置 Tor 代理连接。 如果你想手动设置 Tor 代理的类型和端口可以使用选项 --tor-type 和 --tor-port例如--tor-typeSOCKS5 --tor-port9050。 强烈建议偶尔使用 --check-tor 来确保一切设置正确。有些情况下 Tor 包例如Vidalia译者注Vidalia 是 Tor 的图形界面管理工具官方已经移除对它的支持配置错误或重置了以前的配置会使你以为已经成功匿名。使用这个开关sqlmap 将在对任何目标发起请求之前发送一个请求到你正在使用 Tor这个官方页面检查一切配置是否正常。如果检查失败sqlmap 将警告你并直接退出。 --tor Use Tor anonymity network --tor-portTORPORT Set Tor proxy port other than default --tor-typeTORTYPE Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default)) --check-tor Check to see if Tor is used properly
参数解释--tor自动设置Tor代理连接--tor-port指定端口--tor-type指定类型--check-tor检查Tor设置是否正确
11、 连接时间相关 --delayDELAY Delay in seconds between each HTTP request --timeoutTIMEOUT Seconds to wait before timeout connection (default 30) --retriesRETRIES Retries when the connection timeouts (default 3) --retry-onRETRYON Retry request on regexp matching content (e.g. drop)
参数解释--delayDELAY每次HTTP请求间隔多少秒--timeoutTIMEOUT指定超时连接的等待时间默认30s--retriesRETRIES指定超时连接的重连次数--retry-onRETRYON指定正则匹配的字符串匹配成功进行重连
案例
sqlmap -u http://example.com/vulnerable.php?id1 --risk3 --level5 --retry-ontimeout,error --threads5
12、 --randomizeRPARAM 随机更改参数。可以指定请求参数名称这些参数在请求期间根据原始长度和类型随机更改。这个命令会随机改变 id 参数的值以便在测试时模拟不同的输入。 案例
python sqlmap.py -u http://example.com/vulnerable.php?id1nametest --randomizeid
13、 --safe相关 Sqlmap的盲注测试会产生大量错误请求。为了避免被限制我们可以每隔一段时间来访问正确的url。使用以下参数sqlmap将会每隔一段时间访问一个正确的URL并且不会对其进行任何注入。 --safe-urlSAFEURL URL address to visit frequently during testing --safe-postSAFE.. POST data to send to a safe URL --safe-reqSAFER.. Load safe HTTP request from a file --safe-freqSAFE.. Regular requests between visits to a safe URL
参数解释--safe-urlSAFEURL指定安全链接URL--safe-postSAFE指定安全连接端口--safe-reqSAFER从文件加载安全请求--safe-freqSAFE指定访问安全链接的频率
14、 --skip-urlencode 根据参数的位置例如GET其值可能会被默认进行 URL 编码。在某些情况下后端 Web 服务器不遵循 RFC 标准并要求以原始非编码形式发送参数值。在这种情况下可以使用 --skip-urlencode。 案例
python sqlmap.py -u http://example.com/vulnerable.php?id1 --skip-urlencode
15、 --csrf相关 许多站点有使用 token 的反 CSRF 防护在每个页面的响应随机设置隐藏字段值。sqlmap 将自动尝试识别并绕过这种防护同时支持 --csrf-token 和 --csrf-url 等选项用来做进一步调整。 选项 --csrf-token 用于设置包含随机 token 的隐藏字段的名称。这在网站对这些字段使用非标准名称的情况下是非常有用的。选项 --csrf-url 用于从任意有效的 URL 地址获取 token 值。这在目标网址在初始地不包含必需的 token 值而需要从其他地方提取时是非常有用的。 --csrf-tokenCSR.. Parameter used to hold anti-CSRF token --csrf-urlCSRFURL URL address to visit for extraction of anti-CSRF token --csrf-methodCS.. HTTP method to use during anti-CSRF token page visit --csrf-dataCSRF.. POST data to send during anti-CSRF token page visit --csrf-retriesC.. Retries for anti-CSRF token retrieval (default 0)
参数解释--csrf-tokenCSR指定包含token的参数--csrf-urlCSRFURL指定URL--csrf-methodCS指定请求方法--csrf-dataCSRF指定POST方法请求的数据--csrf-retriesC指定重试次数
16、 杂项 --force-ssl Force usage of SSL/HTTPS --chunked Use HTTP chunked transfer encoded (POST) requests --hpp Use HTTP parameter pollution method --evalEVALCODE Evaluate provided Python code before the request (e.g. import hashlib;id2hashlib.md5(id).hexdigest())
参数解释--force-ssl强制SSL连接--chunked使用分块传输编码请求--hpp使用参数混淆--evalEVALCODE在请求之前执行一段Python代码
案例使用当前 GET 请求中的 id 参数值重新计算出对应的 MD5 哈希值从而替换掉原来的 hash 参数值。
python sqlmap.py -u http://www.target.com/vuln.php?id1hashc4ca4238a0b9238\
20dcc509a6f75849b --evalimport hashlib;hashhashlib.md5(id).hexdigest()
Enumeration模块 该模块用于导出数据库的信息。 Enumeration:These options can be used to enumerate the back-end databasemanagement system information, structure and data contained in thetables-a, --all Retrieve everything-b, --banner Retrieve DBMS banner--current-user Retrieve DBMS current user--current-db Retrieve DBMS current database--hostname Retrieve DBMS server hostname--is-dba Detect if the DBMS current user is DBA--users Enumerate DBMS users--passwords Enumerate DBMS users password hashes--privileges Enumerate DBMS users privileges--roles Enumerate DBMS users roles--dbs Enumerate DBMS databases--tables Enumerate DBMS database tables--columns Enumerate DBMS database table columns--schema Enumerate DBMS schema--count Retrieve number of entries for table(s)--dump Dump DBMS database table entries--dump-all Dump all DBMS databases tables entries--search Search column(s), table(s) and/or database name(s)--comments Check for DBMS comments during enumeration--statements Retrieve SQL statements being run on DBMS-D DB DBMS database to enumerate-T TBL DBMS database table(s) to enumerate-C COL DBMS database table column(s) to enumerate-X EXCLUDE DBMS database identifier(s) to not enumerate-U USER DBMS user to enumerate--exclude-sysdbs Exclude DBMS system databases when enumerating tables--pivot-columnP.. Pivot column name--whereDUMPWHERE Use WHERE condition while table dumping--startLIMITSTART First dump table entry to retrieve--stopLIMITSTOP Last dump table entry to retrieve--firstFIRSTCHAR First query output word character to retrieve--lastLASTCHAR Last query output word character to retrieve--sql-querySQLQ.. SQL statement to be executed--sql-shell Prompt for an interactive SQL shell--sql-fileSQLFILE Execute SQL statements from given file(s)
1、 -a, --all 获取所有数据
python sqlmap.py -u http://ctf/sql_labs/Less-1/?id1 -a
python sqlmap.py -u http://ctf/sql_labs/Less-1/?id1 --all
2、 -b, --banner 获取数据库服务器和中间件版本号
python sqlmap.py -u http://ctf/sql_labs/Less-1/?id1 -b 3、 获取注入页面数据库管理员信息 --current-user Retrieve DBMS current user --current-db Retrieve DBMS current database --hostname Retrieve DBMS server hostname --is-dba Detect if the DBMS current user is DBA
参数解释--current-user获得网页DBMS的当前用户--current-db获得网页DBMS的使用数据库--hostname获得网页主机名--is-dba检查当前用户是否是数据库管理员
4、 列出数据库的指定信息 指定要列出的信息可根据-U、-T、-D指定列出数据的条件也可根据 --exclude-sysdbs 来忽略一些系统表。 --users Enumerate DBMS users --passwords Enumerate DBMS users password hashes --privileges Enumerate DBMS users privileges --roles Enumerate DBMS users roles --dbs Enumerate DBMS databases --tables Enumerate DBMS database tables --columns Enumerate DBMS database table columns --schema Enumerate DBMS schema
参数解释--users 列出所有DBMS用户 --passwords 列出所有DBMS用户密码的哈希值 -U 选项来指定要枚举出角色的用户 --privileges 列出所有DBMS用户权限 -U 选项来指定要枚举出角色的用户 --roles 列出所有DBMS用户角色 -U 选项来指定要枚举出角色的用户 --dbs列出 DBMS 所有数据库--tables列出 DBMS 所有数据表--columns列出 DBMS 所有列--schema列出DBMS 所有模式 5、 --count 获取表的条目数 --count Retrieve number of entries for table(s)
python sqlmap.py http://ctf/sql_labs/Less-1/?id1 --count 用于获取表的条目数量可以用-D、-T来指定数据库和表未指定会输出所有可访问的数据库和表也可以用 --exclude-sysdbs 来忽略一些系统表。 python sqlmap.py http://ctf/sql_labs/Less-1/?id1 --count -exclude-sysdbs
6、 拖库处理 --dump Dump DBMS database table entries --dump-all Dump all DBMS databases tables entries
参数解释--dump导出数据库表条目--dump-alll导出所有数据库表条目 可以用-D、-T来指定数据库和表未指定会输出所有可访问的数据库和表也可以用 --exclude-sysdbs 来忽略一些系统表。 尽量少用--dump-alll因为会产生大量访问获取一些无效信息。 7、 --search 搜索列、表和数据库 此开关允许你在所有数据库中搜索特定的数据库名和表名在特定的数据表中搜索特定的列名。 -C附带以逗号分隔的列名列表来搜索整个 DBMS。 -T附带以逗号分隔的表名列表来搜索整个 DBMS。 -D附带以逗号分隔的数据库名列表来搜索整个 DBMS。 例
sqlmap -u http://example.com/page?id1 --tables -D database_name --search your_search_term 以上的例子 -D 限制要搜索的数据库 --tables 列出限制数据库的所有表 --search : 根据后面的条件搜索符号条件的表并显示。 8、 自定义SQL --sql-querySQLQ.. SQL statement to be executed --sql-shell Prompt for an interactive SQL shell --sql-fileSQLFILE Execute SQL statements from given file(s)
参数解释--sql-querySQLQ指定要执行的SQL语句--sql-shell此开关是注入后进入SQL shell的--sql-fileSQLFILE从所给与的文件里执行SQL语句
9、 设置转储条件 --pivot-columnP.. Pivot column name --whereDUMPWHERE Use WHERE condition while table dumping --startLIMITSTART First dump table entry to retrieve --stopLIMITSTOP Last dump table entry to retrieve --firstFIRSTCHAR First query output word character to retrieve --lastLASTCHAR Last query output word character to retrieve
参数解释--pivot-columnP 设置主键名通常是自动选择 --whereDUMPWHERE 设置导出数据的条件用来限制范围 例如--whereid3 只有 id 值大于 3 的行会被获取 --startLIMITSTART指定要从哪条数据开始导出从索引0开始--stopLIMITSTOP指定在哪条数据停止导出。--firstFIRSTCHAR 导出的特定范围的字符设置字符开始 仅适用于盲注技术 --lastLASTCHAR 导出的特定范围的字符设置字符结束 仅适用于盲注技术
10、 指定参数 -D DB DBMS database to enumerate -T TBL DBMS database table(s) to enumerate -C COL DBMS database table column(s) to enumerate -X EXCLUDE DBMS database identifier(s) to not enumerate -U USER DBMS user to enumerate 指定参数可以使一些搜索操作缩小范围加快获取信息的效率减少没必要的请求。 参数解释-D DB指定数据库-T TBL指定表-C COL指定列-X EXCLUDE指定忽略的标识符-U USER指定用户名 参考资料:
sqlmap 用户手册 (highlight.ink)