Skip to content

Commit 6c28084

Browse files
committed
Merge branch 'gspillman-r7-cucumber_tests'
2 parents 42ea64c + 2b17a04 commit 6c28084

File tree

10 files changed

+219
-0
lines changed

10 files changed

+219
-0
lines changed

test/features/data/test.exe

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#

test/features/encoders.feature

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#This feature contains scenarios that test the various encoders within the metasploit framework
2+
3+
@announce-stdout
4+
5+
Feature: As a Metasploit Framework user
6+
I want to user encoders
7+
So that I can encode various payloads I might use for attacks
8+
9+
Scenario: Create a windows tcp bind payload using the x86/unicode mixed encoder
10+
When I run msfvenom to encode for windows using the "x86/unicode_mixed" encoder with "-i 1" options and a buffer register
11+
#When I run `./msfvenom -p windows/shell/bind_tcp -e x86/unicode_mixed -i 1 BufferRegister=eax` interactively
12+
Then the output should contain "x86/unicode_mixed succeeded with size"
13+
14+
Scenario: Create a windows tcp bind payload encoded with x86 alpha mixed
15+
When I run msfvenom to encode for windows using the "x86/alpha_mixed" encoder with "-b '\x00' -i 1" options
16+
#When I run `./msfvenom -p windows/shell/bind_tcp -e x86/alpha_mixed -b '\x00' -i 1` interactively
17+
Then the output should contain "x86/alpha_mixed succeeded with size"
18+

test/features/handler.feature

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#This feature contains scenarios that test different handlers within the metasploit framework
2+
@announce
3+
4+
Feature: As a MS Framework User
5+
I want to launch various handlers
6+
So the framework can properly handle input and output from exploits
7+
8+
Scenario: Launching the exploit multi handler in Check mode
9+
When I run `./msfcli exploit/multi/handler C`
10+
Then the output should contain "module tree"
11+
Then the output should contain "This exploit does not support check."
12+
13+
Scenario: Launching the generic multi handler in Check mode
14+
When I run `./msfcli multi/handler C`
15+
Then the output should contain "module tree"
16+
Then the output should contain "This exploit does not support check."
17+
18+
19+

test/features/payloads.feature

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#This feature contains scenarios to test the ability to run/access payloads from the metasploit framework
2+
3+
Feature: I want access to Metasploit payloads
4+
So that I can define payload options for exploits
5+
6+
Scenario: Verify the windows shell reverse tcp payload option in ruby
7+
When I run msfpayload to generate a "windows/shell_reverse_tcp" on the local host
8+
Then the output should contain "# windows/shell_reverse_tcp"
9+
Then the output should contain "# http://www.metasploit.com"
10+
11+
Scenario: Verify the windows x64 shell reverse tcp payload option in ruby
12+
When I run msfpayload to generate a "windows/x64/shell_reverse_tcp" on the local host
13+
Then the output should contain "# windows/x64/shell_reverse_tcp"
14+
Then the output should contain "# http://www.metasploit.com"
15+
16+
Scenario: Verify the linux x86 shell reverse tcp payload option in ruby
17+
When I run msfpayload to generate a "linux/x86/shell_reverse_tcp" on the local host
18+
Then the output should contain "# linux/x86/shell_reverse_tcp"
19+
Then the output should contain "# http://www.metasploit.com"
20+
21+
Scenario: Verify the windows meterpreter reverse tcp payload can output its contents in ruby
22+
When I run msfpayload to generate a "windows/meterpreter/reverse_tcp" on the local host
23+
Then the output should contain "# windows/meterpreter/reverse_tcp - 290 bytes (stage 1)"
24+
Then the output should contain "# http://www.metasploit.com"

test/features/steps/common_steps.rb

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#This is the step definition file for common framework testing steps or meta steps
2+
3+
When /^I run the "([^"]*)" exploit with standard target options$/ do |exploit|
4+
steps %Q{
5+
When I run `#{exploit} RHOST=#{TestConfig.instance.rhost} SMBPass=#{TestConfig.instance.smbpass} SMBUser=#{TestConfig.instance.smbuser} E` interactively
6+
}
7+
end
8+
9+
When /^I run the "([^"]*)" exploit with standard target options in check mode$/ do |exploit|
10+
steps %Q{
11+
When I run `#{exploit} RHOST=#{TestConfig.instance.rhost} SMBPass=#{TestConfig.instance.smbpass} SMBUser=#{TestConfig.instance.smbuser} C` interactively
12+
}
13+
end
14+
15+
When /^I run msfvenom to encode for windows using the "([^"]*)" encoder with "(.*)" options$/ do |encoder, options|
16+
steps %Q{
17+
When I run `./msfvenom ./msfvenom -p windows/shell/bind_tcp -e #{encoder} #{options}` interactively
18+
}
19+
end
20+
21+
When /^I run msfvenom to encode for windows using the "([^"]*)" encoder with "(.*)" options and a buffer register$/ do |encoder, options|
22+
steps %Q{
23+
When I run `./msfvenom ./msfvenom -p windows/shell/bind_tcp -e #{encoder} #{options} BufferRegister=eax` interactively
24+
}
25+
end
26+
27+
When /^I run msfpayload to generate a "([^"]*)" on the local host$/ do |payload|
28+
steps %Q{
29+
When I run `./msfpayload #{payload} LHOST=127.0.0.1 y`
30+
}
31+
end

test/features/steps/handler_steps.rb

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#This is the step definition file for cucumber features relating to the framework handler feature
2+
3+
Given /^I launch the exploit multi handler$/ do
4+
steps %Q{
5+
6+
When I run `./msfcli exploit/multi/handler E`
7+
Then the output should contain "Please wait while we load the module tree..."
8+
Then the output should contain "Started reverse handler on"
9+
Then the output should contain "Starting the payload handler..."
10+
11+
}
12+
end
13+
14+
Given /^I launch the generic multi handler$/ do
15+
steps %Q{
16+
17+
When I run `./msfcli multi/handler E`
18+
Then the output should contain "Please wait while we load the module tree..."
19+
Then the output should contain "Started reverse handler on"
20+
Then the output should contain "Starting the payload handler..."
21+
22+
}
23+
end

test/features/support/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# These files are to be excluded from git #
2+
3+
test_config.yml

test/features/support/env.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#Cucumber automation environment setup class for MSF Testing
2+
3+
require 'cucumber'
4+
require 'aruba/cucumber'
5+
require_relative 'test_config'
6+
7+
Before do
8+
# Automatically find the framework path
9+
default_path = File.join(File.expand_path(File.dirname(__FILE__)), '../../../')
10+
11+
# Add more paths manually if needed. For example:
12+
# "/Users/gary/rapid7/framework"
13+
@dirs = [default_path]
14+
15+
@aruba_timeout_seconds = 150
16+
end
17+
18+
Before('@slow_process') do
19+
@aruba_io_wait_seconds = 150
20+
end
21+
22+
@After
23+
#after automation execution methods go here
24+
25+

test/features/support/test_config.rb

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#Test config class provides public methods or varables to use for ever test
2+
#Includes housing data such as default web site to test, time out varaibels, etc
3+
require 'singleton'
4+
class TestConfig
5+
include Singleton
6+
7+
def initialize(*args)
8+
9+
yml_path = File.join(File.dirname(__FILE__),'test_config.yml')
10+
11+
if File.exists?(yml_path)
12+
@yaml_options = YAML::load(File.open(yml_path))
13+
else
14+
@yaml_options = {}
15+
end
16+
17+
@options = {
18+
"rhost" => "localhost",
19+
"smbuser" => "user",
20+
"smbpass" => "password"
21+
}
22+
end
23+
24+
def run_server
25+
@options[:define_site].nil?
26+
end
27+
28+
def method_missing(method)
29+
if @options.has_key? method.to_s
30+
return @options[method.to_s]
31+
else
32+
super
33+
end
34+
end
35+
36+
def respond_to?(method_sym, include_private = false)
37+
if @options.include? method_s
38+
true
39+
else
40+
super
41+
end
42+
end
43+
44+
end
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#This feature contains scenarios that test running exploits related to microsft windows platforms
2+
3+
@announce-stdout
4+
5+
Feature: I want to launch Windows based exploits
6+
So that I can hack Windows targets
7+
So that I can prove how totally unsecured Windows can be
8+
9+
Scenario: Launch Psexec against a Windows Host
10+
When I run the "./msfcli windows/smb/psexec" exploit with standard target options
11+
Then the output should contain "445|WORKGROUP as user"
12+
Then the output should contain "module tree"
13+
14+
Scenario: Launch PSexec in Internal Check Mode
15+
When I run the "./msfcli windows/smb/psexec" exploit with standard target options in check mode
16+
Then the output should contain "module tree"
17+
Then the output should contain "This exploit does not support check."
18+
19+
Scenario: Launch ms08-067 in Internal Check Mode
20+
When I run the "./msfcli windows/smb/ms08_067_netapi" exploit with standard target options in check mode
21+
#When I run `./msfcli windows/smb/ms08_067_netapi RHOST=10.6.0.194 C` interactively
22+
Then the output should contain "module tree"
23+
Then the output should not contain "Check failed:"
24+
25+
Scenario: Launch ms08-067 against a windows remote host
26+
When I run the "./msfcli windows/smb/ms08_067_netapi" exploit with standard target options
27+
Then the output should contain "module tree"
28+
Then the output should contain "Started reverse handler"
29+
30+
31+

0 commit comments

Comments
 (0)