-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a test module for host resolution
- Loading branch information
1 parent
8ee5649
commit 36a67c7
Showing
9 changed files
with
298 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
require 'rex' | ||
|
||
lib = File.join(Msf::Config.install_root, "test", "lib") | ||
$LOAD_PATH.push(lib) unless $LOAD_PATH.include?(lib) | ||
require 'module_test' | ||
|
||
class MetasploitModule < Msf::Post | ||
include Msf::ModuleTest::PostTest | ||
include Msf::Post::DNS::ResolveHost | ||
|
||
def initialize(info = {}) | ||
super( | ||
update_info( | ||
info, | ||
'Name' => 'Meterpreter resolve_host test', | ||
'Description' => %q( This module will test the meterpreter resolve_host API ), | ||
'License' => MSF_LICENSE, | ||
'Platform' => [ 'windows', 'linux', 'unix', 'java', 'osx' ], | ||
'SessionTypes' => ['meterpreter', 'shell', 'powershell'] | ||
) | ||
) | ||
end | ||
def test_resolve_host | ||
vprint_status("Starting resolve_host tests") | ||
|
||
it "should return a Hash" do | ||
# TODO: UPDATE TO NOT POINT AT GOOGLE | ||
hostname = "google.com" | ||
family = AF_INET6 | ||
|
||
resolved_host = resolve_host(hostname, family) | ||
resolved_host.is_a?(Hash) | ||
end | ||
|
||
it "should return a valid IPV4 host" do | ||
hostname = "rapid7.com" | ||
family = AF_INET | ||
|
||
resolved_host = resolve_host(hostname, family) | ||
|
||
puts resolved_host[:ips] | ||
resolved_host[:ips].each { |ip| !!(ip =~ Resolv::IPv4::Regex) } | ||
end | ||
|
||
it "should return a valid IPV6 host" do | ||
hostname = "google.com" | ||
family = AF_INET6 | ||
|
||
resolved_host = resolve_host(hostname, family) | ||
|
||
puts resolved_host[:ips] | ||
resolved_host[:ips].each { |ip| !!(ip =~ Resolv::IPv6::Regex) } | ||
end | ||
|
||
it "should handle an invalid IPV4 host" do | ||
hostname = "foo.bar" | ||
family = AF_INET | ||
|
||
begin | ||
resolve_host(hostname, family) | ||
rescue Rex::Post::Meterpreter::RequestError => e | ||
e.class == Rex::Post::Meterpreter::RequestError | ||
end | ||
end | ||
|
||
it "should handle an invalid IPV6 host" do | ||
hostname = "foo.bar" | ||
family = AF_INET6 | ||
|
||
begin | ||
resolve_host(hostname, family) | ||
rescue Rex::Post::Meterpreter::RequestError => e | ||
e.class == Rex::Post::Meterpreter::RequestError | ||
end | ||
end | ||
|
||
# it "should return a valid IPV4 host via nslookup" do | ||
# hostname = "google.com" | ||
# family = AF_INET | ||
# | ||
# resolved_host = resolve_host(hostname, family) | ||
# | ||
# puts resolved_host[:ips] | ||
# resolved_host[:ips].each { |ip| !!(ip =~ Resolv::IPv4::Regex) } | ||
# end | ||
|
||
# it "should return a valid IPV6 host via nslookup" do | ||
# hostname = "google.com" | ||
# family = AF_INET6 | ||
# | ||
# resolved_host = resolve_host(hostname, family) | ||
# | ||
# resolved_host[:ips].each { |ip| !!(ip =~ Resolv::IPv6::Regex) } | ||
# end | ||
|
||
# TODO: | ||
# - nslookup TESTS (IPV4/6) | ||
# - HOST TESTS (IPV4/6) | ||
# | ||
end | ||
end |