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.
+20 −5
Diff settings

Always

Just for now

Viewing a subset of changes. View all

Send nmap file across the wire.

  • Loading branch information...
jbarnett-r7 committed Oct 31, 2017
commit cfdda37f628a2350d18517bbba1b4bea530fef32
@@ -28,4 +28,5 @@ module DataProxyAutoLoader
include LootDataProxy
include SessionEventDataProxy
include CredentialDataProxy
include NmapDataProxy
end
@@ -1,11 +1,19 @@
require 'metasploit/framework/data_service/remote/http/response_data_helper'
module RemoteLootDataService
module RemoteNmapDataService
include ResponseDataHelper
NMAP_PATH = '/api/1/msf/nmap'
def import_nmap_xml_file(args)
self.post_data_async(NMAP_PATH, args)
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
@@ -1,11 +1,11 @@
module nmapServlet
module NmapServlet
def self.api_path
'/api/1/msf/nmap'
end
def self.registered(app)
app.post nmapServlet.api_path, &import_nmap_xml_file
app.post NmapServlet.api_path, &import_nmap_xml_file
end
#######
@@ -16,6 +16,12 @@ 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)
ProTip! Use n and p to navigate between commits in a pull request.