Skip to content

Commit 548a710

Browse files
author
RageLtMan
committed
Replace db_nmap string concat with an Array
16eab48 introduced changes to cmd_db_nmap which pass a new arguments variable to Open3 with a list of args excluding save. This approach created a problem wherein the address of the target had to be passed in first and arguments could get mangled. Reintroduce an array format, exploding when passing to Open3. Ensure output file options are appended to the arguments being passed to Open3, instead of the args variable. Error example: db_nmap -F 192.168.0.1 [*] Nmap: 'nmap: unrecognized option '- 192.168.0.1 ''
1 parent 9fadc39 commit 548a710

File tree

1 file changed

+7
-7
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+7
-7
lines changed

lib/msf/ui/console/command_dispatcher/db.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1740,7 +1740,7 @@ def cmd_db_nmap(*args)
17401740
return
17411741
end
17421742
save = false
1743-
arguments = ''
1743+
arguments = []
17441744
while (arg = args.shift)
17451745
case arg
17461746
when 'save'
@@ -1749,7 +1749,7 @@ def cmd_db_nmap(*args)
17491749
cmd_db_nmap_help
17501750
return
17511751
else
1752-
arguments << arg + ' '
1752+
arguments << arg
17531753
end
17541754
end
17551755

@@ -1773,15 +1773,15 @@ def cmd_db_nmap(*args)
17731773
# Custom function needed because cygpath breaks on 8.3 dirs
17741774
tout = Rex::Compat.cygwin_to_win32(fd.path)
17751775
fout = Rex::Compat.cygwin_to_win32(fo.path)
1776-
args.push('-oX', tout)
1777-
args.push('-oN', fout)
1776+
arguments.push('-oX', tout)
1777+
arguments.push('-oN', fout)
17781778
else
1779-
args.push('-oX', fd.path)
1780-
args.push('-oN', fo.path)
1779+
arguments.push('-oX', fd.path)
1780+
arguments.push('-oN', fo.path)
17811781
end
17821782

17831783
begin
1784-
nmap_pipe = ::Open3::popen3([nmap, 'nmap'], arguments)
1784+
nmap_pipe = ::Open3::popen3([nmap, 'nmap'], *arguments)
17851785
temp_nmap_threads = []
17861786
temp_nmap_threads << framework.threads.spawn("db_nmap-Stdout", false, nmap_pipe[1]) do |np_1|
17871787
np_1.each_line do |nmap_out|

0 commit comments

Comments
 (0)