Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mysql database? #19145

Open
FalcoGer opened this issue Apr 29, 2024 · 4 comments
Open

Use mysql database? #19145

FalcoGer opened this issue Apr 29, 2024 · 4 comments
Labels
question Questions about Metasploit Usage

Comments

@FalcoGer
Copy link

Summary

I run a lot of services, but only MSF requires a postgresql database. I would like to get rid of it to save on the memory, storage and cpu overhead and use the existing mysql database.

How do i switch from using a postgresql database to mysql? I wish to use an existing, remote database and not create a local one.

Relevant information

Suppose I have my database on server.lan (192.168.1.5), running on the default mysql port of tcp 3306. the username on that mysql server is is 'msf', the password is 'p4ssw0rd', the database is 'metasploitdb'.

I can not find information on these subjects:

  1. how to configure msf to use that remote server
  2. how to prevent msf from trying to create a local database in ~/.msf4/db/ (i have a workaround in place where i have an empty, normal file with permissions 000, but it throws an error every time i execute an msf command)
  3. how to create the relevant tables, keys, indexes and constraints on the remote mysql server's database

Whenever I look up anything remotely resembling this information I either get how to use the postgresql database (but not a remote one, only a local one) or how to attack or enumerate a remote mysql server, not how to use it as a datastore for msf.

If this is not possible, is there some alternative? Maybe some sort of compatibility layer that pretends to be a postgresql server but instead translates the queries to mysql and forwards them to a mysql server instead? I tried looking for something like that but came up only with database migration tools. The best I could find was the mysql_fdw plugin for postgresql, but if possible I'd like to eliminate postgres entirely.

@FalcoGer FalcoGer added the question Questions about Metasploit Usage label Apr 29, 2024
@adfoster-r7
Copy link
Contributor

There's no official support for MySQL as the database out of the box with Metasploit; you might be able to change the configuration file here and have it work: https://github.com/rapid7/metasploit-framework/blob/master/config/database.yml.example - which should be here ~/.msf4/database.yml

To run "remotely", the host field can be the IP of your target machine -

You might have to configure firewalls etc; you'll also need to run the database setup yourself. You might have to follow these steps too: bundle exec rake db:create db:migrate db:seed

@adfoster-r7
Copy link
Contributor

adfoster-r7 commented Apr 30, 2024

You can also run postgres remotely, via TCP - in the same vein as above

@FalcoGer
Copy link
Author

I did set the host value in database.yaml. And it does connect to the remote host, but still every time i start msfconsole or msfvenom it tries to initialize a local database in ~/.msf4/db. It's quite annoying.
I guess I'll just live with the error message.

@adfoster-r7
Copy link
Contributor

Pull requests are welcome 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Questions about Metasploit Usage
Projects
None yet
Development

No branches or pull requests

2 participants