Skip to content

Instantly share code, notes, and snippets.

@garethr
Last active July 20, 2020 18:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save garethr/6579190 to your computer and use it in GitHub Desktop.
Save garethr/6579190 to your computer and use it in GitHub Desktop.
Example nmap scan of the monitorama.eu website written as an rspec test
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
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