Last active
August 29, 2015 14:11
-
-
Save trosen-r7/c24bf4d2c15e0ba1bf37 to your computer and use it in GitHub Desktop.
Getting WebForm information from Metasploit given a Workspace name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'yaml' | |
require 'metasploit_data_models' | |
PATH_TO_DB_FILE = '/opt/metasploit/apps/pro/ui/config/database.yml' | |
connection_hash = YAML.load_file(PATH_TO_DB_FILE) | |
ActiveRecord::Base.establish_connection(connection_hash['production']) | |
workspace_name = ARGV[0] | |
# WebForm | |
#sql =<<-EOS | |
#select * from web_forms | |
#inner join web_sites on web_sites.id = web_forms.web_site_id | |
#inner join services on services.id = web_sites.service_id | |
#inner join hosts on hosts.id = services.host_id | |
#inner join workspaces on workspaces.id = hosts.workspace_id | |
#where workspaces.name = '#{workspace_name}'; | |
#EOS | |
# WebPage | |
#sql =<<-EOS | |
#select * from web_pages | |
#inner join web_sites on web_sites.id = web_pages.web_site_id | |
#inner join services on services.id = web_sites.service_id | |
#inner join hosts on hosts.id = services.host_id | |
#inner join workspaces on workspaces.id = hosts.workspace_id | |
#where workspaces.name = '#{workspace_name}'; | |
#EOS | |
# WebSite | |
sql =<<-EOS | |
select * from web_sites | |
inner join services on services.id = web_sites.service_id | |
inner join hosts on hosts.id = services.host_id | |
inner join workspaces on workspaces.id = hosts.workspace_id | |
where workspaces.name = '#{workspace_name}'; | |
EOS | |
results = ActiveRecord::Base.connection.execute(sql) | |
p results.first | |
# | |
# Make RPC call from here w/ DS_URLS set to computed strings from results | |
# |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment