Land #12314, Clarify file: handling with the RHOSTS parameter
This commit is contained in:
commit
75c58d39a9
|
@ -25,5 +25,5 @@ msf <%= mod.type %>(<%= mod.shortname %>) > set RHOSTS 192.168.1.1/24
|
|||
Example 3:
|
||||
|
||||
```
|
||||
msf <%= mod.type %>(<%= mod.shortname %>) > set RHOSTS file:///tmp/ip_list.txt
|
||||
msf <%= mod.type %>(<%= mod.shortname %>) > set RHOSTS file:/tmp/ip_list.txt
|
||||
```
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
**RHOSTS**
|
||||
|
||||
Either a comma space (`, `) separated list of hosts, or a file containing list of hosts, one per line. File Example: `file://root/ssh_hosts.lst`, list example: `192.168.0.1` or `192.168.0.1, 192.168.0.2`
|
||||
Either a comma space (`, `) separated list of hosts, or a file containing list of hosts, one per line. File Example: `file:/root/ssh_hosts.lst`, list example: `192.168.0.1` or `192.168.0.1, 192.168.0.2`
|
||||
|
||||
**STOP_ON_SUCCESS**
|
||||
|
||||
|
@ -104,8 +104,8 @@ msf auxiliary(ssh_login) > cat /root/ssh_hosts.lst
|
|||
192.168.2.137
|
||||
192.168.2.35
|
||||
192.168.2.46
|
||||
msf auxiliary(ssh_login) > set rhosts file://root/ssh_hosts.lst
|
||||
rhosts => file://root/ssh_hosts.lst
|
||||
msf auxiliary(ssh_login) > set rhosts file:/root/ssh_hosts.lst
|
||||
rhosts => file:/root/ssh_hosts.lst
|
||||
msf auxiliary(ssh_login) > set verbose false
|
||||
verbose => false
|
||||
msf auxiliary(ssh_login) > set threads 4
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
**RHOSTS**
|
||||
|
||||
Either a comma space (`, `) separated list of hosts, or a file containing list of hosts, one per line. File Example: `file://root/ssh_hosts.lst`, list example: `192.168.0.1` or `192.168.0.1, 192.168.0.2`
|
||||
Either a comma space (`, `) separated list of hosts, or a file containing list of hosts, one per line. File Example: `file:/root/ssh_hosts.lst`, list example: `192.168.0.1` or `192.168.0.1, 192.168.0.2`
|
||||
|
||||
**STOP_ON_SUCCESS**
|
||||
|
||||
|
|
|
@ -41,11 +41,11 @@ module Msf
|
|||
end
|
||||
|
||||
# @return [OptAddressRange]
|
||||
def self.RHOSTS(default=nil, required=true, desc="The target address range or CIDR identifier")
|
||||
def self.RHOSTS(default=nil, required=true, desc="The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'")
|
||||
Msf::OptAddressRange.new('RHOSTS', [ required, desc, default ])
|
||||
end
|
||||
|
||||
def self.RHOST(default=nil, required=true, desc="The target address range or CIDR identifier")
|
||||
def self.RHOST(default=nil, required=true, desc="The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'")
|
||||
Msf::OptAddressRange.new('RHOSTS', [ required, desc, default ], aliases: [ 'RHOST' ])
|
||||
end
|
||||
|
||||
|
|
|
@ -18,7 +18,8 @@ class OptAddressRange < OptBase
|
|||
|
||||
def normalize(value)
|
||||
return nil unless value.kind_of?(String)
|
||||
if (value =~ /^file:(.*)/)
|
||||
# accept both "file://<path>" and "file:<path>" syntax
|
||||
if (value =~ /^file:\/\/(.*)/) || (value =~ /^file:(.*)/)
|
||||
path = $1
|
||||
return false if not File.exist?(path) or File.directory?(path)
|
||||
return File.readlines(path).map{ |s| s.strip}.join(" ")
|
||||
|
|
|
@ -11,7 +11,8 @@ RSpec.describe Msf::OptAddressRange do
|
|||
{ :value => "192.0.2.0,1-255", :normalized => "192.0.2.0,1-255" },
|
||||
{ :value => "192.0.2.*", :normalized => "192.0.2.*" },
|
||||
{ :value => "192.0.2.0-192.0.2.255", :normalized => "192.0.2.0-192.0.2.255" },
|
||||
{ :value => "file:#{File.expand_path('short_address_list.txt',FILE_FIXTURES_PATH)}", :normalized => '192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5'}
|
||||
{ :value => "file:#{File.expand_path('short_address_list.txt',FILE_FIXTURES_PATH)}", :normalized => '192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5'},
|
||||
{ :value => "file://#{File.expand_path('short_address_list.txt',FILE_FIXTURES_PATH)}", :normalized => '192.168.1.1 192.168.1.2 192.168.1.3 192.168.1.4 192.168.1.5'}
|
||||
]
|
||||
invalid_values = [
|
||||
# Too many dots
|
||||
|
|
Loading…
Reference in New Issue