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

Deserialize JSON into MDM Objects #9394

Closed
wants to merge 57 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+67 −0
Diff settings

Always

Just for now

Viewing a subset of changes. View all
@@ -15,6 +15,7 @@ module DataProxyAutoLoader
autoload :LootDataProxy, 'metasploit/framework/data_service/proxy/loot_data_proxy'
autoload :SessionEventDataProxy, 'metasploit/framework/data_service/proxy/session_event_data_proxy'
autoload :CredentialDataProxy, 'metasploit/framework/data_service/proxy/credential_data_proxy'
autoload :NmapDataProxy, 'metasploit/framework/data_service/proxy/nmap_data_proxy'
include ServiceDataProxy
include HostDataProxy
include VulnDataProxy
@@ -27,4 +28,5 @@ module DataProxyAutoLoader
include LootDataProxy
include SessionEventDataProxy
include CredentialDataProxy
include NmapDataProxy
end
@@ -0,0 +1,12 @@
module NmapDataProxy
def import_nmap_xml_file(args = {})
begin
data_service = self.get_data_service()
data_service.import_nmap_xml_file(args)
rescue Exception => e
puts "Call to #{data_service.class}#import_nmap_xml_file threw exception: #{e.message}"
e.backtrace { |line| puts "#{line}\n"}
end
end
end
@@ -14,6 +14,7 @@ module DataServiceAutoLoader
autoload :RemoteLootDataService, 'metasploit/framework/data_service/remote/http/remote_loot_data_service'
autoload :RemoteSessionEventDataService, 'metasploit/framework/data_service/remote/http/remote_session_event_data_service'
autoload :RemoteCredentialDataService, 'metasploit/framework/data_service/remote/http/remote_credential_data_service'
autoload :RemoteNmapDataService, 'metasploit/framework/data_service/remote/http/remote_nmap_data_service'
include RemoteHostDataService
include RemoteEventDataService
include RemoteNoteDataService
@@ -26,4 +27,5 @@ module DataServiceAutoLoader
include RemoteLootDataService
include RemoteSessionEventDataService
include RemoteCredentialDataService
include RemoteNmapDataService
end
@@ -0,0 +1,19 @@
require 'metasploit/framework/data_service/remote/http/response_data_helper'
module RemoteNmapDataService
include ResponseDataHelper
NMAP_PATH = '/api/1/msf/nmap'
def import_nmap_xml_file(opts)
filename = opts[:filename]
data = ""
File.open(filename, 'rb') do |f|
data = f.read(f.stat.size)
end
opts[:data] = Base64.urlsafe_encode64(data)
self.post_data_async(NMAP_PATH, opts)
end
end
@@ -0,0 +1,30 @@
module NmapServlet
def self.api_path
'/api/1/msf/nmap'
end
def self.registered(app)
app.post NmapServlet.api_path, &import_nmap_xml_file
end
#######
private
#######
def self.import_nmap_xml_file
lambda {
job = lambda { |opts|
nmap_file = opts[:filename].split('/').last
local_file = File.open(File.join(Msf::Config.local_directory, nmap_file), 'w')
local_file.write(Base64.urlsafe_decode64(opts[:data]))
local_file.close
opts[:filename] = File.expand_path(local_file)
get_db().import_nmap_xml_file(opts)
}
exec_report_job(request, &job)
}
end
end
@@ -14,6 +14,7 @@
require 'msf/core/db_manager/http/servlet/loot_servlet'
require 'msf/core/db_manager/http/servlet/session_event_servlet'
require 'msf/core/db_manager/http/servlet/credential_servlet'
require 'msf/core/db_manager/http/servlet/nmap_servlet'
class SinatraApp < Sinatra::Base
@@ -35,4 +36,5 @@ class SinatraApp < Sinatra::Base
register LootServlet
register SessionEventServlet
register CredentialServlet
register NmapServlet
end
ProTip! Use n and p to navigate between commits in a pull request.