Results 1 to 5 of 5

Thread: Unable to start Postgresql so I can run Metasploit

  1. #1

    Unable to start Postgresql so I can run Metasploit

    Hello,
    After searching various threads here on how to get Posgresql running, I am still having no luck

    As root or using sudo to service postgresql start the command seems to execute and then I am back in my shell prompt.

    Some articles said to run ss -ant to see if postgres is listening, but no reply. I tried ss -lntp | grep port expecting to see the ports listening but no joy.

    I did a apt-get dist-upgrade and rebooted and tried again, no joy.

    Tried logging in to msfconsole to see this:
    ~$ sudo msfconsole
    [-] Failed to connect to the database: could not connect to server: Connection refused
    Is the server running on host "localhost" (::1) and accepting
    TCP/IP connections on port 5432?
    could not connect to server: Connection refused
    Is the server running on host "localhost" (127.0.0.1) and accepting
    TCP/IP connections on port 5432?

    then: msf > db_status[*] postgresql selected, no connection

    then:
    msf > db_connect postgresql
    msf > db_status[*] postgresql selected, no connection

    I tried also connecting pointing to the database.yml file to no end.

    Where did I go wrong?
    Thanks!

  2. #2
    Right, I run that command to start postgresql and then when I run the ss -ant this is what I get:

    $ sudo service postgresql start
    [sudo] password for me:
    me@Kali:~$
    me@Kali:~$ ss -ant
    State Recv-Q Send-Q Local Address:Port Peer Address:Port
    dave@daveKali:~$

    So something is wrong with postgres not starting.

    Should I uninstall and reinstall?

    I saw a forum post about checking the config file to verify that posgresql was running on 5432 and it is.

    Would a recent dist-upgrade reset all config files back to examples? I saw some examples but no config files in
    me@Kali:/usr/share/postgresql/10$ ls
    catalog_version pg_ident.conf.sample recovery.conf.sample
    contrib pg_service.conf.sample snowball_create.sql
    conversion_create.sql postgres.bki sql_features.txt
    extension postgres.description system_views.sql
    information_schema.sql postgresql.conf.sample timezonesets
    man postgres.shdescription tsearch_data
    pg_hba.conf.sample psqlrc.sample

    /etc/postgresql/10/main/postgresql.conf

    What do I need to do to get postgresql 10 started?

  3. #3
    Hi,
    Let me ask this:
    If using your command from your first reply:
    "service postgresql start"
    and then checking it with ss -ant shows nothing, then what can we do to get postgresql running. I can start msfconsole no issue, just no db connection.

    Should I remove and reinstall postgresql before metasploit?

    *edit* and as this is Posgresql 10, could that be an issue?

  4. #4
    *Solved*

    I did some digging and found that I should try to use systemctl to start posgresql.

    This showed me this line:
    postgresql@10-main loaded failed failed PostgreSQL Cluster 10-main

    So I then ran
    sudo systemctl start postgresql@10-main
    Job for [email protected] failed because the service did not take the steps required by its unit configuration.
    See "systemctl status [email protected]" and "journalctl -xe" for details.
    me@Kali:/$ sudo systemctl status postgresql@10-main
    [email protected] - PostgreSQL Cluster 10-main
    Loaded: loaded (/lib/systemd/system/[email protected]; indirect; vendor preset: disabled)
    Drop-In: /lib/systemd/system/[email protected]
    └─kali_postgresql.conf
    Active: failed (Result: protocol) since Fri 2018-02-02 12:44:10 MST; 17s ago
    Process: 4217 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 10-main start (code=exited, status=1/FAILURE)
    Process: 4215 ExecStartPre=/usr/share/kali-defaults/postgresql_reduce_shared_buffers 10/main (code=exited, status=0/SUCCESS)

    Feb 02 12:44:10 Kali postgresql@10-main[4217]: 2018-02-02 19:44:10.816 UTC [4222] LOG: listening on IPv4 address "127.0.0.1", port 5432
    Feb 02 12:44:10 Kali postgresql@10-main[4217]: 2018-02-02 19:44:10.818 UTC [4222] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
    Feb 02 12:44:10 Kali postgresql@10-main[4217]: 2018-02-02 19:44:10.838 UTC [4222] LOG: could not open configuration file "/etc/postgresql/10/main/pg_hba.conf": Permission denied
    Feb 02 12:44:10 Kali postgresql@10-main[4217]: 2018-02-02 19:44:10.838 UTC [4222] FATAL: could not load pg_hba.conf
    Feb 02 12:44:10 Kali postgresql@10-main[4217]: 2018-02-02 19:44:10.839 UTC [4222] LOG: database system is shut down
    Feb 02 12:44:10 Kali postgresql@10-main[4217]: pg_ctl: could not start server
    Feb 02 12:44:10 Kali postgresql@10-main[4217]: Examine the log output.
    Feb 02 12:44:10 Kali systemd[1]: [email protected]: PID file /var/run/postgresql/10-main.pid not readable (yet?) after start: No such file or directory
    Feb 02 12:44:10 Kali systemd[1]: [email protected]: Failed with result 'protocol'.
    Feb 02 12:44:10 Kali systemd[1]: Failed to start PostgreSQL Cluster 10-main.

    That led me to do these steps:

    root@daveKali:/var/run/postgresql/10-main.pg_stat_tmp# chmod 664 /etc/postgresql/10/main/pg_hba.conf
    root@daveKali:/var/run/postgresql/10-main.pg_stat_tmp# systemctl start postgresql@10-main
    root@daveKali:/var/run/postgresql/10-main.pg_stat_tmp# systemctl status postgresql
    ● postgresql.service - PostgreSQL RDBMS
    Loaded: loaded (/lib/systemd/system/postgresql.service; disabled; vendor preset: disabled)
    Active: active (exited) since Fri 2018-02-02 12:28:31 MST; 19min ago
    Process: 4160 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
    Main PID: 4160 (code=exited, status=0/SUCCESS)

    Feb 02 12:28:31 daveKali systemd[1]: Starting PostgreSQL RDBMS...
    Feb 02 12:28:31 daveKali systemd[1]: Started PostgreSQL RDBMS.
    root@daveKali:/var/run/postgresql/10-main.pg_stat_tmp# ss -lntp | grep post
    LISTEN 0 128 127.0.0.1:5432 0.0.0.0:* users("postgres",pid=4309,fd=6))
    LISTEN 0 128 [::1]:5432 [::]:* users("postgres",pid=4309,fd=3))
    root@daveKali:/var/run/postgresql/10-main.pg_stat_tmp#

    So now Postgresql is up and running.

    Ran a msfdb reinit and msfconsole came up no errors.

    Thanks!

  5. #5
    Join Date
    2016-Oct
    Location
    /dev/sda
    Posts
    1,012
    #/etc/init.d/postgresql
    service --status-all
    service postgresql start
    service postgresql status

    #/usr/bin/msfconsole
    msfdb init
    msfconsole
    msf > db_status

Similar Threads

  1. Postgresql and Metasploit
    By Noob123 in forum NetHunter General Questions
    Replies: 9
    Last Post: 2015-08-23, 14:17
  2. Metasploit and Postgresql Doesn't start
    By Blkzer0 in forum NetHunter General Questions
    Replies: 5
    Last Post: 2015-06-17, 18:40
  3. metasploit and postgresql help
    By Lordx19 in forum TroubleShooting Archive
    Replies: 18
    Last Post: 2014-03-04, 14:00

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •