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

Update call to deprecated connection_config #15735

Merged
merged 1 commit into from
Oct 4, 2021

Conversation

jaydesl
Copy link
Contributor

@jaydesl jaydesl commented Oct 2, 2021

Updates the call to fetch the DB configuration hash in db_connector.rb as it is being deprecated in Rails 6.2

Fixes #15715

Verification

List the steps needed to make sure this thing works

  • run msfdb --init
  • start msfconsole
  • type db_disconnect
  • see no deprecation warnings

@gwillcox-r7
Copy link
Contributor

Before patch:

 ~/git/metasploit-framework │ master *1 ?34  ./msfdb init                                                    ✔ │ 6s │ 2.7.2 Ruby 
[?] Would you like to init the webservice? (Not Required) [no]: yes
====================================================================
Running the 'init' command for the database:
Creating database at /home/gwillcox/.msf4/db
Starting database at /home/gwillcox/.msf4/db...success
Creating database users
Writing client authentication configuration file /home/gwillcox/.msf4/db/pg_hba.conf
Stopping database at /home/gwillcox/.msf4/db
Starting database at /home/gwillcox/.msf4/db...success
Creating initial database schema
====================================================================

====================================================================
Running the 'init' command for the webservice:
[?] Initial MSF web service account username? [gwillcox]: 
[?] Initial MSF web service account password? (Leave blank for random password): 
Generating SSL key and certificate for MSF web service
Attempting to start MSF web service...success
MSF web service started and online
Creating MSF web service user gwillcox

*redacted*

MSF web service configuration complete
The web service has been configured as your default data service in msfconsole with the name "local-https-data-service"

If needed, manually reconnect to the data service in msfconsole using the command:
*redacted*

The username and password are credentials for the API account:
https://localhost:5443/api/v1/auth/account

Persisting http web data service credentials in msfconsole
====================================================================

 ~/git/metasploit-framework │ master *1 ?34  ./msfconsole                                                   ✔ │ 31s │ 2.7.2 Ruby 
                                                  

 ______________________________________________________________________________
|                                                                              |
|                   METASPLOIT CYBER MISSILE COMMAND V5                        |
|______________________________________________________________________________|
      \                                  /                      /
       \     .                          /                      /            x
        \                              /                      /
         \                            /          +           /
          \            +             /                      /
           *                        /                      /
                                   /      .               /
    X                             /                      /            X
                                 /                     ###
                                /                     # % #
                               /                       ###
                      .       /
     .                       /      .            *           .
                            /
                           *
                  +                       *

                                       ^
####      __     __     __          #######         __     __     __        ####
####    /    \ /    \ /    \      ###########     /    \ /    \ /    \      ####
################################################################################
################################################################################
# WAVE 5 ######## SCORE 31337 ################################## HIGH FFFFFFFF #
################################################################################
                                                           https://metasploit.com


       =[ metasploit v6.1.9-dev-2881adff04                ]
+ -- --=[ 2168 exploits - 1149 auxiliary - 397 post       ]
+ -- --=[ 596 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: Tired of setting RHOSTS for modules? Try 
globally setting it with setg RHOSTS x.x.x.x

msf6 payload(windows/x64/meterpreter/reverse_tcp) > back
msf6 > db_disconnect
DEPRECATION WARNING: connection_config is deprecated and will be removed from Rails 6.2 (Use connection_db_config instead) (called from build_postgres_url at /home/gwillcox/git/metasploit-framework/lib/msf/core/db_connector.rb:260)
Successfully disconnected from the data service: remote_data_service: (https://localhost:5443).
msf6 > 

@gwillcox-r7
Copy link
Contributor

After Patch:

 ~/git/metasploit-framework │ @6d2d680b *1 ?34  git checkout upstream/pr/15735 -b land-pr15735                    ✔ │ 2.7.2 Ruby 
Branch 'land-pr15735' set up to track remote branch 'pr/15735' from 'upstream'.
Switched to a new branch 'land-pr15735'
 ~/git/metasploit-framework │ land-pr15735:pr/15735 *1 ?34  ./msfconsole                                          ✔ │ 2.7.2 Ruby 
                                                  

      .:okOOOkdc'           'cdkOOOko:.
    .xOOOOOOOOOOOOc       cOOOOOOOOOOOOx.
   :OOOOOOOOOOOOOOOk,   ,kOOOOOOOOOOOOOOO:
  'OOOOOOOOOkkkkOOOOO: :OOOOOOOOOOOOOOOOOO'
  oOOOOOOOO.    .oOOOOoOOOOl.    ,OOOOOOOOo
  dOOOOOOOO.      .cOOOOOc.      ,OOOOOOOOx
  lOOOOOOOO.         ;d;         ,OOOOOOOOl
  .OOOOOOOO.   .;           ;    ,OOOOOOOO.
   cOOOOOOO.   .OOc.     'oOO.   ,OOOOOOOc
    oOOOOOO.   .OOOO.   :OOOO.   ,OOOOOOo
     lOOOOO.   .OOOO.   :OOOO.   ,OOOOOl
      ;OOOO'   .OOOO.   :OOOO.   ;OOOO;
       .dOOo   .OOOOocccxOOOO.   xOOd.
         ,kOl  .OOOOOOOOOOOOO. .dOk,
           :kk;.OOOOOOOOOOOOO.cOk:
             ;kOOOOOOOOOOOOOOOk:
               ,xOOOOOOOOOOOx,
                 .lOOOOOOOl.
                    ,dOd,
                      .

       =[ metasploit v6.1.9-dev-6d2d680b5b                ]
+ -- --=[ 2168 exploits - 1149 auxiliary - 397 post       ]
+ -- --=[ 596 payloads - 45 encoders - 10 nops            ]
+ -- --=[ 9 evasion                                       ]

Metasploit tip: View missing module options with show 
missing

msf6 payload(windows/x64/meterpreter/reverse_tcp) > back
msf6 > db_disconnect
Successfully disconnected from the data service: remote_data_service: (https://localhost:5443).
msf6 > 

@gwillcox-r7
Copy link
Contributor

This looks good to me and based on there being similar changes by Jeffery in the past and Alan recommending his change which is very similar to this one, combined with testing which shows this works as expected, I'm comfortable going ahead and landing this. If this does by some small chance break something then let me know, but I highly doubt it should.

@gwillcox-r7 gwillcox-r7 merged commit 6541b85 into rapid7:master Oct 4, 2021
@gwillcox-r7 gwillcox-r7 added the rn-enhancement release notes enhancement label Oct 4, 2021
@gwillcox-r7
Copy link
Contributor

gwillcox-r7 commented Oct 4, 2021

Release Notes

Fixes a Rails 6 deprecation warning when a user ran db_disconnect in msfconsole

@gwillcox-r7
Copy link
Contributor

gwillcox-r7 commented Oct 4, 2021

Thanks for the PR @jaydesl! Since it is HacktoberFest, I also marked your PR as a valid submission for HacktoberFest 👍 Appreciate your work fixing this issue, and congrats on your first MSF PR 🥳

@adfoster-r7
Copy link
Contributor

@gwillcox-r7 I've updated the release notes to change depreciation to deprecation 👍

@jaydesl
Copy link
Contributor Author

jaydesl commented Oct 16, 2021

Thanks for the merge! MSF is such a great toolkit I am happy to contribute :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

connection_config is deprecated
3 participants