@@ -1647,11 +1647,18 @@ def cmd_db_nmap(*args)
1647
1647
print_status ( "Usage: db_nmap [nmap options]" )
1648
1648
return
1649
1649
end
1650
-
1651
1650
save = false
1652
- if args . include? ( "save" )
1653
- save = active?
1654
- args . delete ( "save" )
1651
+ arguments = ''
1652
+ while ( arg = args . shift )
1653
+ case arg
1654
+ when 'save'
1655
+ save = active?
1656
+ when '--help' , '-h'
1657
+ cmd_db_nmap_help
1658
+ return
1659
+ else
1660
+ arguments << arg + ' '
1661
+ end
1655
1662
end
1656
1663
1657
1664
nmap =
@@ -1682,7 +1689,7 @@ def cmd_db_nmap(*args)
1682
1689
end
1683
1690
1684
1691
begin
1685
- nmap_pipe = ::Open3 ::popen3 ( [ nmap , " nmap" ] , * args )
1692
+ nmap_pipe = ::Open3 ::popen3 ( [ nmap , ' nmap' ] , arguments )
1686
1693
temp_nmap_threads = [ ]
1687
1694
temp_nmap_threads << framework . threads . spawn ( "db_nmap-Stdout" , false , nmap_pipe [ 1 ] ) do |np_1 |
1688
1695
np_1 . each_line do |nmap_out |
@@ -1715,6 +1722,45 @@ def cmd_db_nmap(*args)
1715
1722
}
1716
1723
end
1717
1724
1725
+ def cmd_db_nmap_help
1726
+ nmap =
1727
+ Rex ::FileUtils . find_full_path ( 'nmap' ) ||
1728
+ Rex ::FileUtils . find_full_path ( 'nmap.exe' )
1729
+
1730
+ stdout , stderr = Open3 . capture3 ( [ nmap , 'nmap' ] , '--help' )
1731
+
1732
+ stdout . each_line do |out_line |
1733
+ next if out_line . strip . empty?
1734
+ print_status ( out_line . strip ) ;
1735
+ end
1736
+
1737
+ stderr . each_line do |err_line |
1738
+ next if err_line . strip . empty?
1739
+ print_error ( err_line . strip )
1740
+ end
1741
+ end
1742
+
1743
+ def cmd_db_nmap_tabs ( str , words )
1744
+ nmap =
1745
+ Rex ::FileUtils . find_full_path ( 'nmap' ) ||
1746
+ Rex ::FileUtils . find_full_path ( 'nmap.exe' )
1747
+
1748
+ stdout , stderr = Open3 . capture3 ( [ nmap , 'nmap' ] , '--help' )
1749
+ tabs = [ ]
1750
+ stdout . each_line do |out_line |
1751
+ if out_line . strip . starts_with? ( '-' )
1752
+ tabs . push ( out_line . strip . split ( ':' ) . first )
1753
+ end
1754
+ end
1755
+
1756
+ stderr . each_line do |err_line |
1757
+ next if err_line . strip . empty?
1758
+ print_error ( err_line . strip )
1759
+ end
1760
+
1761
+ tabs
1762
+ end
1763
+
1718
1764
#
1719
1765
# Store some locally-generated data as a file, similiar to store_loot.
1720
1766
#
0 commit comments