Skip to content

Commit 9d00093

Browse files
committed
Initial commit for nmap proxying
1 parent d63b087 commit 9d00093

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
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
@@ -15,6 +15,7 @@ module DataProxyAutoLoader
1515
autoload :LootDataProxy, 'metasploit/framework/data_service/proxy/loot_data_proxy'
1616
autoload :SessionEventDataProxy, 'metasploit/framework/data_service/proxy/session_event_data_proxy'
1717
autoload :CredentialDataProxy, 'metasploit/framework/data_service/proxy/credential_data_proxy'
18+
autoload :NmapDataProxy, 'metasploit/framework/data_service/proxy/nmap_data_proxy'
1819
include ServiceDataProxy
1920
include HostDataProxy
2021
include VulnDataProxy
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
module NmapDataProxy
2+
3+
def import_nmap_xml_file(args = {})
4+
begin
5+
data_service = self.get_data_service()
6+
data_service.import_nmap_xml_file(args)
7+
rescue Exception => e
8+
puts "Call to #{data_service.class}#import_nmap_xml_file threw exception: #{e.message}"
9+
e.backtrace { |line| puts "#{line}\n"}
10+
end
11+
end
12+
end

lib/metasploit/framework/data_service/remote/http/data_service_auto_loader.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ module DataServiceAutoLoader
1414
autoload :RemoteLootDataService, 'metasploit/framework/data_service/remote/http/remote_loot_data_service'
1515
autoload :RemoteSessionEventDataService, 'metasploit/framework/data_service/remote/http/remote_session_event_data_service'
1616
autoload :RemoteCredentialDataService, 'metasploit/framework/data_service/remote/http/remote_credential_data_service'
17+
autoload :RemoteNmapDataService, 'metasploit/framework/data_service/remote/http/remote_nmap_data_service'
1718
include RemoteHostDataService
1819
include RemoteEventDataService
1920
include RemoteNoteDataService
@@ -26,4 +27,5 @@ module DataServiceAutoLoader
2627
include RemoteLootDataService
2728
include RemoteSessionEventDataService
2829
include RemoteCredentialDataService
30+
include RemoteNmapDataService
2931
end
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
require 'metasploit/framework/data_service/remote/http/response_data_helper'
2+
3+
module RemoteLootDataService
4+
include ResponseDataHelper
5+
6+
NMAP_PATH = '/api/1/msf/nmap'
7+
8+
def import_nmap_xml_file(args)
9+
self.post_data_async(NMAP_PATH, args)
10+
end
11+
end
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module nmapServlet
2+
3+
def self.api_path
4+
'/api/1/msf/nmap'
5+
end
6+
7+
def self.registered(app)
8+
app.post nmapServlet.api_path, &import_nmap_xml_file
9+
end
10+
11+
#######
12+
private
13+
#######
14+
15+
def self.import_nmap_xml_file
16+
lambda {
17+
18+
job = lambda { |opts|
19+
get_db().import_nmap_xml_file(opts)
20+
}
21+
exec_report_job(request, &job)
22+
}
23+
end
24+
end

lib/msf/core/db_manager/http/sinatra_app.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
require 'msf/core/db_manager/http/servlet/loot_servlet'
1515
require 'msf/core/db_manager/http/servlet/session_event_servlet'
1616
require 'msf/core/db_manager/http/servlet/credential_servlet'
17+
require 'msf/core/db_manager/http/servlet/nmap_servlet'
1718

1819
class SinatraApp < Sinatra::Base
1920

@@ -35,4 +36,5 @@ class SinatraApp < Sinatra::Base
3536
register LootServlet
3637
register SessionEventServlet
3738
register CredentialServlet
39+
register NmapServlet
3840
end

0 commit comments

Comments
 (0)