Skip to content

Commit cfdda37

Browse files
committed
Send nmap file across the wire.
1 parent 9d00093 commit cfdda37

File tree

3 files changed

+20
-5
lines changed

3 files changed

+20
-5
lines changed

lib/metasploit/framework/data_service/proxy/data_proxy_auto_loader.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ module DataProxyAutoLoader
2828
include LootDataProxy
2929
include SessionEventDataProxy
3030
include CredentialDataProxy
31+
include NmapDataProxy
3132
end
Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
require 'metasploit/framework/data_service/remote/http/response_data_helper'
22

3-
module RemoteLootDataService
3+
module RemoteNmapDataService
44
include ResponseDataHelper
55

66
NMAP_PATH = '/api/1/msf/nmap'
77

8-
def import_nmap_xml_file(args)
9-
self.post_data_async(NMAP_PATH, args)
8+
def import_nmap_xml_file(opts)
9+
filename = opts[:filename]
10+
data = ""
11+
File.open(filename, 'rb') do |f|
12+
data = f.read(f.stat.size)
13+
end
14+
15+
opts[:data] = Base64.urlsafe_encode64(data)
16+
17+
self.post_data_async(NMAP_PATH, opts)
1018
end
1119
end

lib/msf/core/db_manager/http/servlet/nmap_servlet.rb

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
module nmapServlet
1+
module NmapServlet
22

33
def self.api_path
44
'/api/1/msf/nmap'
55
end
66

77
def self.registered(app)
8-
app.post nmapServlet.api_path, &import_nmap_xml_file
8+
app.post NmapServlet.api_path, &import_nmap_xml_file
99
end
1010

1111
#######
@@ -16,6 +16,12 @@ def self.import_nmap_xml_file
1616
lambda {
1717

1818
job = lambda { |opts|
19+
20+
nmap_file = opts[:filename].split('/').last
21+
local_file = File.open(File.join(Msf::Config.local_directory, nmap_file), 'w')
22+
local_file.write(Base64.urlsafe_decode64(opts[:data]))
23+
local_file.close
24+
opts[:filename] = File.expand_path(local_file)
1925
get_db().import_nmap_xml_file(opts)
2026
}
2127
exec_report_job(request, &job)

0 commit comments

Comments
 (0)