gauntlt 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. data/.gitmodules +4 -1
  2. data/.travis.yml +3 -3
  3. data/Gemfile +3 -0
  4. data/README.md +73 -34
  5. data/examples/curl/cookies.attack +3 -1
  6. data/examples/curl/simple.attack +3 -1
  7. data/examples/curl/verbs.attack +3 -1
  8. data/examples/garmr/garmr.attack +11 -3
  9. data/examples/generic/generic.attack +3 -1
  10. data/examples/nmap/nmap.attack +4 -16
  11. data/examples/nmap/os_detection.attack +3 -1
  12. data/examples/nmap/simple.attack +3 -1
  13. data/examples/nmap/tcp_ping_ports.attack +10 -8
  14. data/examples/nmap/xml_output.attack +3 -1
  15. data/examples/simplest.attack +10 -0
  16. data/examples/sqlmap/sqlmap.attack +15 -3
  17. data/examples/sslyze/sslyze.attack +4 -10
  18. data/features/attack.feature +37 -42
  19. data/features/attacks/garmr.feature +3 -3
  20. data/features/attacks/nmap.feature +1 -1
  21. data/features/attacks/sqlmap.feature +4 -4
  22. data/features/step_definitions/support_steps.rb +17 -6
  23. data/features/support/hooks.rb +6 -0
  24. data/features/tags.feature +30 -27
  25. data/gauntlt.gemspec +1 -1
  26. data/lib/gauntlt/attack_adapters/curl.rb +1 -2
  27. data/lib/gauntlt/attack_adapters/garmr.rb +1 -2
  28. data/lib/gauntlt/attack_adapters/gauntlt.rb +16 -4
  29. data/lib/gauntlt/attack_adapters/generic.rb +1 -2
  30. data/lib/gauntlt/attack_adapters/nmap.rb +1 -25
  31. data/lib/gauntlt/attack_adapters/sqlmap.rb +2 -4
  32. data/lib/gauntlt/attack_adapters/sslyze.rb +2 -8
  33. data/lib/gauntlt/attack_adapters/support/profile_helper.rb +11 -20
  34. data/lib/gauntlt/version.rb +1 -1
  35. metadata +4 -13
  36. data/features/support/scapegoat/scapegoat.rb +0 -59
  37. data/features/support/scapegoat/views/index.erb +0 -17
  38. data/features/support/scapegoat/views/inline_js.erb +0 -3
  39. data/features/support/scapegoat/views/layout.erb +0 -10
  40. data/features/support/scapegoat/views/sqlmap.erb +0 -25
data/.gitmodules CHANGED
@@ -6,4 +6,7 @@
6
6
  url = https://github.com/sqlmapproject/sqlmap.git
7
7
  [submodule "vendor/Garmr"]
8
8
  path = vendor/Garmr
9
- url = https://github.com/freddyb/Garmr.git
9
+ url = git://github.com/mozilla/Garmr.git
10
+ [submodule "features/support/scapegoat"]
11
+ path = features/support/scapegoat
12
+ url = git://github.com/gauntlt/scapegoat.git
data/.travis.yml CHANGED
@@ -6,9 +6,9 @@ before_install:
6
6
  - git submodule update --init --recursive
7
7
  before_script:
8
8
  - sudo apt-get install nmap
9
- - export SSLYZE_PATH="/home/vagrant/builds/thegauntlet/gauntlt/vendor/sslyze/sslyze.py"
10
- - export SQLMAP_PATH="/home/vagrant/builds/thegauntlet/gauntlt/vendor/sqlmap/sqlmap.py"
11
- - 'cd vendor/Garmr && sudo python setup.py install && sudo easy_install BeautifulSoup && cd ../..'
9
+ - export SSLYZE_PATH="/home/vagrant/builds/gauntlt/gauntlt/vendor/sslyze/sslyze.py"
10
+ - export SQLMAP_PATH="/home/vagrant/builds/gauntlt/gauntlt/vendor/sqlmap/sqlmap.py"
11
+ - 'cd vendor/Garmr && sudo python setup.py install && cd ../..'
12
12
 
13
13
  matrix:
14
14
  allow_failures:
data/Gemfile CHANGED
@@ -3,4 +3,7 @@ source :rubygems
3
3
  gemspec
4
4
 
5
5
  gem 'debugger', :platform => :mri
6
+ gem 'ruby-debug-base', :platform => :jruby
7
+
6
8
  gem 'sqlite3', :platform => :mri
9
+ gem 'jdbc-sqlite3', :platform => :jruby
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # gauntlt [![Build Status](https://secure.travis-ci.org/thegauntlet/gauntlt.png?branch=master)](http://travis-ci.org/thegauntlet/gauntlt) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/thegauntlet/gauntlt)
1
+ # gauntlt [![Build Status](https://secure.travis-ci.org/gauntlt/gauntlt.png?branch=master)](http://travis-ci.org/gauntlt/gauntlt) [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/gauntlt/gauntlt)
2
2
 
3
3
  gauntlt is a ruggedization framework
4
4
 
@@ -10,7 +10,7 @@ Have questions? Ask us anything on the [gauntlt google group](http://bit.ly/gau
10
10
 
11
11
  ## GET STARTED
12
12
 
13
- Note: if you are new to gauntlt, have a look at [gauntlt-starter-kit](https://github.com/thegauntlet/gauntlt-starter-kit), which is the easiest way to get up and running with gauntlt.
13
+ Note: if you are new to gauntlt, have a look at [gauntlt-starter-kit](https://github.com/gauntlt/gauntlt-starter-kit), which is the easiest way to get up and running with gauntlt.
14
14
 
15
15
  You will need ruby version `1.9.3` to run gauntlt, but you can run gauntlt against applications built with any language or platform.
16
16
 
@@ -20,21 +20,16 @@ You will need ruby version `1.9.3` to run gauntlt, but you can run gauntlt again
20
20
 
21
21
  2. Create an attack file and put it anywhere you like
22
22
 
23
- # nmap.attack
24
- Feature: nmap attacks
25
- Background:
26
- Given "nmap" is installed
27
- And the target hostname is "google.com"
28
-
29
- Scenario: Verify server is available on standard web ports
30
- When I launch an "nmap" attack with:
23
+ # simplest.attack
24
+ Feature: simplest attack possible
25
+ Scenario:
26
+ When I launch a "generic" attack with:
31
27
  """
32
- nmap -p 80,443 <hostname>
28
+ ls -a
33
29
  """
34
30
  Then the output should contain:
35
31
  """
36
- 80/tcp open http
37
- 443/tcp open https
32
+ .
38
33
  """
39
34
 
40
35
  3. Run gauntlt to launch the attack defined above
@@ -48,7 +43,7 @@ You will need ruby version `1.9.3` to run gauntlt, but you can run gauntlt again
48
43
  $ gauntlt my_attacks/*.attack some_other.file
49
44
 
50
45
 
51
- For more attack examples, refer to the [examples](https://github.com/thegauntlet/gauntlt/tree/master/examples).
46
+ For more attack examples, refer to the [examples](https://github.com/gauntlt/gauntlt/tree/master/examples).
52
47
 
53
48
  4. Other commands
54
49
 
@@ -59,13 +54,72 @@ You will need ruby version `1.9.3` to run gauntlt, but you can run gauntlt again
59
54
  $ gauntlt --help
60
55
 
61
56
 
62
- ## For developers
57
+ ## ATTACK ADAPTERS
58
+
59
+ Gauntlt includes attack adapters for the following tools:
60
+
61
+ * [curl] [curl]
62
+ * [nmap] [nmap]
63
+ * [sslyze] [sslyze]
64
+ * [sqlmap] [sqlmap]
65
+ * [Garmr] [garmr]
66
+
67
+ You will need to install each tool yourself before you can use it with gauntlt. However, if you try to use a tool that is not installed or that gauntlt cannot find, you will get a helpful error message from gauntlt with information on how to install and/or configure the tool for use with gauntlt.
68
+
69
+ We also include a generic attack adapter that allows you to run anything on the command line, parse its output and check its exit status.
70
+
71
+
72
+ ## ATTACK FILES
73
+
74
+ ### Preamble
75
+
76
+ To use gauntlt, you will need one or more attack files. An attack file is a plain text file written with [Gherkin](https://github.com/cucumber/gherkin) syntax and named with the `.attack` extension. For more info on the Gherkin syntax, have a look at [Cucumber](http://cukes.info). A gauntlt attack file is almost the same as a cucumber feature file. The main difference is that gauntlt aims to provide the user with predefined steps geared towards security and durability testing so that you do not have to write your own step definitions, whereas cucumber is aimed at developers and stakeholders building features from end to end. Gauntlt and cucumber can and do work together harmoniously.
77
+
78
+ ### What an attack file looks like
79
+
80
+ # my.attack
81
+ Feature: Description for all scenarios in this file
82
+ Scenario: Description of this scenario
83
+ Given ...
84
+ When ...
85
+ Then ...
86
+
87
+ Scenario: ...
88
+ Given ...
89
+ When ...
90
+ Then ...
91
+
92
+ You can have as many `Scenario` entries as you like, but it is good practice to keep the number low and to ensure that the scenarios in an attack file are all related. You can create as many attack files as you like and organize them in folders and sub-folders as well.
63
93
 
64
- NOTE: We currently use `ruby 1.9.3` and `JRuby 1.7.0-preview2` for development and testing.
94
+ There are a large number of step definitions available, but you can do a lot with just these 3:
95
+
96
+ Feature: Attack with kindness
97
+
98
+ Scenario: Ensure I am not mean
99
+ # verify a given attack adapter is installed
100
+ # HIGHLY RECOMMENDED to catch installation/configuration problems
101
+ Given "kindness" is installed
102
+
103
+ # Execute the attack
104
+ When I launch a "kindness" attack with:
105
+ """
106
+ whoami # EXACT commands to be executed on the command line
107
+ """
108
+
109
+ # Check exit status and STDOUT
110
+ Then it should pass with:
111
+ """
112
+ very_kind
113
+ """
114
+
115
+
116
+ ## FOR DEVELOPERS
117
+
118
+ NOTE: We currently use `ruby 1.9.3` and `JRuby 1.7.0` for development and testing.
65
119
 
66
120
  1. Clone the git repo and get the submodules
67
121
 
68
- $ git clone --recursive git://github.com/thegauntlet/gauntlt.git
122
+ $ git clone --recursive git://github.com/gauntlt/gauntlt.git
69
123
 
70
124
  2. Install bundler
71
125
 
@@ -92,21 +146,7 @@ NOTE: We currently use `ruby 1.9.3` and `JRuby 1.7.0-preview2` for development a
92
146
 
93
147
  ## ROADMAP
94
148
 
95
- We are adding different features into gauntlt rignt now. Please submit issues via github and tag them as enhancements. The core team meets weekly and will divide out the enhancement requests into our monthly releases.
96
-
97
- Below are some tools we are targeting but don't let that stop you from adding your favorite hacking tool.
98
-
99
- * [curl] [curl]
100
- * [nmap] [nmap]
101
- * [sslyze] [sslyze]
102
- * [sqlmap] [sqlmap]
103
- * [w3af] [w3af]
104
- * [arachni] [arachni]
105
-
106
-
107
- ## ADD AN ATTACK ADAPTER
108
-
109
- See the wiki on how to add an attack adapter to gauntlt. We would love your contributions.
149
+ Gauntlt is under active development and we appreciate your suggestions and bug reports. We aim to be very responsive and friendly while adhering to a consistent design based on minimalism, simplicity and extensibility.
110
150
 
111
151
  ## LICENSE
112
152
 
@@ -115,6 +155,5 @@ gauntlt is licensed under The MIT License. See the LICENSE file in the repo or v
115
155
  [curl]: http://curl.haxx.se
116
156
  [nmap]: http://nmap.org
117
157
  [sslyze]: https://github.com/iSECPartners/sslyze
118
- [w3af]: http://w3af.sourceforge.net
119
158
  [sqlmap]: http://sqlmap.org
120
- [arachni]: http://arachni-scanner.com
159
+ [garmr]: https://github.com/mozilla/Garmr
@@ -2,7 +2,9 @@ Feature: Evaluate received cookies against expected.
2
2
 
3
3
  Background:
4
4
  Given "curl" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  Scenario: Verify server is returning the cookies expected
8
10
  When I launch a "curl" attack with:
@@ -2,7 +2,9 @@ Feature: Launch curl attack
2
2
 
3
3
  Background:
4
4
  Given "curl" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  Scenario: Verify a 301 is received from a curl
8
10
  When I launch a "curl" attack with:
@@ -2,7 +2,9 @@ Feature: Evaluate responses to various HTTP methods.
2
2
 
3
3
  Background:
4
4
  Given "curl" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  Scenario Outline: Verify server responds correctly to various HTTP methods
8
10
  When I launch a "curl" attack with:
@@ -2,12 +2,20 @@ Feature: Run garmr scan on a URL
2
2
 
3
3
  Scenario: Use Garmr to scan a website for basic security requirements
4
4
  Given "garmr" is installed
5
- And the target URL is "http://localhost:9292/inline-js"
5
+ And the following profile:
6
+ | name | value |
7
+ | target_url | http://localhost:9292/inline-js |
6
8
  When I launch a "garmr" attack with:
7
9
  """
8
- garmr -u <target_url>
10
+ garmr -u <target_url> -o my_garmr_output.xml
9
11
  """
10
12
  Then it should pass with:
11
13
  """
12
14
  [Garmr.corechecks.InlineJS] Fail Inline JavaScript found
13
- """
15
+ """
16
+ And the file "my_garmr_output.xml" should contain XML:
17
+ | css |
18
+ | testcase[name="InlineJS"] failure |
19
+ And the file "my_garmr_output.xml" should not contain XML:
20
+ | css |
21
+ | testcase[name="SCSPHeaderCheck"] failure |
@@ -4,7 +4,9 @@ This attack adapter allows for any command line binary to be executed and the ou
4
4
 
5
5
  Background:
6
6
  Given the "ping" command line binary is installed
7
- And the target hostname is "google.com"
7
+ And the following profile:
8
+ | name | value |
9
+ | hostname | google.com |
8
10
 
9
11
  Scenario: Verify a 301 is received from a curl
10
12
  When I launch a "generic" attack with:
@@ -3,9 +3,10 @@
3
3
  Feature: nmap attacks for example.com
4
4
  Background:
5
5
  Given "nmap" is installed
6
- And the target hostname is "google.com"
7
- And the target tcp_ping_ports are "22,25,80,443"
8
-
6
+ And the following profile:
7
+ | name | value |
8
+ | hostname | google.com |
9
+ | tcp_ping_ports | 22,25,80,443 |
9
10
 
10
11
  Scenario: Verify server is open on expected set of ports using the nmap fast flag
11
12
  When I launch an "nmap" attack with:
@@ -30,19 +31,6 @@ Feature: nmap attacks for example.com
30
31
  25/tcp
31
32
  """
32
33
 
33
- Scenario: Using tcp syn ping scan and the nmap fast flag
34
- When I launch an "nmap" attack with:
35
- """
36
- nmap -F -PS<tcp_ping_ports> <hostname>
37
- """
38
- Then the output should contain:
39
- """
40
- 80/tcp open http
41
- 443/tcp open https
42
- 3128/tcp open squid-http
43
- 8080/tcp open http-proxy
44
- """
45
-
46
34
  Scenario: Output to XML
47
35
  When I launch an "nmap" attack with:
48
36
  """
@@ -2,7 +2,9 @@ Feature: OS detection
2
2
 
3
3
  Background:
4
4
  Given "nmap" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  @slow
8
10
  Scenario: Detect OS
@@ -2,7 +2,9 @@ Feature: simple nmap attack (sanity check)
2
2
 
3
3
  Background:
4
4
  Given "nmap" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  Scenario: Verify server is available on standard web ports
8
10
  When I launch an "nmap" attack with:
@@ -1,16 +1,18 @@
1
+ @slow @announce
1
2
  Feature: nmap attacks for example.com
2
3
  Background:
3
4
  Given "nmap" is installed
4
- And the target hostname is "google.com"
5
- And the target tcp_ping_ports are "22,25,80,443"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | scanme.nmap.org |
8
+ | tcp_ping_ports | 22,25,80,443 |
6
9
 
7
- @slow
8
10
  Scenario: Using tcp syn ping scan and the nmap fast flag
9
11
  When I launch an "nmap" attack with:
10
12
  """
11
- nmap -F -PS<tcp_ping_ports> <hostname>
12
- """
13
- Then the output should contain:
14
- """
15
- 80/tcp
13
+ nmap -F -PS<tcp_ping_ports> <hostname> -oX foo.xml
16
14
  """
15
+ Then the file "foo.xml" should contain XML:
16
+ | css |
17
+ | ports port[protocol="tcp"][portid="80"] state[state="open"] |
18
+ | ports port[protocol="tcp"][portid="22"] state[state="open"] |
@@ -2,7 +2,9 @@ Feature: XML output
2
2
 
3
3
  Background:
4
4
  Given "nmap" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  Scenario: Output to XML
8
10
  When I launch an "nmap" attack with:
@@ -0,0 +1,10 @@
1
+ Feature: simplest attack possible
2
+ Scenario:
3
+ When I launch a "generic" attack with:
4
+ """
5
+ ls -a
6
+ """
7
+ Then the output should contain:
8
+ """
9
+ .
10
+ """
@@ -1,14 +1,26 @@
1
- @slow
1
+ @slow @announce
2
2
  Feature: Run sqlmap against a target
3
+ # See:
4
+ # https://github.com/sqlmapproject/sqlmap/wiki/Usage
3
5
 
4
6
  Scenario: Identify SQL injection vulnerabilities
5
7
  Given "sqlmap" is installed
6
- And the target URL is "http://localhost:9292/sql-injection?number_id=1"
8
+ And the following profile:
9
+ | name | value |
10
+ | target_url | http://localhost:9292/sql-injection?number_id=1 |
7
11
  When I launch a "sqlmap" attack with:
8
12
  """
9
- python <sqlmap_path> -u <target_url> --dbms sqlite --batch -v 0
13
+ python <sqlmap_path> -u <target_url> --dbms sqlite --batch -v 0 --tables
10
14
  """
11
15
  Then the output should contain:
12
16
  """
13
17
  sqlmap identified the following injection points
18
+ """
19
+ And the output should contain:
20
+ """
21
+ [2 tables]
22
+ +-----------------+
23
+ | numbers |
24
+ | sqlite_sequence |
25
+ +-----------------+
14
26
  """
@@ -2,7 +2,9 @@ Feature: Run sslyze against a target
2
2
 
3
3
  Background:
4
4
  Given "sslyze" is installed
5
- And the target hostname is "google.com"
5
+ And the following profile:
6
+ | name | value |
7
+ | hostname | google.com |
6
8
 
7
9
  Scenario: Ensure no anonymous certificates
8
10
  When I launch an "sslyze" attack with:
@@ -12,12 +14,4 @@ Scenario: Ensure no anonymous certificates
12
14
  Then the output should not contain:
13
15
  """
14
16
  Anon
15
- """
16
-
17
- # Scenario: Make sure that the certificate key size is at least 2048
18
- # Given the target hostname is "google.com"
19
- # When I launch an "sslyze" attack with:
20
- # """
21
- # python <sslyze_path> <hostname>:443
22
- # """
23
- # Then the key size should be at least 2048
17
+ """
@@ -12,70 +12,65 @@ Feature: Verify the attack behaviour is correct
12
12
  nmap
13
13
  """
14
14
 
15
- @slow
16
15
  Scenario: Run attack
17
16
  Given an attack "nmap" exists
18
17
  And a file named "nmap.attack" with:
19
- """
20
- Feature: my nmap attacks
21
- Scenario: nmap attack works
22
- Given "nmap" is installed
23
- And the target hostname is "google.com"
24
- When I launch an "nmap" attack with:
25
- \"\"\"
26
- nmap -p 80,443 <hostname>
27
- \"\"\"
28
- Then the output should contain:
29
- \"\"\"
30
- 80/tcp open http
31
- 443/tcp open https
32
- \"\"\"
33
- """
18
+ """
19
+ Feature: simplest attack possible
20
+ Scenario:
21
+ When I launch a "generic" attack with:
22
+ \"\"\"
23
+ ls -a
24
+ \"\"\"
25
+ Then the output should contain:
26
+ \"\"\"
27
+ .
28
+ \"\"\"
29
+ """
34
30
  When I run `gauntlt`
35
31
  Then it should pass with:
36
- """
37
- 4 steps (4 passed)
38
- """
32
+ """
33
+ 2 steps (2 passed)
34
+ """
39
35
 
40
36
  Scenario: Run attack with custom filename
41
37
  Given an attack "nmap" exists
42
38
  And a file named "my.awesome.attack.file" with:
43
- """
44
- Feature: my nmap attacks
45
- Scenario: nmap attack works
46
- Given "nmap" is installed
47
- """
39
+ """
40
+ Feature: my nmap attacks
41
+ Scenario: nmap attack works
42
+ Given "nmap" is installed
43
+ """
48
44
  When I run `gauntlt my.awesome.attack.file`
49
45
  Then it should pass with:
50
- """
51
- 1 step (1 passed)
52
- """
46
+ """
47
+ 1 step (1 passed)
48
+ """
53
49
 
54
50
  Scenario: Run attack with undefined steps
55
51
  Given an attack "nmap" exists
56
52
  And a file named "nmap.attack" with:
57
- """
58
- Feature: my non-existent attack
59
- Scenario: Fail on undefined step definition
60
- Given "thisattackwouldneverexist" is installed
61
- """
53
+ """
54
+ Feature: my non-existent attack
55
+ Scenario: Fail on undefined step definition
56
+ Given "thisattackwouldneverexist" is installed
57
+ """
62
58
  When I run `gauntlt`
63
59
  Then it should fail with:
64
- """
65
- Bad or undefined attack!
66
- """
67
-
60
+ """
61
+ Bad or undefined attack!
62
+ """
68
63
 
69
64
  Scenario: No attack files in default path
70
65
  When I run `gauntlt`
71
66
  Then it should fail with:
72
- """
73
- No files found in path
74
- """
67
+ """
68
+ No files found in path
69
+ """
75
70
 
76
71
  Scenario: No attack files in specified path
77
72
  When I run `gauntlt apaththatdoesnotexist`
78
73
  Then it should fail with:
79
- """
80
- No files found in path: apaththatdoesnotexist
81
- """
74
+ """
75
+ No files found in path: apaththatdoesnotexist
76
+ """
@@ -1,8 +1,8 @@
1
+ @scapegoat
1
2
  Feature: Garmr scan
2
3
  Background:
3
- Given an attack "curl" exists
4
+ Given an attack "garmr" exists
4
5
  And scapegoat is running on port 9292
5
- And an attack "garmr" exists
6
6
  And I copy the attack files from the "examples/garmr" folder
7
7
  And the following attack files exist:
8
8
  | filename |
@@ -10,6 +10,6 @@ Feature: Garmr scan
10
10
  When I run `gauntlt`
11
11
  Then it should pass with:
12
12
  """
13
- 4 steps (4 passed)
13
+ 6 steps (6 passed)
14
14
  """
15
15
  And scapegoat should quit
@@ -28,7 +28,7 @@ Feature: nmap attack
28
28
  When I run `gauntlt tcp_ping_ports.attack`
29
29
  Then it should pass with:
30
30
  """
31
- 5 steps (5 passed)
31
+ 4 steps (4 passed)
32
32
  """
33
33
 
34
34
  Scenario: Handle XML output file
@@ -1,10 +1,10 @@
1
- @skip-on-jruby
1
+ @scapegoat
2
2
  Feature: sqlmap attack
3
3
 
4
4
  @slow
5
5
  Scenario:
6
- Given scapegoat is running on port 9292
7
- And an attack "sqlmap" exists
6
+ Given an attack "sqlmap" exists
7
+ And scapegoat is running on port 9292
8
8
  And I copy the attack files from the "examples/sqlmap" folder
9
9
  And the following attack files exist:
10
10
  | filename |
@@ -12,6 +12,6 @@ Feature: sqlmap attack
12
12
  When I run `gauntlt`
13
13
  Then it should pass with:
14
14
  """
15
- 4 steps (4 passed)
15
+ 5 steps (5 passed)
16
16
  """
17
17
  And scapegoat should quit
@@ -21,12 +21,23 @@ end
21
21
 
22
22
  require 'rack/handler/webrick'
23
23
  Given /^scapegoat is running on port (\d+)$/ do |port|
24
- Gauntlt::Scapegoat.set :port, port.to_i
25
- Gauntlt::Scapegoat.set :logging, nil
26
- @scapegoat_pid = Process.fork do
27
- trap(:INT) { ::Rack::Handler::WEBrick.shutdown }
28
- Gauntlt::Scapegoat.run!
29
- exit # manually exit; otherwise this sub-process will re-run the specs that haven't run yet.
24
+ if Scapegoat.running?
25
+ if Scapegoat.port != port.to_i
26
+ raise "Scapegoat already running on port #{Scapegoat.port} (not #{port})"
27
+ end
28
+ else
29
+ Scapegoat.set :port, port.to_i
30
+ Scapegoat.set :logging, nil
31
+
32
+ if RUBY_PLATFORM == 'java'
33
+ Thread.new { Scapegoat.run! }
34
+ else
35
+ @scapegoat_pid = Process.fork do
36
+ trap(:INT) { ::Rack::Handler::WEBrick.shutdown }
37
+ Scapegoat.run!
38
+ exit # manually exit; otherwise this sub-process will re-run the specs that haven't run yet.
39
+ end
40
+ end
30
41
  end
31
42
  end
32
43
 
@@ -1,3 +1,9 @@
1
1
  Before('@slow') do
2
2
  @aruba_timeout_seconds = 30
3
+ end
4
+
5
+ if RUBY_PLATFORM == 'java'
6
+ Before do
7
+ @aruba_timeout_seconds = 30
8
+ end
3
9
  end
@@ -1,44 +1,47 @@
1
1
  Feature: Run attacks by tag
2
2
 
3
3
  Background:
4
- Given an attack "nmap" exists
5
- And a file named "nmap.attack" with:
6
- """
7
- Feature: my nmap attacks
4
+ Given a file named "foobar.attack" with:
5
+ """
6
+ Feature: silly attack
8
7
 
9
- @foo
10
- Scenario: Foo
11
- Given the target hostname is "foo"
8
+ @foo
9
+ Scenario: Foo
10
+ Given the following profile:
11
+ | name | value |
12
+ | foo | bar |
12
13
 
13
- @bar
14
- Scenario: Bar
15
- Given the target hostname is "bar"
16
- """
14
+ @bar
15
+ Scenario: Bar
16
+ Given the following profile:
17
+ | name | value |
18
+ | bar | baz |
19
+ """
17
20
 
18
21
  Scenario: Run attack for one tag
19
22
  When I run `gauntlt --tags @foo`
20
23
  Then it should pass with:
21
- """
22
- Feature: my nmap attacks
24
+ """
25
+ Feature: silly attack
23
26
 
24
- @foo
25
- """
27
+ @foo
28
+ """
26
29
  And the stdout should contain:
27
- """
28
- 1 scenario (1 passed)
29
- 1 step (1 passed)
30
- """
30
+ """
31
+ 1 scenario (1 passed)
32
+ 1 step (1 passed)
33
+ """
31
34
 
32
35
  Scenario: Run attack by exluding one tag
33
36
  When I run `gauntlt --tags ~@foo`
34
37
  Then it should pass with:
35
- """
36
- Feature: my nmap attacks
38
+ """
39
+ Feature: silly attack
37
40
 
38
- @bar
39
- """
41
+ @bar
42
+ """
40
43
  And the stdout should contain:
41
- """
42
- 1 scenario (1 passed)
43
- 1 step (1 passed)
44
- """
44
+ """
45
+ 1 scenario (1 passed)
46
+ 1 step (1 passed)
47
+ """
data/gauntlt.gemspec CHANGED
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Gauntlt::VERSION
8
8
  s.authors = ["James Wickett", "Mani Tadayon"]
9
9
  s.email = ["james@ruggeddevops.org"]
10
- s.homepage = "https://github.com/thegauntlet/gauntlt"
10
+ s.homepage = "https://github.com/gauntlt/gauntlt"
11
11
  s.summary = %q{behaviour-driven security using cucumber}
12
12
  s.description = %q{Using standard Gherkin language to define security tests, gauntlt happily wraps cucumber functionality and provides a security testing framework that security engineers, developers and operations teams can collaborate on together.}
13
13
 
@@ -3,8 +3,7 @@ When /^"curl" is installed$/ do
3
3
  end
4
4
 
5
5
  When /^I launch a "curl" attack with:$/ do |command|
6
- command.gsub!('<hostname>', hostname)
7
- run command
6
+ run_with_profile command
8
7
  @raw_curl_response = all_output # aruba defines all_output
9
8
  end
10
9
 
@@ -3,7 +3,6 @@ When /^"garmr" is installed$/ do
3
3
  end
4
4
 
5
5
  When /^I launch a "garmr" attack with:$/ do |command|
6
- command.gsub!('<target_url>', target_url)
7
- run command
6
+ run_with_profile command
8
7
  @raw_garmr_output = all_output
9
8
  end
@@ -1,7 +1,19 @@
1
- When /^the target hostname is "(.*?)"$/ do |host|
2
- set_hostname host
1
+ require 'nokogiri'
2
+
3
+ Given /^the following profile:$/ do |table|
4
+ table.hashes.each do |hsh|
5
+ add_to_profile( hsh['name'], hsh['value'] )
6
+ end
3
7
  end
4
8
 
5
- When /^the target URL is "(.*?)"$/ do |u|
6
- set_target_url u
9
+ When /^the file "(.*?)" should contain XML:$/ do |filename, css_selectors|
10
+ css_selectors.hashes.each do |row|
11
+ assert_xml_includes(filename, row['css'])
12
+ end
7
13
  end
14
+
15
+ When /^the file "(.*?)" should not contain XML:$/ do |filename, css_selectors|
16
+ css_selectors.hashes.each do |row|
17
+ assert_xml_does_not_include(filename, row['css'])
18
+ end
19
+ end
@@ -1,6 +1,5 @@
1
1
  When /^I launch a "generic" attack with:$/ do |command|
2
- command.gsub!('<hostname>', hostname)
3
- run command
2
+ run_with_profile command
4
3
  end
5
4
 
6
5
  Given /^the "(.*?)" command line binary is installed$/ do |bin|
@@ -4,30 +4,6 @@ When /^"nmap" is installed$/ do
4
4
  ensure_cli_installed("nmap")
5
5
  end
6
6
 
7
- When /^the target tcp_ping_ports are "(.*?)"$/ do |ports|
8
- set_tcp_ping_ports ports
9
- end
10
-
11
7
  When /^I launch an "nmap" attack with:$/ do |command|
12
- # hostname defined in Gauntlt::Support::ProfileHelper
13
- command.gsub!('<hostname>', hostname)
14
-
15
- # tcp_ping_ports defined in Gauntlt::Support::ProfileHelper
16
- command.gsub!('<tcp_ping_ports>', tcp_ping_ports) if tcp_ping_ports
17
-
18
- run command
19
- end
20
-
21
- require 'nokogiri'
22
-
23
- When /^the file "(.*?)" should contain XML:$/ do |filename, css_selectors|
24
- css_selectors.hashes.each do |row|
25
- assert_xml_includes(filename, row['css'])
26
- end
27
- end
28
-
29
- When /^the file "(.*?)" should not contain XML:$/ do |filename, css_selectors|
30
- css_selectors.hashes.each do |row|
31
- assert_xml_does_not_include(filename, row['css'])
32
- end
8
+ run_with_profile command
33
9
  end
@@ -3,9 +3,7 @@ Given /^"sqlmap" is installed$/ do
3
3
  end
4
4
 
5
5
  When /^I launch an? "sqlmap" attack with:$/ do |command|
6
- sqlmap_path = path_to_python_script("sqlmap")
6
+ add_to_profile('sqlmap_path', path_to_python_script("sqlmap"))
7
7
 
8
- command.gsub!('<target_url>', target_url)
9
- command.gsub!('<sqlmap_path>', sqlmap_path)
10
- run command
8
+ run_with_profile command
11
9
  end
@@ -3,13 +3,7 @@ Given /^"sslyze" is installed$/ do
3
3
  end
4
4
 
5
5
  When /^I launch an "sslyze" attack with:$/ do |command|
6
- sslyze_path = path_to_python_script("sslyze")
6
+ add_to_profile( 'sslyze', path_to_python_script('sslyze') )
7
7
 
8
- command.gsub!('<hostname>', hostname)
9
- command.gsub!('<sslyze_path>', sslyze_path)
10
- run command
11
- end
12
-
13
- Then /^the key size should be at least (\d+)$/ do |arg1|
14
- pending # express the regexp above with the code you wish you had
8
+ run_with_profile command
15
9
  end
@@ -1,32 +1,23 @@
1
1
  module Gauntlt
2
2
  module Support
3
3
  module ProfileHelper
4
- def hostname
5
- raise "No host defined" if @hostname.nil?
6
-
7
- @hostname
8
- end
9
-
10
- def target_url
11
- raise "No target URL defined" if @target_url.nil?
12
-
13
- @target_url
4
+ def gauntlt_profile
5
+ @gauntlt_profile ||= {}
14
6
  end
15
7
 
16
- def tcp_ping_ports
17
- @tcp_ping_ports
8
+ def add_to_profile(k,v)
9
+ puts "Overwriting profile value for #{k}" if gauntlt_profile.has_key?(k)
10
+ gauntlt_profile[k] = v
18
11
  end
19
12
 
20
- def set_hostname(s)
21
- @hostname = s
22
- end
13
+ def run_with_profile(command_template)
14
+ command = command_template.dup
23
15
 
24
- def set_target_url(s)
25
- @target_url = s
26
- end
16
+ gauntlt_profile.each do |name, value|
17
+ command.gsub!( "<#{name}>", value )
18
+ end
27
19
 
28
- def set_tcp_ping_ports(s)
29
- @tcp_ping_ports = s
20
+ run command
30
21
  end
31
22
  end
32
23
  end
@@ -1,3 +1,3 @@
1
1
  module Gauntlt
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gauntlt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-10-27 00:00:00.000000000 Z
13
+ date: 2012-10-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: cucumber
@@ -168,6 +168,7 @@ files:
168
168
  - examples/nmap/simple.attack
169
169
  - examples/nmap/tcp_ping_ports.attack
170
170
  - examples/nmap/xml_output.attack
171
+ - examples/simplest.attack
171
172
  - examples/sqlmap/sqlmap.attack
172
173
  - examples/sslyze/sslyze.attack
173
174
  - features/attack.feature
@@ -184,11 +185,6 @@ files:
184
185
  - features/support/aruba.rb
185
186
  - features/support/env.rb
186
187
  - features/support/hooks.rb
187
- - features/support/scapegoat/scapegoat.rb
188
- - features/support/scapegoat/views/index.erb
189
- - features/support/scapegoat/views/inline_js.erb
190
- - features/support/scapegoat/views/layout.erb
191
- - features/support/scapegoat/views/sqlmap.erb
192
188
  - features/tags.feature
193
189
  - gauntlt.gemspec
194
190
  - gem_tasks/cucumber.rake
@@ -214,7 +210,7 @@ files:
214
210
  - test/test_helper.rb
215
211
  - test/tmf.rb
216
212
  - vendor/sslyze_output.README
217
- homepage: https://github.com/thegauntlet/gauntlt
213
+ homepage: https://github.com/gauntlt/gauntlt
218
214
  licenses: []
219
215
  post_install_message:
220
216
  rdoc_options: []
@@ -253,11 +249,6 @@ test_files:
253
249
  - features/support/aruba.rb
254
250
  - features/support/env.rb
255
251
  - features/support/hooks.rb
256
- - features/support/scapegoat/scapegoat.rb
257
- - features/support/scapegoat/views/index.erb
258
- - features/support/scapegoat/views/inline_js.erb
259
- - features/support/scapegoat/views/layout.erb
260
- - features/support/scapegoat/views/sqlmap.erb
261
252
  - features/tags.feature
262
253
  - test/gauntlt/attack_test.rb
263
254
  - test/gauntlt_test.rb
@@ -1,59 +0,0 @@
1
- if RUBY_PLATFORM != 'java'
2
-
3
- require 'rubygems'
4
- require 'sinatra/base'
5
- require 'sqlite3'
6
-
7
-
8
- $DB = SQLite3::Database.new "goat.$DB"
9
-
10
- # Create a database
11
- rows = $DB.execute <<-SQL
12
- create table if not exists numbers (
13
- id INTEGER PRIMARY KEY AUTOINCREMENT,
14
- name varchar(30),
15
- val int
16
- );
17
- SQL
18
-
19
- # Execute a few inserts
20
- {
21
- "one" => 1,
22
- "two" => 2,
23
- }.each do |pair|
24
- $DB.execute "insert into numbers(id, name, val) values ( NULL, ?, ? )", pair
25
- end
26
-
27
- module Gauntlt
28
- end
29
-
30
- class Gauntlt::Scapegoat < Sinatra::Base
31
- helpers do
32
- def page_title
33
- end
34
- end
35
-
36
- get '/' do
37
- erb :index
38
- end
39
-
40
- # sqlmap.py -u "http://localhost:9292/sql-injection?number_id=1" --dbms sqlite
41
- get '/sql-injection' do
42
- query = if params['number_id']
43
- "select * from numbers where id = #{params['number_id']}"
44
- elsif params['sql']
45
- params['sql']
46
- end
47
-
48
- result = $DB.execute(query) if query
49
-
50
- erb :sqlmap, :locals => {:result => result}
51
- end
52
-
53
- get '/inline-js' do
54
- erb :inline_js
55
- end
56
-
57
- run! if app_file == $0
58
- end
59
- end
@@ -1,17 +0,0 @@
1
- <pre>
2
-
3
- ______________________
4
- < Welcome to scapegoat >
5
- ----------------------
6
- \\
7
- \\ (__)
8
- (\\/)
9
- /-------\\/
10
- / | ||
11
- / ||----||
12
- ~~ ~~
13
-
14
-
15
- Available goats: * <a href="/sql-injection">sql-goat</a>
16
- * <a href="/inline-js">inline js</a>
17
- </pre>
@@ -1,3 +0,0 @@
1
- <script>
2
- alert("hi from inline javascript");
3
- </script>
@@ -1,10 +0,0 @@
1
- <html>
2
- <head>
3
- <title>
4
- <%= page_title || 'scapegoat' %>
5
- </title>
6
- </head>
7
- <body>
8
- <%= yield %>
9
- </body>
10
- </html>
@@ -1,25 +0,0 @@
1
- <h1>The form on this page is vulnerable to SQL injection</h1>
2
- <h2>Received params</h2>
3
- <pre id='received-params'>
4
- <%= params.inspect %>
5
- </pre>
6
- <h2>Data returned from database</h2>
7
- <pre id='result'>
8
- <%= result %>
9
- </pre>
10
- <br />
11
- <br />
12
- <form>
13
- <label>
14
- <fieldset>
15
- <legend>Enter your SQL injection attack here:</legend>
16
- <label>
17
- Number to look up
18
- <input name='number_id' />
19
- </label>
20
- </fieldset>
21
- <fieldset>
22
- <input type='submit' />
23
- </fieldset>
24
- </label>
25
- </form>