-
-
Save thermistor/8362077dcd396a71b6b6d3e604ed151c to your computer and use it in GitHub Desktop.
Example nmap scan of the monitorama.eu website written as an rspec test
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
tarting Nmap 6.40 ( http://nmap.org ) at 2013-11-15 09:36 GMT | |
Nmap scan report for monitorama.eu (141.101.116.49) | |
Host is up (0.012s latency). | |
Other addresses for monitorama.eu (not scanned): 141.101.117.49 | |
PORT STATE SERVICE | |
20/tcp filtered ftp-data | |
21/tcp filtered ftp | |
22/tcp filtered ssh | |
23/tcp filtered telnet | |
25/tcp filtered smtp | |
80/tcp open http | |
110/tcp filtered pop3 | |
443/tcp filtered https | |
512/tcp filtered exec | |
522/tcp filtered ulp | |
1080/tcp filtered socks | |
8080/tcp open http-proxy | |
Nmap done: 1 IP address (1 host up) scanned in 2.45 seconds | |
F. | |
Failures: | |
1) the monitorama.eu website should have one port open | |
Failure/Error: @open_ports.should have(1).items | |
expected 1 items, got 12 | |
# ./nmap-rspec.rb:24:in `block (2 levels) in <top (required)>' | |
Finished in 2.47 seconds | |
2 examples, 1 failure | |
Failed examples: | |
rspec ./nmap-rspec.rb:23 # the monitorama.eu website should have one port open |
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
require 'nmap/program' | |
require 'nmap/xml' | |
describe "the monitorama.eu website" do | |
before(:all) do | |
Nmap::Program.scan do |nmap| | |
nmap.xml = 'scan.xml' | |
nmap.ports = [20,21,22,23,25,80,110,443,512,522,8080,1080] | |
nmap.targets = 'monitorama.eu' | |
end | |
@open_ports = [] | |
Nmap::XML.new('scan.xml') do |xml| | |
xml.each_host do |host| | |
host.each_port do |port| | |
@open_ports << port.number | |
end | |
end | |
end | |
end | |
it "should have one port open" do | |
@open_ports.should have(1).items | |
end | |
it "should have port 80 open" do | |
@open_ports.should include(80) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment