@@ -1594,11 +1594,19 @@ def cmd_db_nmap(*args)
1594
1594
print_status ( "Usage: db_nmap [nmap options]" )
1595
1595
return
1596
1596
end
1597
-
1597
+
1598
1598
save = false
1599
- if args . include? ( "save" )
1600
- save = active?
1601
- args . delete ( "save" )
1599
+ arguments = ''
1600
+ while ( arg = args . shift )
1601
+ case arg
1602
+ when 'save'
1603
+ save = active?
1604
+ when '--help' , '-h'
1605
+ cmd_db_nmap_help
1606
+ return
1607
+ else
1608
+ arguments << arg + ' '
1609
+ end
1602
1610
end
1603
1611
1604
1612
nmap =
@@ -1629,7 +1637,7 @@ def cmd_db_nmap(*args)
1629
1637
end
1630
1638
1631
1639
begin
1632
- nmap_pipe = ::Open3 ::popen3 ( [ nmap , "nmap" ] , * args )
1640
+ nmap_pipe = ::Open3 ::popen3 ( [ nmap , "nmap" ] , arguments )
1633
1641
temp_nmap_threads = [ ]
1634
1642
temp_nmap_threads << framework . threads . spawn ( "db_nmap-Stdout" , false , nmap_pipe [ 1 ] ) do |np_1 |
1635
1643
np_1 . each_line do |nmap_out |
@@ -1662,6 +1670,45 @@ def cmd_db_nmap(*args)
1662
1670
}
1663
1671
end
1664
1672
1673
+ def cmd_db_nmap_help
1674
+ nmap =
1675
+ Rex ::FileUtils . find_full_path ( 'nmap' ) ||
1676
+ Rex ::FileUtils . find_full_path ( 'nmap.exe' )
1677
+
1678
+ stdout , stderr = Open3 . capture3 ( [ nmap , 'nmap' ] , '--help' )
1679
+
1680
+ stdout . each_line do |out_line |
1681
+ next if out_line . strip . empty?
1682
+ print_status ( out_line . strip ) ;
1683
+ end
1684
+
1685
+ stderr . each_line do |err_line |
1686
+ next if err_line . strip . empty?
1687
+ print_error ( err_line . strip )
1688
+ end
1689
+ end
1690
+
1691
+ def cmd_db_nmap_tabs ( str , words )
1692
+ nmap =
1693
+ Rex ::FileUtils . find_full_path ( 'nmap' ) ||
1694
+ Rex ::FileUtils . find_full_path ( 'nmap.exe' )
1695
+
1696
+ stdout , stderr = Open3 . capture3 ( [ nmap , 'nmap' ] , '--help' )
1697
+ tabs = [ ]
1698
+ stdout . each_line do |out_line |
1699
+ if out_line . strip . starts_with? ( '-' )
1700
+ tabs . push ( out_line . strip . split ( ':' ) . first )
1701
+ end
1702
+ end
1703
+
1704
+ stderr . each_line do |err_line |
1705
+ next if err_line . strip . empty?
1706
+ print_error ( err_line . strip )
1707
+ end
1708
+
1709
+ return tabs
1710
+ end
1711
+
1665
1712
#
1666
1713
# Store some locally-generated data as a file, similiar to store_loot.
1667
1714
#
0 commit comments