forked from rapid7/metasploit-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from rapid7/master
update
- Loading branch information
Showing
123 changed files
with
2,538 additions
and
684 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<% | ||
rerun = File.file?('rerun.txt') ? IO.read('rerun.txt') : "" | ||
rerun_opts = rerun.to_s.strip.empty? ? "--format #{ENV['CUCUMBER_FORMAT'] || 'progress'} features" : "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} #{rerun}" | ||
std_opts = "--format #{ENV['CUCUMBER_FORMAT'] || 'pretty'} --strict --tags ~@wip" | ||
%> | ||
default: <%= std_opts %> features | ||
wip: --tags @wip:3 --wip features | ||
rerun: <%= rerun_opts %> --format rerun --out rerun.txt --strict --tags ~@wip |
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,158 @@ | ||
Feature: `msfconsole` `database.yml` | ||
|
||
In order to connect to the database in `msfconsole` | ||
As a user calling `msfconsole` from a terminal | ||
I want to be able to set the path of the `database.yml` in one of 4 locations (in order of precedence): | ||
|
||
1. An explicit argument to the `-y` flag to `msfconsole` | ||
2. The MSF_DATABASE_CONFIG environment variable | ||
3. The user's `~/.msf4/database.yml` | ||
4. `config/database.yml` in the metasploit-framework checkout location. | ||
|
||
Scenario: With all 4 locations, --yaml wins | ||
Given a file named "command_line.yml" with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: command_line_metasploit_framework_test | ||
username: command_line_metasploit_framework_test | ||
""" | ||
And a file named "msf_database_config.yml" with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: environment_metasploit_framework_test | ||
username: environment_metasploit_framework_test | ||
""" | ||
And I set the environment variables to: | ||
| variable | value | | ||
| MSF_DATABASE_CONFIG | msf_database_config.yml | | ||
And a directory named "home" | ||
And I cd to "home" | ||
And a mocked home directory | ||
And a directory named ".msf4" | ||
And I cd to ".msf4" | ||
And a file named "database.yml" with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: user_metasploit_framework_test | ||
username: user_metasploit_framework_test | ||
""" | ||
And I cd to "../.." | ||
And the project "database.yml" exists with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: project_metasploit_framework_test | ||
username: project_metasploit_framework_test | ||
""" | ||
When I run `msfconsole --environment test --yaml command_line.yml` interactively | ||
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" | ||
And I type "exit" | ||
Then the output should contain "command_line_metasploit_framework_test" | ||
|
||
Scenario: Without --yaml, MSF_DATABASE_CONFIG wins | ||
Given a file named "msf_database_config.yml" with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: environment_metasploit_framework_test | ||
username: environment_metasploit_framework_test | ||
""" | ||
And I set the environment variables to: | ||
| variable | value | | ||
| MSF_DATABASE_CONFIG | msf_database_config.yml | | ||
And a directory named "home" | ||
And I cd to "home" | ||
And a mocked home directory | ||
And a directory named ".msf4" | ||
And I cd to ".msf4" | ||
And a file named "database.yml" with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: user_metasploit_framework_test | ||
username: user_metasploit_framework_test | ||
""" | ||
And I cd to "../.." | ||
And the project "database.yml" exists with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: project_metasploit_framework_test | ||
username: project_metasploit_framework_test | ||
""" | ||
When I run `msfconsole --environment test` interactively | ||
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" | ||
And I type "exit" | ||
Then the output should contain "environment_metasploit_framework_test" | ||
|
||
Scenario: Without --yaml or MSF_DATABASE_CONFIG, ~/.msf4/database.yml wins | ||
Given I unset the environment variables: | ||
| variable | | ||
| MSF_DATABASE_CONFIG | | ||
And a directory named "home" | ||
And I cd to "home" | ||
And a mocked home directory | ||
And a directory named ".msf4" | ||
And I cd to ".msf4" | ||
And a file named "database.yml" with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: user_metasploit_framework_test | ||
username: user_metasploit_framework_test | ||
""" | ||
And I cd to "../.." | ||
And the project "database.yml" exists with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: project_metasploit_framework_test | ||
username: project_metasploit_framework_test | ||
""" | ||
When I run `msfconsole --environment test` interactively | ||
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" | ||
And I type "exit" | ||
Then the output should contain "user_metasploit_framework_test" | ||
|
||
Scenario: Without --yaml, MSF_DATABASE_CONFIG or ~/.msf4/database.yml, project "database.yml" wins | ||
Given I unset the environment variables: | ||
| variable | | ||
| MSF_DATABASE_CONFIG | | ||
And a directory named "home" | ||
And I cd to "home" | ||
And a mocked home directory | ||
And I cd to "../.." | ||
And the project "database.yml" exists with: | ||
""" | ||
test: | ||
adapter: postgresql | ||
database: project_metasploit_framework_test | ||
username: project_metasploit_framework_test | ||
""" | ||
When I run `msfconsole --environment test` interactively | ||
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" | ||
And I type "exit" | ||
Then the output should contain "project_metasploit_framework_test" | ||
|
||
|
||
Scenario: Without --yaml, MSF_DATABASE_CONFIG, ~/.msf4/database.yml, or project "database.yml", no database connection | ||
Given I unset the environment variables: | ||
| variable | | ||
| MSF_DATABASE_CONFIG | | ||
And a directory named "home" | ||
And I cd to "home" | ||
And a mocked home directory | ||
And I cd to "../.." | ||
And the project "database.yml" does not exist | ||
When I run `msfconsole --environment test` interactively | ||
And I wait for stdout to contain "Free Metasploit Pro trial: http://r-7.co/trymsp" | ||
And I type "db_status" | ||
And I type "exit" | ||
Then the output should not contain "command_line_metasploit_framework_test" | ||
And the output should not contain "environment_metasploit_framework_test" | ||
And the output should not contain "user_metasploit_framework_test" | ||
And the output should not contain "project_metasploit_framework_test" | ||
And the output should contain "[*] postgresql selected, no connection" |
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,20 @@ | ||
Given /^I unset the environment variables:$/ do |table| | ||
table.hashes.each do |row| | ||
variable = row['variable'].to_s.upcase | ||
|
||
# @todo add extension to Announcer | ||
announcer.instance_eval do | ||
if @options[:env] | ||
print "$ unset #{variable}" | ||
end | ||
end | ||
|
||
current_value = ENV.delete(variable) | ||
|
||
# if original_env already has the key, then the true original was already recorded from a previous unset or set, | ||
# so don't record the current value as it will cause ENV not to be restored after the Scenario. | ||
unless original_env.key? variable | ||
original_env[variable] = current_value | ||
end | ||
end | ||
end |
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,14 @@ | ||
require 'metasploit/framework/database/cucumber' | ||
|
||
Given /^the project "database.yml" does not exist$/ do | ||
Metasploit::Framework::Database::Cucumber.backup_project_configurations | ||
end | ||
|
||
Given /^the project "database.yml" exists with:$/ do |file_content| | ||
Metasploit::Framework::Database::Cucumber.backup_project_configurations | ||
write_file(Metasploit::Framework::Database::Cucumber.project_configurations_path, file_content) | ||
end | ||
|
||
After do | ||
Metasploit::Framework::Database::Cucumber.restore_project_configurations | ||
end |
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,26 @@ | ||
#!/usr/bin/env ruby | ||
|
||
case ARGV[0] | ||
when 'size' | ||
puts "30 134" | ||
when '-a' | ||
puts <<EOS | ||
speed 38400 baud; 30 rows; 134 columns; | ||
lflags: icanon isig iexten echo echoe echok echoke -echonl echoctl | ||
-echoprt -altwerase -noflsh -tostop -flusho pendin -nokerninfo | ||
-extproc | ||
iflags: -istrip icrnl -inlcr -igncr ixon -ixoff ixany imaxbel iutf8 | ||
-ignbrk brkint -inpck -ignpar -parmrk | ||
oflags: opost onlcr -oxtabs -onocr -onlret | ||
cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb -crtscts -dsrflow | ||
-dtrflow -mdmbuf | ||
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = <undef>; | ||
eol2 = <undef>; erase = ^?; intr = ^C; kill = ^U; lnext = ^V; | ||
min = 1; quit = ^\; reprint = ^R; start = ^Q; status = ^T; | ||
stop = ^S; susp = ^Z; time = 0; werase = ^W; | ||
EOS | ||
when '-g' | ||
puts "gfmt1:cflag=4b00:iflag=6b02:lflag=200005cf:oflag=3:discard=f:dsusp=19:eof=4:eol=ff:eol2=ff:erase=7f:intr=3:kill=15:lnext=16:min=1:quit=1c:reprint=12:start=11:status=14:stop=13:susp=1a:time=0:werase=17:ispeed=38400:ospeed=38400" | ||
end | ||
|
||
exit 0 |
Oops, something went wrong.