Skip to content

Commit

Permalink
Add a generic profile step and clean up cukes
Browse files Browse the repository at this point in the history
  • Loading branch information
bowsersenior committed Oct 28, 2012
1 parent 5f871ae commit 5c3fcae
Show file tree
Hide file tree
Showing 23 changed files with 147 additions and 177 deletions.
4 changes: 3 additions & 1 deletion examples/curl/cookies.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: Evaluate received cookies against expected.

Background:
Given "curl" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario: Verify server is returning the cookies expected
When I launch a "curl" attack with:
Expand Down
4 changes: 3 additions & 1 deletion examples/curl/simple.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: Launch curl attack

Background:
Given "curl" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario: Verify a 301 is received from a curl
When I launch a "curl" attack with:
Expand Down
4 changes: 3 additions & 1 deletion examples/curl/verbs.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: Evaluate responses to various HTTP methods.

Background:
Given "curl" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario Outline: Verify server responds correctly to various HTTP methods
When I launch a "curl" attack with:
Expand Down
4 changes: 3 additions & 1 deletion examples/garmr/garmr.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: Run garmr scan on a URL

Scenario: Use Garmr to scan a website for basic security requirements
Given "garmr" is installed
And the target URL is "http://localhost:9292/inline-js"
And the following profile:
| name | value |
| target_url | http://localhost:9292/inline-js |
When I launch a "garmr" attack with:
"""
garmr -u <target_url> -o my_garmr_output.xml
Expand Down
4 changes: 3 additions & 1 deletion examples/generic/generic.attack
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ This attack adapter allows for any command line binary to be executed and the ou

Background:
Given the "ping" command line binary is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario: Verify a 301 is received from a curl
When I launch a "generic" attack with:
Expand Down
20 changes: 4 additions & 16 deletions examples/nmap/nmap.attack
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
Feature: nmap attacks for example.com
Background:
Given "nmap" is installed
And the target hostname is "google.com"
And the target tcp_ping_ports are "22,25,80,443"

And the following profile:
| name | value |
| hostname | google.com |
| tcp_ping_ports | 22,25,80,443 |

Scenario: Verify server is open on expected set of ports using the nmap fast flag
When I launch an "nmap" attack with:
Expand All @@ -30,19 +31,6 @@ Feature: nmap attacks for example.com
25/tcp
"""

Scenario: Using tcp syn ping scan and the nmap fast flag
When I launch an "nmap" attack with:
"""
nmap -F -PS<tcp_ping_ports> <hostname>
"""
Then the output should contain:
"""
80/tcp open http
443/tcp open https
3128/tcp open squid-http
8080/tcp open http-proxy
"""

Scenario: Output to XML
When I launch an "nmap" attack with:
"""
Expand Down
4 changes: 3 additions & 1 deletion examples/nmap/os_detection.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: OS detection

Background:
Given "nmap" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

@slow
Scenario: Detect OS
Expand Down
4 changes: 3 additions & 1 deletion examples/nmap/simple.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: simple nmap attack (sanity check)

Background:
Given "nmap" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario: Verify server is available on standard web ports
When I launch an "nmap" attack with:
Expand Down
14 changes: 9 additions & 5 deletions examples/nmap/tcp_ping_ports.attack
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
@slow
Feature: nmap attacks for example.com
Background:
Given "nmap" is installed
And the target hostname is "google.com"
And the target tcp_ping_ports are "22,25,80,443"
And the following profile:
| name | value |
| hostname | google.com |
| tcp_ping_ports | 22,25,80,443 |

@slow
Scenario: Using tcp syn ping scan and the nmap fast flag
When I launch an "nmap" attack with:
"""
nmap -F -PS<tcp_ping_ports> <hostname>
"""
Then the output should contain:
"""
80/tcp
"""
21/tcp open ftp
80/tcp open http
443/tcp open https
"""
4 changes: 3 additions & 1 deletion examples/nmap/xml_output.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: XML output

Background:
Given "nmap" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario: Output to XML
When I launch an "nmap" attack with:
Expand Down
4 changes: 3 additions & 1 deletion examples/sqlmap/sqlmap.attack
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ Feature: Run sqlmap against a target

Scenario: Identify SQL injection vulnerabilities
Given "sqlmap" is installed
And the target URL is "http://localhost:9292/sql-injection?number_id=1"
And the following profile:
| name | value |
| target_url | http://localhost:9292/sql-injection?number_id=1 |
When I launch a "sqlmap" attack with:
"""
python <sqlmap_path> -u <target_url> --dbms sqlite --batch -v 0
Expand Down
14 changes: 4 additions & 10 deletions examples/sslyze/sslyze.attack
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ Feature: Run sslyze against a target

Background:
Given "sslyze" is installed
And the target hostname is "google.com"
And the following profile:
| name | value |
| hostname | google.com |

Scenario: Ensure no anonymous certificates
When I launch an "sslyze" attack with:
Expand All @@ -12,12 +14,4 @@ Scenario: Ensure no anonymous certificates
Then the output should not contain:
"""
Anon
"""

# Scenario: Make sure that the certificate key size is at least 2048
# Given the target hostname is "google.com"
# When I launch an "sslyze" attack with:
# """
# python <sslyze_path> <hostname>:443
# """
# Then the key size should be at least 2048
"""
79 changes: 37 additions & 42 deletions features/attack.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,65 @@ Feature: Verify the attack behaviour is correct
nmap
"""

@slow
Scenario: Run attack
Given an attack "nmap" exists
And a file named "nmap.attack" with:
"""
Feature: my nmap attacks
Scenario: nmap attack works
Given "nmap" is installed
And the target hostname is "google.com"
When I launch an "nmap" attack with:
\"\"\"
nmap -p 80,443 <hostname>
\"\"\"
Then the output should contain:
\"\"\"
80/tcp open http
443/tcp open https
\"\"\"
"""
"""
Feature: simplest attack possible
Scenario:
When I launch a "generic" attack with:
\"\"\"
ls -a
\"\"\"
Then the output should contain:
\"\"\"
.
\"\"\"
"""
When I run `gauntlt`
Then it should pass with:
"""
4 steps (4 passed)
"""
"""
2 steps (2 passed)
"""

Scenario: Run attack with custom filename
Given an attack "nmap" exists
And a file named "my.awesome.attack.file" with:
"""
Feature: my nmap attacks
Scenario: nmap attack works
Given "nmap" is installed
"""
"""
Feature: my nmap attacks
Scenario: nmap attack works
Given "nmap" is installed
"""
When I run `gauntlt my.awesome.attack.file`
Then it should pass with:
"""
1 step (1 passed)
"""
"""
1 step (1 passed)
"""

Scenario: Run attack with undefined steps
Given an attack "nmap" exists
And a file named "nmap.attack" with:
"""
Feature: my non-existent attack
Scenario: Fail on undefined step definition
Given "thisattackwouldneverexist" is installed
"""
"""
Feature: my non-existent attack
Scenario: Fail on undefined step definition
Given "thisattackwouldneverexist" is installed
"""
When I run `gauntlt`
Then it should fail with:
"""
Bad or undefined attack!
"""

"""
Bad or undefined attack!
"""

Scenario: No attack files in default path
When I run `gauntlt`
Then it should fail with:
"""
No files found in path
"""
"""
No files found in path
"""

Scenario: No attack files in specified path
When I run `gauntlt apaththatdoesnotexist`
Then it should fail with:
"""
No files found in path: apaththatdoesnotexist
"""
"""
No files found in path: apaththatdoesnotexist
"""
2 changes: 1 addition & 1 deletion features/attacks/nmap.feature
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: nmap attack
When I run `gauntlt tcp_ping_ports.attack`
Then it should pass with:
"""
5 steps (5 passed)
4 steps (4 passed)
"""

Scenario: Handle XML output file
Expand Down
57 changes: 30 additions & 27 deletions features/tags.feature
Original file line number Diff line number Diff line change
@@ -1,44 +1,47 @@
Feature: Run attacks by tag

Background:
Given an attack "nmap" exists
And a file named "nmap.attack" with:
"""
Feature: my nmap attacks
Given a file named "foobar.attack" with:
"""
Feature: silly attack
@foo
Scenario: Foo
Given the target hostname is "foo"
@foo
Scenario: Foo
Given the following profile:
| name | value |
| foo | bar |
@bar
Scenario: Bar
Given the target hostname is "bar"
"""
@bar
Scenario: Bar
Given the following profile:
| name | value |
| bar | baz |
"""

Scenario: Run attack for one tag
When I run `gauntlt --tags @foo`
Then it should pass with:
"""
Feature: my nmap attacks
"""
Feature: silly attack
@foo
"""
@foo
"""
And the stdout should contain:
"""
1 scenario (1 passed)
1 step (1 passed)
"""
"""
1 scenario (1 passed)
1 step (1 passed)
"""

Scenario: Run attack by exluding one tag
When I run `gauntlt --tags ~@foo`
Then it should pass with:
"""
Feature: my nmap attacks
"""
Feature: silly attack
@bar
"""
@bar
"""
And the stdout should contain:
"""
1 scenario (1 passed)
1 step (1 passed)
"""
"""
1 scenario (1 passed)
1 step (1 passed)
"""
3 changes: 1 addition & 2 deletions lib/gauntlt/attack_adapters/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
end

When /^I launch a "curl" attack with:$/ do |command|
command.gsub!('<hostname>', hostname)
run command
run_with_profile command
@raw_curl_response = all_output # aruba defines all_output
end

Expand Down
Loading

0 comments on commit 5c3fcae

Please sign in to comment.