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

Add DB Stats Command to Console #18373

Merged
merged 5 commits into from Oct 24, 2023
Merged

Add DB Stats Command to Console #18373

merged 5 commits into from Oct 24, 2023

Conversation

h00die
Copy link
Contributor

@h00die h00die commented Sep 15, 2023

fix #13136

@leebaird 3yrs later :)

This PR adds a db_stats command which gives the user information about how much data is in their database/workspace. It is very similar to debug --database, in fact borrowing some code from there, however this prints in console friendly format instead of markdown. I've also added some quick calculations for services/host, and vulns/host.

image

Verification

  • Start msfconsole
  • have some hosts/vulns/services/notes/creds/kerberos_tickets in workspaces
  • Verify db_stats prints out a friendly formatted table with the information

@h00die
Copy link
Contributor Author

h00die commented Sep 18, 2023

now with creds and kerberos ticket counts!

@cdelafuente-r7 cdelafuente-r7 self-assigned this Sep 19, 2023
@h00die
Copy link
Contributor Author

h00die commented Sep 19, 2023

@cdelafuente-r7 right now the code loops through counts for each field when populating the workspace rows. Later it does a request for all counts, which in theory isn't needed as the numbers could be totaled up from before and stored. Save a few DB queries, thoughts? This is already partially done since just thought it may be good to expand it.

@cdelafuente-r7
Copy link
Contributor

@h00die, yes absolutely, I think it is a good idea.

@h00die
Copy link
Contributor Author

h00die commented Sep 20, 2023

There seems to be a bug in the tickets_search function, when it calls tickets the workspace filter isn't being applied, it simply defaults to whatever workspace you are currently in. @dwelch-r7 can you check on that since you wrote that code?

@dwelch-r7
Copy link
Contributor

There seems to be a bug in the tickets_search function, when it calls tickets the workspace filter isn't being applied, it simply defaults to whatever workspace you are currently in. @dwelch-r7 can you check on that since you wrote that code?

Thanks for calling this out, this PR here #18400 should sort it

@cdelafuente-r7
Copy link
Contributor

Thank you @dwelch-r7 and @h00die for working on this issue. The related PR is now landed.

@h00die, would you mind rebasing your branch? When it's done, I'll do a last batch of test and land it. Thanks!

@h00die
Copy link
Contributor Author

h00die commented Oct 23, 2023

rebased

@cdelafuente-r7
Copy link
Contributor

Thanks @h00die ! Everything looks good to me. I'll go ahead and land it.

Example output

msf6 > db_stats
Session Type: Connected to msf. Connection type: postgresql.
Database Stats
==============

      ID     Name     Hosts  Services  Services per Host  Vulnerabilities  Vulns per Host  Notes  Creds  Kerberos Cache
      --     ----     -----  --------  -----------------  ---------------  --------------  -----  -----  --------------
  =>  1      default  11     4         0.36               7                0.63            45     123    2
      2      test     3      0         0.0                0                0.0             0      0      3
      Total  2        14     4         0.28               7                0.5             45     123    5

@cdelafuente-r7 cdelafuente-r7 added the rn-enhancement release notes enhancement label Oct 24, 2023
@cdelafuente-r7 cdelafuente-r7 merged commit 59c277b into rapid7:master Oct 24, 2023
35 checks passed
@cdelafuente-r7
Copy link
Contributor

Release Notes

This adds a db_stats command which gives the user information about how much data is in their database/workspace.

@h00die h00die deleted the db_stats branch October 24, 2023 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Database stats
4 participants