Skip to content

Commit 636d1a5

Browse files
committed
fix rapid7#8921, fix crash on nmap tab completion
1 parent bcfab11 commit 636d1a5

File tree

1 file changed

+15
-11
lines changed
  • lib/msf/ui/console/command_dispatcher

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1499,6 +1499,10 @@ def cmd_db_export(*args)
14991499
}
15001500
end
15011501

1502+
def find_nmap_path
1503+
Rex::FileUtils.find_full_path("nmap") || Rex::FileUtils.find_full_path("nmap.exe")
1504+
end
1505+
15021506
#
15031507
# Import Nmap data from a file
15041508
#
@@ -1524,11 +1528,8 @@ def cmd_db_nmap(*args)
15241528
end
15251529
end
15261530

1527-
nmap =
1528-
Rex::FileUtils.find_full_path("nmap") ||
1529-
Rex::FileUtils.find_full_path("nmap.exe")
1530-
1531-
if (not nmap)
1531+
nmap = find_nmap_path
1532+
unless nmap
15321533
print_error("The nmap executable could not be found")
15331534
return
15341535
end
@@ -1578,9 +1579,11 @@ def cmd_db_nmap(*args)
15781579
end
15791580

15801581
def cmd_db_nmap_help
1581-
nmap =
1582-
Rex::FileUtils.find_full_path('nmap') ||
1583-
Rex::FileUtils.find_full_path('nmap.exe')
1582+
nmap = find_nmap_path
1583+
unless nmap
1584+
print_error("The nmap executable could not be found")
1585+
return
1586+
end
15841587

15851588
stdout, stderr = Open3.capture3([nmap, 'nmap'], '--help')
15861589

@@ -1596,9 +1599,10 @@ def cmd_db_nmap_help
15961599
end
15971600

15981601
def cmd_db_nmap_tabs(str, words)
1599-
nmap =
1600-
Rex::FileUtils.find_full_path('nmap') ||
1601-
Rex::FileUtils.find_full_path('nmap.exe')
1602+
nmap = find_nmap_path
1603+
unless nmap
1604+
return
1605+
end
16021606

16031607
stdout, stderr = Open3.capture3([nmap, 'nmap'], '--help')
16041608
tabs = []

0 commit comments

Comments
 (0)