rapid7 / metasploit-framework

Metasploit Framework
https://www.metasploit.com/
Other
33.77k stars 13.89k forks source link

framework.db.import issue with remote data service #11988

Open mkienow-r7 opened 5 years ago

mkienow-r7 commented 5 years ago

Steps to reproduce

Calls to framework.db.import will fail when using the remote data service since the DbImportDataProxy module has both import and import_file methods, however, the RemoteDbImportDataService module only exposes a import_file method.

Expected behavior

The calling code operates without issue.

Current behavior

The import calling code results in an error. This can be seen in the ~/.msf4/logs/framework.log log file.

[06/17/2019 16:52:21] [e(0)] core: Problem generating DB Import: undefined method `import' for #<Metasploit::Framework::DataService::RemoteHTTPDataService:0x00007ff1735c0d98>
Did you mean?  import_file
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/metasploit/framework/data_service/proxy/db_import_data_proxy.rb:6:in `block in import'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:166:in `data_service_operation'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/metasploit/framework/data_service/proxy/db_import_data_proxy.rb:4:in `import'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/plugins/openvas.rb:530:in `cmd_openvas_report_import'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/rex/ui/text/shell.rb:151:in `run'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
[06/17/2019 16:52:21] [e(0)] core: /home/msfdev/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
[06/17/2019 16:52:21] [e(0)] core: ./msfconsole:49:in `<main>'

System stuff

Metasploit version

msf5 > version
Framework: 5.0.30-dev-eb8e0e238d
Console  : 5.0.30-dev-eb8e0e238d

I installed Metasploit with:

OS

macOS

mkienow-r7 commented 5 years ago

Runtime issue has not been verified, however, the following modules would be means of triggering the issue since they make calls to the framework.db.import method.

lib/msf/core/rpc/v10/rpc_db.rb
plugins/nessus.rb
plugins/nexpose.rb
plugins/nexpose.rb
plugins/openvas.rb
FalcoGer commented 5 years ago

i can confirm that openvas_report_import does not work with the following error:

msf5 > openvas_report_import a5999e31-9ff6-4ad8-9e38-ed2f92a4a4fa a994b278-1f62-11e1-96ac-406186ea4fc5
[*] Importing report to database.
[-] Error while running command openvas_report_import: undefined method `import' for #<Metasploit::Framework::DataService::RemoteHTTPDataService:0x00005586181a8e40>
Did you mean?  import_file

Call stack:
/opt/metasploit-framework/lib/metasploit/framework/data_service/proxy/db_import_data_proxy.rb:6:in `block in import'
/opt/metasploit-framework/lib/metasploit/framework/data_service/proxy/core.rb:166:in `data_service_operation'
/opt/metasploit-framework/lib/metasploit/framework/data_service/proxy/db_import_data_proxy.rb:4:in `import'
/opt/metasploit-framework/plugins/openvas.rb:528:in `cmd_openvas_report_import'
/opt/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:523:in `run_command'
/opt/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:474:in `block in run_single'
/opt/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `each'
/opt/metasploit-framework/lib/rex/ui/text/dispatcher_shell.rb:468:in `run_single'
/opt/metasploit-framework/lib/rex/ui/text/shell.rb:151:in `run'
/opt/metasploit-framework/lib/metasploit/framework/command/console.rb:48:in `start'
/opt/metasploit-framework/lib/metasploit/framework/command/base.rb:82:in `start'
/usr/local/bin/msfconsole:49:in `<main>'
msf5 > version
Framework: 5.0.43-dev-9ea327ecdd
Console  : 5.0.43-dev-9ea327ecdd

Remarks: I edited ~/.rbenv/versions/2.6.2/lib/ruby/gems/2.6.0/gems/openvas-omp-0.0.4/lib/openvas-omp.rb to get rid of the Object#timeout is depreciated use Timeout.timeout instead message.
The error occured before then, too.

mkienow-r7 commented 5 years ago

@FalcoGer Thank you for the confirmation

kolyan-skalny commented 4 years ago

The same error on MacOS version [] Generating the export data file... [] Downloading the export data... [*] Importing Nexpose data... [-] Error while running command nexpose_site_import: undefined method `import' for # Did you mean? import_file

Call stack: /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/data_service/proxy/db_import_data_proxy.rb:6:in block in import' /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/data_service/proxy/core.rb:166:indata_service_operation' /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/data_service/proxy/db_import_data_proxy.rb:4:in import' /opt/metasploit-framework/embedded/framework/plugins/nexpose.rb:611:inprocess_nexpose_data' /opt/metasploit-framework/embedded/framework/plugins/nexpose.rb:334:in cmd_nexpose_site_import' /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:523:inrun_command' /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:474:in block in run_single' /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:468:ineach' /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/dispatcher_shell.rb:468:in run_single' /opt/metasploit-framework/embedded/framework/lib/rex/ui/text/shell.rb:158:inrun' /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/console.rb:48:in start' /opt/metasploit-framework/embedded/framework/lib/metasploit/framework/command/base.rb:82:instart' /opt/metasploit-framework/bin/../embedded/framework/msfconsole:49:in `

'

msf5 > version Framework: 5.0.72-dev-0fc1a9ee5fd328bf490bf5b5d893826f381378e6 Console : 5.0.72-dev-0fc1a9ee5fd328bf490bf5b5d893826f381378e6

github-actions[bot] commented 3 years ago

Hi!

This issue has been left open with no activity for a while now.

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 30 days since the last update here. If we missed this issue or if you want to keep it open, please reply here. You can also add the label "not stale" to keep this issue open!

As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request.