ruby-nmap 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog.md CHANGED
@@ -1,3 +1,8 @@
1
+ ### 0.3.0 / 2010-11-08
2
+
3
+ * Added {Nmap::Host#scripts}.
4
+ * Added {Nmap::Port#scripts}.
5
+
1
6
  ### 0.2.0 / 2010-10-29
2
7
 
3
8
  * Require nokogiri >= 1.3.0.
data/README.md CHANGED
@@ -47,6 +47,30 @@ Parse Nmap XML scan files:
47
47
  end
48
48
  end
49
49
 
50
+ Print out NSE script output from an XML scan file:
51
+
52
+ require 'nmap/xml'
53
+
54
+ Nmap::XML.new('nse.xml') do |xml|
55
+ xml.each_host do |host|
56
+ puts "[#{host.ip}]"
57
+
58
+ host.scripts.each do |name,output|
59
+ output.each_line { |line| puts " #{line}" }
60
+ end
61
+
62
+ host.each_port do |port|
63
+ puts " [#{port.number}/#{port.protocol}]"
64
+
65
+ port.scripts.each do |name,output|
66
+ puts " [#{name}]"
67
+
68
+ output.each_line { |line| puts " #{line}" }
69
+ end
70
+ end
71
+ end
72
+ end
73
+
50
74
  ## Requirements
51
75
 
52
76
  * [nmap](http://www.insecure.org/)
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
 
4
4
  begin
5
- gem 'ore-tasks', '~> 0.1.2'
5
+ gem 'ore-tasks', '~> 0.2.0'
6
6
  require 'ore/tasks'
7
7
 
8
8
  Ore::Tasks.new
data/gemspec.yml CHANGED
@@ -17,7 +17,6 @@ dependencies:
17
17
  rprogram: ~> 0.2.0
18
18
 
19
19
  development_dependencies:
20
- ore: ~> 0.2.1
21
- ore-tasks: ~> 0.1.2
20
+ ore-tasks: ~> 0.2.0
22
21
  rspec: ~> 2.0.0
23
22
  yard: ~> 0.6.0
data/lib/nmap/host.rb CHANGED
@@ -243,7 +243,7 @@ module Nmap
243
243
  return enum_for(:each_port) unless block_given?
244
244
 
245
245
  @node.xpath("ports/port").each do |port|
246
- yield create_port(port)
246
+ yield Port.new(port)
247
247
  end
248
248
 
249
249
  return self
@@ -276,7 +276,7 @@ module Nmap
276
276
  return enum_for(:each_open_port) unless block_given?
277
277
 
278
278
  @node.xpath("ports/port[state/@state='open']").each do |port|
279
- yield create_port(port)
279
+ yield Port.new(port)
280
280
  end
281
281
 
282
282
  return self
@@ -309,7 +309,7 @@ module Nmap
309
309
  return enum_for(:each_tcp_port) unless block_given?
310
310
 
311
311
  @node.xpath("ports/port[@protocol='tcp']").each do |port|
312
- yield create_port(port)
312
+ yield Port.new(port)
313
313
  end
314
314
 
315
315
  return self
@@ -342,7 +342,7 @@ module Nmap
342
342
  return enum_for(:each_udp_port) unless block_given?
343
343
 
344
344
  @node.xpath("ports/port[@protocol='udp']").each do |port|
345
- yield create_port(port)
345
+ yield Port.new(port)
346
346
  end
347
347
 
348
348
  return self
@@ -368,42 +368,35 @@ module Nmap
368
368
  end
369
369
 
370
370
  #
371
- # Converts the host to a String.
371
+ # The output from the NSE scripts ran against the host.
372
372
  #
373
- # @return [String]
374
- # The address of the host.
373
+ # @return [Hash{String => String}]
374
+ # The NSE script names and output.
375
375
  #
376
- # @see address
376
+ # @since 0.3.0
377
377
  #
378
- def to_s
379
- address.to_s
380
- end
378
+ def scripts
379
+ unless @scripts
380
+ @scripts = {}
381
381
 
382
- protected
382
+ @node.xpath('hostscript/script').each do |script|
383
+ @scripts[script['id']] = script['output']
384
+ end
385
+ end
386
+
387
+ return @scripts
388
+ end
383
389
 
384
390
  #
385
- # Creates a new Port object around a node.
391
+ # Converts the host to a String.
386
392
  #
387
- # @param [Nokogiri::XML::Node] node
388
- # The node to create the Port object around.
393
+ # @return [String]
394
+ # The address of the host.
389
395
  #
390
- # @return [Port]
391
- # The port object.
396
+ # @see address
392
397
  #
393
- def create_port(node)
394
- state = node.at('state')
395
-
396
- if (service = node.at('service/@name'))
397
- service = service.inner_text
398
- end
399
-
400
- return Port.new(
401
- node['protocol'].to_sym,
402
- node['portid'].to_i,
403
- state['state'].to_sym,
404
- state['reason'],
405
- service
406
- )
398
+ def to_s
399
+ address.to_s
407
400
  end
408
401
 
409
402
  end
data/lib/nmap/port.rb CHANGED
@@ -1,57 +1,90 @@
1
1
  module Nmap
2
2
  class Port
3
3
 
4
- # The protocol the port runs on
5
- attr_reader :protocol
6
-
7
- # The port number
8
- attr_reader :number
9
-
10
- # The state of the port
11
- attr_reader :state
4
+ #
5
+ # Creates a new Port object.
6
+ #
7
+ # @param [Nokogiri::XML::Element] node
8
+ # The XML `port` element.
9
+ #
10
+ def initialize(node)
11
+ @node = node
12
+ end
12
13
 
13
- # The reason the port was discovered
14
- attr_reader :reason
14
+ #
15
+ # The protocol the port runs on
16
+ #
17
+ # @return [Symbol]
18
+ # The protocol of the port.
19
+ #
20
+ def protocol
21
+ @protocol ||= @node['protocol'].to_sym
22
+ end
15
23
 
16
- # The service the port provides
17
- attr_reader :service
24
+ #
25
+ # The port number.
26
+ #
27
+ # @return [Integer]
28
+ # The number of the port.
29
+ #
30
+ def number
31
+ @number ||= @node['portid'].to_i
32
+ end
18
33
 
19
34
  #
20
- # Creates a new Port object.
35
+ # The state of the port.
21
36
  #
22
- # @param [Integer] protocol
23
- # The protocol the port runs on.
37
+ # @return [Symbol]
38
+ # The state of the port (`:open`, `:filtered` or `:closed`).
24
39
  #
25
- # @param [Integer] number
26
- # The port number.
40
+ def state
41
+ @state ||= @node.at('state/@state').inner_text.to_sym
42
+ end
43
+
27
44
  #
28
- # @param [Symbol] state
29
- # The state the port is in.
45
+ # The reason the port was discovered.
30
46
  #
31
- # @param [String] reason
32
- # The reason for the ports state.
47
+ # @return [String]
48
+ # How the port was discovered.
49
+ #
50
+ def reason
51
+ @reason ||= @node.at('state/@reason').inner_text
52
+ end
53
+
33
54
  #
34
- # @param [String] service
35
- # The name of the service that runs on the port.
55
+ # The service the port provides.
36
56
  #
37
- def initialize(protocol,number,state,reason,service=nil)
38
- @protocol = protocol
39
- @number = number
40
- @state = state
41
- @reason = reason
42
- @service = service
57
+ # @return [String]
58
+ # The service detected on the port.
59
+ #
60
+ def service
61
+ @service ||= if (service = @node.at('service/@name'))
62
+ service.inner_text
63
+ end
43
64
  end
44
65
 
45
66
  #
46
- # Converts the port to an Integer.
67
+ # The output from the NSE scripts ran against the open port.
47
68
  #
48
- # @return [Integer]
49
- # The port number.
69
+ # @return [Hash{String => String}]
70
+ # The NSE script names and output.
50
71
  #
51
- def to_i
52
- @number.to_i
72
+ # @since 0.3.0
73
+ #
74
+ def scripts
75
+ unless @scripts
76
+ @scripts = {}
77
+
78
+ @node.xpath('script').each do |script|
79
+ @scripts[script['id']] = script['output']
80
+ end
81
+ end
82
+
83
+ return @scripts
53
84
  end
54
85
 
86
+ alias to_i number
87
+
55
88
  #
56
89
  # Converts the port to a String.
57
90
  #
@@ -59,7 +92,7 @@ module Nmap
59
92
  # The port number.
60
93
  #
61
94
  def to_s
62
- @number.to_s
95
+ number.to_s
63
96
  end
64
97
 
65
98
  end
data/lib/nmap/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Nmap
2
2
  # ruby-nmap version
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
data/ruby-nmap.gemspec CHANGED
@@ -6,5 +6,5 @@ begin
6
6
  end
7
7
  rescue NameError
8
8
  STDERR.puts "The 'ruby-nmap.gemspec' file requires Ore."
9
- STDERR.puts "Run `gem install ore` to install Ore."
9
+ STDERR.puts "Run `gem install ore-core` to install Ore."
10
10
  end
@@ -0,0 +1,94 @@
1
+ <?xml version="1.0" ?>
2
+ <?xml-stylesheet href="file:///usr/share/nmap/nmap.xsl" type="text/xsl"?>
3
+ <!-- Nmap 5.21 scan initiated Mon Nov 8 18:37:05 2010 as: nmap -sV -sC -&#45;script=all -vv -oX nse.xml 173.255.192.6 -->
4
+ <nmaprun scanner="nmap" args="nmap -sV -sC -&#45;script=all -vv -oX nse.xml 173.255.192.6" start="1289270225" startstr="Mon Nov 8 18:37:05 2010" version="5.21" xmloutputversion="1.03">
5
+ <scaninfo type="syn" protocol="tcp" numservices="1000" services="1,3-4,6-7,9,13,17,19-26,30,32-33,37,42-43,49,53,70,79-85,88-90,99-100,106,109-111,113,119,125,135,139,143-144,146,161,163,179,199,211-212,222,254-256,259,264,280,301,306,311,340,366,389,406-407,416-417,425,427,443-445,458,464-465,481,497,500,512-515,524,541,543-545,548,554-555,563,587,593,616-617,625,631,636,646,648,666-668,683,687,691,700,705,711,714,720,722,726,749,765,777,783,787,800-801,808,843,873,880,888,898,900-903,911-912,981,987,990,992-993,995,999-1002,1007,1009-1011,1021-1100,1102,1104-1108,1110-1114,1117,1119,1121-1124,1126,1130-1132,1137-1138,1141,1145,1147-1149,1151-1152,1154,1163-1166,1169,1174-1175,1183,1185-1187,1192,1198-1199,1201,1213,1216-1218,1233-1234,1236,1244,1247-1248,1259,1271-1272,1277,1287,1296,1300-1301,1309-1311,1322,1328,1334,1352,1417,1433-1434,1443,1455,1461,1494,1500-1501,1503,1521,1524,1533,1556,1580,1583,1594,1600,1641,1658,1666,1687-1688,1700,1717-1721,1723,1755,1761,1782-1783,1801,1805,1812,1839-1840,1862-1864,1875,1900,1914,1935,1947,1971-1972,1974,1984,1998-2010,2013,2020-2022,2030,2033-2035,2038,2040-2043,2045-2049,2065,2068,2099-2100,2103,2105-2107,2111,2119,2121,2126,2135,2144,2160-2161,2170,2179,2190-2191,2196,2200,2222,2251,2260,2288,2301,2323,2366,2381-2383,2393-2394,2399,2401,2492,2500,2522,2525,2557,2601-2602,2604-2605,2607-2608,2638,2701-2702,2710,2717-2718,2725,2800,2809,2811,2869,2875,2909-2910,2920,2967-2968,2998,3000-3001,3003,3005-3007,3011,3013,3017,3030-3031,3050,3052,3071,3077,3128,3168,3211,3221,3260-3261,3268-3269,3283,3300-3301,3306,3322-3325,3333,3351,3367,3369-3372,3389-3390,3404,3476,3493,3517,3527,3546,3551,3580,3659,3689-3690,3703,3737,3766,3784,3800-3801,3809,3814,3826-3828,3851,3869,3871,3878,3880,3889,3905,3914,3918,3920,3945,3971,3986,3995,3998,4000-4006,4045,4111,4125-4126,4129,4224,4242,4279,4321,4343,4443-4446,4449,4550,4567,4662,4848,4899-4900,4998,5000-5004,5009,5030,5033,5050-5051,5054,5060-5061,5080,5087,5100-5102,5120,5190,5200,5214,5221-5222,5225-5226,5269,5280,5298,5357,5405,5414,5431-5432,5440,5500,5510,5544,5550,5555,5560,5566,5631,5633,5666,5678-5679,5718,5730,5800-5802,5810-5811,5815,5822,5825,5850,5859,5862,5877,5900-5904,5906-5907,5910-5911,5915,5922,5925,5950,5952,5959-5963,5987-5989,5998-6007,6009,6025,6059,6100-6101,6106,6112,6123,6129,6156,6346,6389,6502,6510,6543,6547,6565-6567,6580,6646,6666-6669,6689,6692,6699,6779,6788-6789,6792,6839,6881,6901,6969,7000-7002,7004,7007,7019,7025,7070,7100,7103,7106,7200-7201,7402,7435,7443,7496,7512,7625,7627,7676,7741,7777-7778,7800,7911,7920-7921,7937-7938,7999-8002,8007-8011,8021-8022,8031,8042,8045,8080-8090,8093,8099-8100,8180-8181,8192-8194,8200,8222,8254,8290-8292,8300,8333,8383,8400,8402,8443,8500,8600,8649,8651-8652,8654,8701,8800,8873,8888,8899,8994,9000-9003,9009-9011,9040,9050,9071,9080-9081,9090-9091,9099-9103,9110-9111,9200,9207,9220,9290,9415,9418,9485,9500,9502-9503,9535,9575,9593-9595,9618,9666,9876-9878,9898,9900,9917,9943-9944,9968,9998-10004,10009-10010,10012,10024-10025,10082,10180,10215,10243,10566,10616-10617,10621,10626,10628-10629,10778,11110-11111,11967,12000,12174,12265,12345,13456,13722,13782-13783,14000,14238,14441-14442,15000,15002-15004,15660,15742,16000-16001,16012,16016,16018,16080,16113,16992-16993,17877,17988,18040,18101,18988,19101,19283,19315,19350,19780,19801,19842,20000,20005,20031,20221-20222,20828,21571,22939,23502,24444,24800,25734-25735,26214,27000,27352-27353,27355-27356,27715,28201,30000,30718,30951,31038,31337,32768-32785,33354,33899,34571-34573,35500,38292,40193,40911,41511,42510,44176,44442-44443,44501,45100,48080,49152-49161,49163,49165,49167,49175-49176,49400,49999-50003,50006,50300,50389,50500,50636,50800,51103,51493,52673,52822,52848,52869,54045,54328,55055-55056,55555,55600,56737-56738,57294,57797,58080,60020,60443,61532,61900,62078,63331,64623,64680,65000,65129,65389" />
6
+ <verbose level="2" />
7
+ <debugging level="0" />
8
+ <taskbegin task="Ping Scan" time="1289270225" />
9
+ <taskend task="Ping Scan" time="1289270225" extrainfo="1 total hosts" />
10
+ <taskbegin task="Parallel DNS resolution of 1 host." time="1289270225" />
11
+ <taskend task="Parallel DNS resolution of 1 host." time="1289270225" />
12
+ <taskbegin task="SYN Stealth Scan" time="1289270225" />
13
+ <taskprogress task="SYN Stealth Scan" time="1289270256" percent="8.15" remaining="350" etc="1289270605" />
14
+ <taskprogress task="SYN Stealth Scan" time="1289270286" percent="11.75" remaining="459" etc="1289270744" />
15
+ <taskprogress task="SYN Stealth Scan" time="1289270316" percent="15.45" remaining="498" etc="1289270814" />
16
+ <taskprogress task="SYN Stealth Scan" time="1289270475" percent="34.80" remaining="469" etc="1289270943" />
17
+ <taskprogress task="SYN Stealth Scan" time="1289270529" percent="41.35" remaining="432" etc="1289270960" />
18
+ <taskprogress task="SYN Stealth Scan" time="1289270577" percent="47.20" remaining="394" etc="1289270971" />
19
+ <taskprogress task="SYN Stealth Scan" time="1289270973" percent="67.55" remaining="360" etc="1289271332" />
20
+ <taskprogress task="SYN Stealth Scan" time="1289271138" percent="75.05" remaining="304" etc="1289271442" />
21
+ <taskprogress task="SYN Stealth Scan" time="1289271273" percent="81.20" remaining="243" etc="1289271516" />
22
+ <taskprogress task="SYN Stealth Scan" time="1289271399" percent="86.90" remaining="177" etc="1289271576" />
23
+ <taskprogress task="SYN Stealth Scan" time="1289271516" percent="92.25" remaining="109" etc="1289271624" />
24
+ <taskprogress task="SYN Stealth Scan" time="1289271624" percent="97.15" remaining="42" etc="1289271665" />
25
+ <taskend task="SYN Stealth Scan" time="1289271692" extrainfo="1000 total ports" />
26
+ <taskbegin task="Service scan" time="1289271692" />
27
+ <taskend task="Service scan" time="1289271712" extrainfo="7 services on 1 host" />
28
+ <taskbegin task="NSE" time="1289271713" />
29
+ <taskprogress task="NSE" time="1289271744" percent="92.50" remaining="3" etc="1289271747" />
30
+ <taskprogress task="NSE" time="1289271774" percent="95.00" remaining="4" etc="1289271777" />
31
+ <taskprogress task="NSE" time="1289271804" percent="95.00" remaining="5" etc="1289271809" />
32
+ <taskprogress task="NSE" time="1289271834" percent="95.00" remaining="7" etc="1289271840" />
33
+ <taskprogress task="NSE" time="1289271864" percent="95.00" remaining="8" etc="1289271872" />
34
+ <taskprogress task="NSE" time="1289271894" percent="97.50" remaining="5" etc="1289271899" />
35
+ <taskprogress task="NSE" time="1289271924" percent="97.50" remaining="6" etc="1289271929" />
36
+ <taskprogress task="NSE" time="1289271954" percent="97.50" remaining="7" etc="1289271960" />
37
+ <taskprogress task="NSE" time="1289271984" percent="97.50" remaining="7" etc="1289271991" />
38
+ <taskprogress task="NSE" time="1289272014" percent="97.50" remaining="8" etc="1289272022" />
39
+ <taskprogress task="NSE" time="1289272044" percent="97.50" remaining="9" etc="1289272052" />
40
+ <taskprogress task="NSE" time="1289272074" percent="97.50" remaining="10" etc="1289272083" />
41
+ <taskprogress task="NSE" time="1289272104" percent="97.50" remaining="11" etc="1289272114" />
42
+ <taskprogress task="NSE" time="1289272134" percent="97.50" remaining="11" etc="1289272145" />
43
+ <taskprogress task="NSE" time="1289272164" percent="97.50" remaining="12" etc="1289272176" />
44
+ <taskprogress task="NSE" time="1289272194" percent="97.50" remaining="13" etc="1289272206" />
45
+ <taskprogress task="NSE" time="1289272224" percent="97.50" remaining="14" etc="1289272237" />
46
+ <taskprogress task="NSE" time="1289272254" percent="97.50" remaining="14" etc="1289272268" />
47
+ <taskprogress task="NSE" time="1289272284" percent="97.50" remaining="15" etc="1289272299" />
48
+ <taskprogress task="NSE" time="1289272314" percent="97.50" remaining="16" etc="1289272329" />
49
+ <taskprogress task="NSE" time="1289272344" percent="97.50" remaining="17" etc="1289272360" />
50
+ <taskprogress task="NSE" time="1289272374" percent="97.50" remaining="17" etc="1289272391" />
51
+ <taskprogress task="NSE" time="1289272404" percent="97.50" remaining="18" etc="1289272422" />
52
+ <taskprogress task="NSE" time="1289272434" percent="97.50" remaining="19" etc="1289272452" />
53
+ <taskprogress task="NSE" time="1289272464" percent="97.50" remaining="20" etc="1289272483" />
54
+ <taskprogress task="NSE" time="1289272494" percent="97.50" remaining="21" etc="1289272514" />
55
+ <taskprogress task="NSE" time="1289272524" percent="97.50" remaining="21" etc="1289272545" />
56
+ <taskprogress task="NSE" time="1289272554" percent="97.50" remaining="22" etc="1289272576" />
57
+ <taskprogress task="NSE" time="1289272584" percent="97.50" remaining="23" etc="1289272606" />
58
+ <taskprogress task="NSE" time="1289272614" percent="97.50" remaining="24" etc="1289272637" />
59
+ <taskprogress task="NSE" time="1289272644" percent="97.50" remaining="24" etc="1289272668" />
60
+ <taskprogress task="NSE" time="1289272674" percent="97.50" remaining="25" etc="1289272699" />
61
+ <taskprogress task="NSE" time="1289272704" percent="97.50" remaining="26" etc="1289272729" />
62
+ <taskprogress task="NSE" time="1289272734" percent="97.50" remaining="27" etc="1289272760" />
63
+ <taskprogress task="NSE" time="1289272764" percent="97.50" remaining="27" etc="1289272791" />
64
+ <taskprogress task="NSE" time="1289272794" percent="97.50" remaining="28" etc="1289272822" />
65
+ <taskprogress task="NSE" time="1289272824" percent="97.50" remaining="29" etc="1289272852" />
66
+ <taskprogress task="NSE" time="1289272854" percent="97.50" remaining="30" etc="1289272883" />
67
+ <taskprogress task="NSE" time="1289272884" percent="97.50" remaining="31" etc="1289272914" />
68
+ <taskprogress task="NSE" time="1289272914" percent="97.50" remaining="31" etc="1289272945" />
69
+ <taskprogress task="NSE" time="1289272944" percent="97.50" remaining="32" etc="1289272976" />
70
+ <taskprogress task="NSE" time="1289272974" percent="97.50" remaining="33" etc="1289273006" />
71
+ <taskprogress task="NSE" time="1289273004" percent="97.50" remaining="34" etc="1289273037" />
72
+ <taskend task="NSE" time="1289273023" />
73
+ <host starttime="1289270225" endtime="1289273023"><status state="up" reason="echo-reply"/>
74
+ <address addr="173.255.192.6" addrtype="ipv4" />
75
+ <hostnames>
76
+ <hostname name="li202-6.members.linode.com" type="PTR"/>
77
+ </hostnames>
78
+ <ports><extraports state="filtered" count="992">
79
+ <extrareasons reason="no-responses" count="992"/>
80
+ </extraports>
81
+ <port protocol="tcp" portid="22"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="ssh" product="OpenSSH" version="5.1p1 Debian 6ubuntu2" extrainfo="protocol 2.0" ostype="Linux" method="probed" conf="10" /><script id="banner" output="SSH-2.0-OpenSSH_5.1p1 Debian-6ubuntu2" /><script id="ssh-hostkey" output="1024 5d:12:dd:c6:8a:05:d7:b7:a5:26:ec:cc:9c:8a:ca:67 (DSA)&#xa;ssh-dss AAAAB3NzaC1kc3MAAACBAKZ0ENxOqnH/PxDAj3AcnvX2hSxMsKAyeJT3wG/DluzL6TR0WX5QrYifF5ATRGlnsyF4ZxS1LiPUwcTs8LzFJ8a8KSThjXq6ET3V/TW43fWRTwJL+2X8+TXt3TC1cKdgrDPluhnzdsSg/78lQ5vVo118JxtSuC+pNDDOtmA+L3fJAAAAFQD5UcOqQR9iv89CIZBIC69Hi5/X+QAAAIEAnavKxpHJzOQ7/FGfU3heRQ6Bg/w5UC95YBEVyMc8x8aPOz8B4ZkWmioIQvhhS4ZobxK71imdm32RGD3G62pcCZ7X2FdgQIdb6RbHIMV+YrLdalE/ZoayD354BSJpyUQhzguB15qdmi1L+WZ9Zn51inWL/8UGZqma92JOKoqyec0AAACAS5kkXAZUbVO05GmMqVQre/CJd/wOR1hRn95nWSlJYi/xtEFx9mSxNUYdueSTJqYswI4S12OT61YqndCeFFETf77s3wH2Ry6/qHIpjW5Yxxqyw799Dj6w+RsV0K8h2EnY3Iwf12zi+yq4d3TIOTHRBhfzKt0W6jr5lkqPDzaijW0=&#xa;2048 a9:54:43:16:84:18:cd:40:90:8e:e2:d2:8e:19:b0:23 (RSA)&#xa;ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAto8rh6m6TPykHIsdA3QeoXHt73gR1YkaVpgvj/k73qP5Mf8xOXXew9wCMW1+tPywchabhq3zzA9uS9jPzFDdVlMC/jU+P5SHyfP1gFfHeRSXzJXIctObyBDTo1inTyuyzjLtBGu9aN7+xMH6aFkT4G7qq9rW7m2cNNCZucWJZRrbRH1jwqVFuhwLiUkM3xSBcPt1f5H6b9pVKNAewEOo8mxy5QJ/oX45S7+3ExLGTsHSZ/7xuGeromhJIjWjcU88gMGW2vVMDKPccgZgV503k1BXm74e3mPkJxncplFITypaonFfkc5IZVdAp9kqB1ZiOo5Icv6kQHaqTF0XosCqxw==" /></port>
82
+ <port protocol="tcp" portid="25"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="smtp" product="Postfix smtpd" hostname=" chiringapress.com" method="probed" conf="10" /><script id="smtp-commands" output="&#xa;EHLO chiringapress.com, PIPELINING, SIZE 30720000, VRFY, ETRN, STARTTLS, AUTH PLAIN LOGIN, AUTH=PLAIN LOGIN, ENHANCEDSTATUSCODES, 8BITMIME, DSN" /><script id="banner" output="220 chiringapress.com ESMTP Postfix (Ubuntu)" /><script id="ssl-cert" output="Subject: commonName=Michael Godeck/organizationName=Chiringa Press Inc./stateOrProvinceName=Texas/countryName=US/emailAddress=chiringapress@gmail.com/localityName=Seguin&#xa;Issuer: commonName=Michael Godeck/organizationName=Chiringa Press Inc./stateOrProvinceName=Texas/countryName=US/emailAddress=chiringapress@gmail.com/localityName=Seguin&#xa;Not valid before: 2010-10-03 14:16:02&#xa;Not valid after: 2011-10-03 14:16:02&#xa;MD5: 0b3b 9216 c053 3921 8718 2d37 e057 be54&#xa;SHA-1: 8f11 19a1 0a4f e599 9993 a8f0 c286 d73d 092e 4f97&#xa;-&#45;&#45;&#45;&#45;BEGIN CERTIFICATE-&#45;&#45;&#45;&#45;&#xa;MIIElTCCA32gAwIBAgIJAJHFR+QLQZwZMA0GCSqGSIb3DQEBBQUAMIGNMQswCQYD&#xa;VQQGEwJVUzEOMAwGA1UECBMFVGV4YXMxDzANBgNVBAcTBlNlZ3VpbjEcMBoGA1UE&#xa;ChMTQ2hpcmluZ2EgUHJlc3MgSW5jLjEXMBUGA1UEAxMOTWljaGFlbCBHb2RlY2sx&#xa;JjAkBgkqhkiG9w0BCQEWF2NoaXJpbmdhcHJlc3NAZ21haWwuY29tMB4XDTEwMTAw&#xa;MzE0MTYwMloXDTExMTAwMzE0MTYwMlowgY0xCzAJBgNVBAYTAlVTMQ4wDAYDVQQI&#xa;EwVUZXhhczEPMA0GA1UEBxMGU2VndWluMRwwGgYDVQQKExNDaGlyaW5nYSBQcmVz&#xa;cyBJbmMuMRcwFQYDVQQDEw5NaWNoYWVsIEdvZGVjazEmMCQGCSqGSIb3DQEJARYX&#xa;Y2hpcmluZ2FwcmVzc0BnbWFpbC5jb20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw&#xa;ggEKAoIBAQC/DPQNLCvtdwh6T2HD+ZNOy4gnMV87FuvRDSa2fhzPfKPXSQGpy+Hl&#xa;8LAp7BRiDHbeo2iJa8/47YOkzgOet9C+gwmkGu3ISBpEMvsCybsN6ihMHDhpKdaL&#xa;1CTVFZKZZAUSXkXv7igI2BZFptWP+8hw+ruy9j4lqIkCT8he9HGQghcK3Ejhg0XX&#xa;hT7x0EfaVmkK47qDBLYrh4zOkVZaH4zX67R5/D2Bp2PwA2jaS1jqI591niAWJbCA&#xa;77IEKLRE2txO4sPf2GV+DDvWDOOVOBrJdzqQAOhaV0HxkepdxkVb4A5TkUklvotO&#xa;oB9qKJFmbNihm4DwAuzs+dBJVLCwxPuXAgMBAAGjgfUwgfIwHQYDVR0OBBYEFLOG&#xa;m4+ymQ3Q7zzz/EC4KoaNgvVXMIHCBgNVHSMEgbowgbeAFLOGm4+ymQ3Q7zzz/EC4&#xa;KoaNgvVXoYGTpIGQMIGNMQswCQYDVQQGEwJVUzEOMAwGA1UECBMFVGV4YXMxDzAN&#xa;BgNVBAcTBlNlZ3VpbjEcMBoGA1UEChMTQ2hpcmluZ2EgUHJlc3MgSW5jLjEXMBUG&#xa;A1UEAxMOTWljaGFlbCBHb2RlY2sxJjAkBgkqhkiG9w0BCQEWF2NoaXJpbmdhcHJl&#xa;c3NAZ21haWwuY29tggkAkcVH5AtBnBkwDAYDVR0TBAUwAwEB/zANBgkqhkiG9w0B&#xa;AQUFAAOCAQEAmZ0FpngGz5/Y/dVD0Orre07Qz97oe+ZuXG5O0ZzPsapaC2jlEbc6&#xa;bYAAsneY+IGmxBoCfq8rJK1Kky8qjq/ToKH0lh338akh9sY30dwrlYbpGB8sVGTi&#xa;K/5HpZLnk30jVCP9m7HB/v7adR697D+xkgqT/bP+ExGZkajAB/nQou92A6RDtMJq&#xa;HF6h1G+r7mq2paaAioC7IrCI5D8E2lQeZj6Y7QTeZFK1nR7x+pjX44Hk6+Fgq2Uw&#xa;Jg0MZemEnN6fORQMsDoYZm6N/ZWQP+vCNdVhBCY5YZ8OizYqu6c5liFnXuR+XqKj&#xa;uZpl3JCxTRE1kyce8DGXh50xv1ZmqT7Nlw==&#xa;-&#45;&#45;&#45;&#45;END CERTIFICATE-&#45;&#45;&#45;&#45;&#xa;" /></port>
83
+ <port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="http" product="Apache httpd" version="2.2.12" extrainfo="(Ubuntu)" method="probed" conf="10" /><script id="citrix-brute-xml" output="FAILED: No domain specified (use ntdomain argument)" /><script id="citrix-enum-servers-xml" output="" /><script id="http-date" output="Tue, 09 Nov 2010 02:57:42 GMT; -4m11s from local time." /><script id="citrix-enum-apps-xml" output="" /><script id="http-malware-host" output="Host appears to be clean" /><script id="html-title" output="Chiringa Press | Publishing without community is like flying k..." /><script id="http-favicon" output="Unknown favicon MD5: A5B77B85173FAD1BFD30A7621AB76A07" /><script id="http-headers" output=" &#xa; Date: Tue, 09 Nov 2010 02:57:45 GMT&#xa; Server: Apache/2.2.12 (Ubuntu)&#xa; X-Powered-By: PHP/5.2.10-2ubuntu6.5&#xa; Set-Cookie: SESS7595338a1622aabb05091c2231c9d7e3=1b66c99fc7b5a04cdaf65ab8107fb4ae; expires=Thu, 02-Dec-2010 06:31:05 GMT; path=/; domain=.li202-6.members.linode.com&#xa; Expires: Sun, 19 Nov 1978 05:00:00 GMT&#xa; Last-Modified: Tue, 09 Nov 2010 02:57:45 GMT&#xa; Cache-Control: store, no-cache, must-revalidate&#xa; Cache-Control: post-check=0, pre-check=0&#xa; Vary: Accept-Encoding&#xa; Connection: close&#xa; Content-Type: text/html; charset=utf-8&#xa; &#xa; (Request type: HEAD)&#xa;" /><script id="http-enum" output=" &#xa; /icons/: Icons and images&#xa; /includes/: Includes directory&#xa; /install/: Install directory&#xa;" /><script id="http-iis-webdav-vuln" output="ERROR: This web server is not supported." /></port>
84
+ <port protocol="tcp" portid="110"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="pop3" product="Dovecot pop3d" method="probed" conf="10" /><script id="pop3-capabilities" output="OK(K) CAPA RESP-CODES UIDL PIPELINING STLS TOP SASL" /><script id="banner" output="+OK Dovecot ready." /></port>
85
+ <port protocol="tcp" portid="143"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="imap" product="Dovecot imapd" method="probed" conf="10" /><script id="banner" output="* OK Dovecot ready." /><script id="imap-capabilities" output="LOGIN-REFERRALS LOGINDISABLED STARTTLS I18NLEVEL=1 LIST-EXTENDED UNSELECT THREAD=REFERENCES UIDPLUS IMAP4rev1 NAMESPACE SORT CHILDREN LITERAL+ IDLE SASL-IR MULTIAPPEND" /></port>
86
+ <port protocol="tcp" portid="443"><state state="closed" reason="reset" reason_ttl="50"/><service name="https" method="table" conf="3" /></port>
87
+ <port protocol="tcp" portid="993"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="imap" product="Dovecot imapd" tunnel="ssl" method="probed" conf="10" /><script id="sslv2" output="server still supports SSLv2&#xa;&#x9;the server didn&apos;t offer any cyphers" /><script id="banner" output="* OK Dovecot ready." /><script id="imap-capabilities" output="LOGIN-REFERRALS AUTH=PLAIN I18NLEVEL=1 LIST-EXTENDED UNSELECT THREAD=REFERENCES UIDPLUS IMAP4rev1 NAMESPACE SORT CHILDREN LITERAL+ IDLE SASL-IR MULTIAPPEND" /><script id="ssl-cert" output="Subject: commonName=chiringapress.com&#xa;Issuer: commonName=chiringapress.com&#xa;Not valid before: 2010-10-03 14:04:20&#xa;Not valid after: 2020-09-30 14:04:20&#xa;MD5: cf02 9d1d 3af9 f0a8 614f a434 a543 d136&#xa;SHA-1: 1d23 6e70 69f0 4db2 5ffe b60e 377d f93f aff5 fa8c&#xa;-&#45;&#45;&#45;&#45;BEGIN CERTIFICATE-&#45;&#45;&#45;&#45;&#xa;MIIBrzCCARgCCQD5n7BHROZItTANBgkqhkiG9w0BAQUFADAcMRowGAYDVQQDExFj&#xa;aGlyaW5nYXByZXNzLmNvbTAeFw0xMDEwMDMxNDA0MjBaFw0yMDA5MzAxNDA0MjBa&#xa;MBwxGjAYBgNVBAMTEWNoaXJpbmdhcHJlc3MuY29tMIGfMA0GCSqGSIb3DQEBAQUA&#xa;A4GNADCBiQKBgQDWg3kAL44/vviOZva0TeMLLOb3epJ9qNjfiOp5K71UEb9OmPz5&#xa;Cj6gtmBIo0ftwRREq1k7vSw2nD4W8ZsFi3XVyrc6VvdhQeUA94PRnpwox6yFg7aS&#xa;FoOxhrwW+23ruNMH12LG2Qlr290U7Mlpr+4uU+Zloy5piGC07iO/uH9F9QIDAQAB&#xa;MA0GCSqGSIb3DQEBBQUAA4GBALlWMAjpnJp9b2/BrCKuIn7t8kyf0m5DQ17A1/Kl&#xa;k5XhtdBUaazWMeZr600AKxx/Dv0RdDTFY5TkynfPki4n4hDLtPGQxMXrzYRS+gSo&#xa;dVtLskRr/jFlrv6DXo2aO+dPEdbm3ZrUi0yPr1YZW4fQN+HYU5uSxKknOH0SqOdZ&#xa;Vo+h&#xa;-&#45;&#45;&#45;&#45;END CERTIFICATE-&#45;&#45;&#45;&#45;&#xa;" /></port>
88
+ <port protocol="tcp" portid="995"><state state="open" reason="syn-ack" reason_ttl="50"/><service name="pop3" product="Dovecot pop3d" tunnel="ssl" method="probed" conf="10" /><script id="sslv2" output="server still supports SSLv2&#xa;&#x9;the server didn&apos;t offer any cyphers" /><script id="banner" output="+OK Dovecot ready." /><script id="ssl-cert" output="Subject: commonName=chiringapress.com&#xa;Issuer: commonName=chiringapress.com&#xa;Not valid before: 2010-10-03 14:04:20&#xa;Not valid after: 2020-09-30 14:04:20&#xa;MD5: cf02 9d1d 3af9 f0a8 614f a434 a543 d136&#xa;SHA-1: 1d23 6e70 69f0 4db2 5ffe b60e 377d f93f aff5 fa8c&#xa;-&#45;&#45;&#45;&#45;BEGIN CERTIFICATE-&#45;&#45;&#45;&#45;&#xa;MIIBrzCCARgCCQD5n7BHROZItTANBgkqhkiG9w0BAQUFADAcMRowGAYDVQQDExFj&#xa;aGlyaW5nYXByZXNzLmNvbTAeFw0xMDEwMDMxNDA0MjBaFw0yMDA5MzAxNDA0MjBa&#xa;MBwxGjAYBgNVBAMTEWNoaXJpbmdhcHJlc3MuY29tMIGfMA0GCSqGSIb3DQEBAQUA&#xa;A4GNADCBiQKBgQDWg3kAL44/vviOZva0TeMLLOb3epJ9qNjfiOp5K71UEb9OmPz5&#xa;Cj6gtmBIo0ftwRREq1k7vSw2nD4W8ZsFi3XVyrc6VvdhQeUA94PRnpwox6yFg7aS&#xa;FoOxhrwW+23ruNMH12LG2Qlr290U7Mlpr+4uU+Zloy5piGC07iO/uH9F9QIDAQAB&#xa;MA0GCSqGSIb3DQEBBQUAA4GBALlWMAjpnJp9b2/BrCKuIn7t8kyf0m5DQ17A1/Kl&#xa;k5XhtdBUaazWMeZr600AKxx/Dv0RdDTFY5TkynfPki4n4hDLtPGQxMXrzYRS+gSo&#xa;dVtLskRr/jFlrv6DXo2aO+dPEdbm3ZrUi0yPr1YZW4fQN+HYU5uSxKknOH0SqOdZ&#xa;Vo+h&#xa;-&#45;&#45;&#45;&#45;END CERTIFICATE-&#45;&#45;&#45;&#45;&#xa;" /><script id="pop3-capabilities" output="OK(K) CAPA RESP-CODES UIDL PIPELINING USER TOP SASL(PLAIN)" /></port>
89
+ </ports>
90
+ <hostscript><script id="asn-query" output=" &#xa;BGP: 173.255.192.0/20 | Country: US&#xa; Origin AS: 21844 - THEPLANET-AS - ThePlanet.com Internet Services, Inc.&#xa; Peer AS: 2914 3356 3549 4565 6461 7922 10310 22822" /><script id="whois" output="Record found at whois.arin.net&#xa;netrange: 173.255.192.0 - 173.255.255.255&#xa;netname: LINODE-US&#xa;orgname: Linode&#xa;orgid: LINOD&#xa;country: US stateprov: NJ &#xa;&#xa;orgtechname: Linode Network Operations&#xa;orgtechemail: support@linode.com" /></hostscript><times srtt="110549" rttvar="65422" to="372237" />
91
+ </host>
92
+ <runstats><finished time="1289273023" timestr="Mon Nov 8 19:23:43 2010" elapsed="2798.66"/><hosts up="1" down="0" total="1" />
93
+ <!-- Nmap done at Mon Nov 8 19:23:43 2010; 1 IP address (1 host up) scanned in 2798.66 seconds -->
94
+ </runstats></nmaprun>
data/spec/helpers/xml.rb CHANGED
@@ -1,3 +1,5 @@
1
1
  module Helpers
2
2
  SCAN_FILE = File.join(File.dirname(__FILE__),'scan.xml')
3
+
4
+ NSE_FILE = File.join(File.dirname(__FILE__),'nse.xml')
3
5
  end
data/spec/host_spec.rb CHANGED
@@ -9,7 +9,10 @@ describe Host do
9
9
 
10
10
  before(:all) do
11
11
  @xml = XML.new(Helpers::SCAN_FILE)
12
+ @nse_xml = XML.new(Helpers::NSE_FILE)
13
+
12
14
  @host = @xml.hosts.first
15
+ @nse_host = @nse_xml.hosts.first
13
16
  end
14
17
 
15
18
  it "should parse the start_time" do
@@ -72,23 +75,6 @@ describe Host do
72
75
  ports = @host.ports
73
76
 
74
77
  ports.length.should == 3
75
- ports[0].protocol.should == :tcp
76
- ports[0].number.should == 21
77
- ports[0].state.should == :closed
78
- ports[0].reason.should == 'reset'
79
- ports[0].service.should == 'ftp'
80
-
81
- ports[1].protocol.should == :tcp
82
- ports[1].number.should == 23
83
- ports[1].state.should == :closed
84
- ports[1].reason.should == 'reset'
85
- ports[1].service.should == 'telnet'
86
-
87
- ports[2].protocol.should == :tcp
88
- ports[2].number.should == 443
89
- ports[2].state.should == :open
90
- ports[2].reason.should == 'syn-ack'
91
- ports[2].service.should == 'https'
92
78
  end
93
79
 
94
80
  it "should list the open ports" do
@@ -112,4 +98,11 @@ describe Host do
112
98
  it "should convert to a String" do
113
99
  @host.to_s.should == '192.168.5.1'
114
100
  end
101
+
102
+ it "should list output of NSE scripts ran against the host" do
103
+ @nse_host.scripts.should_not be_empty
104
+
105
+ @nse_host.scripts.keys.should_not include(nil)
106
+ @nse_host.scripts.values.should_not include(nil)
107
+ end
115
108
  end
data/spec/port_spec.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'spec_helper'
2
+ require 'helpers/xml'
3
+
4
+ require 'nmap/xml'
5
+ require 'nmap/port'
6
+
7
+ describe Port do
8
+ include Helpers
9
+
10
+ before(:all) do
11
+ @xml = XML.new(Helpers::SCAN_FILE)
12
+ @nse_xml = XML.new(Helpers::NSE_FILE)
13
+
14
+ @port = @xml.hosts.first.ports.first
15
+ @nse_port = @nse_xml.hosts.first.ports.first
16
+ end
17
+
18
+ it "should parse the protocol" do
19
+ @port.protocol.should == :tcp
20
+ end
21
+
22
+ it "should parse the port number" do
23
+ @port.number.should == 21
24
+ end
25
+
26
+ it "should parse the state" do
27
+ @port.state.should == :closed
28
+ end
29
+
30
+ it "should parse the reason" do
31
+ @port.reason.should == 'reset'
32
+ end
33
+
34
+ it "should parse the detected service" do
35
+ @port.service.should == 'ftp'
36
+ end
37
+
38
+ it "should parse the output of NSE scripts ran against the port" do
39
+ @nse_port.scripts.should_not be_empty
40
+
41
+ @nse_port.scripts.keys.should_not include(nil)
42
+ @nse_port.scripts.values.should_not include(nil)
43
+ end
44
+ end
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
7
+ - 3
8
8
  - 0
9
- version: 0.2.0
9
+ version: 0.3.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Postmodern
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-29 00:00:00 -07:00
17
+ date: 2010-11-08 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  type: :runtime
49
49
  version_requirements: *id002
50
50
  - !ruby/object:Gem::Dependency
51
- name: ore
51
+ name: ore-tasks
52
52
  prerelease: false
53
53
  requirement: &id003 !ruby/object:Gem::Requirement
54
54
  none: false
@@ -58,29 +58,14 @@ dependencies:
58
58
  segments:
59
59
  - 0
60
60
  - 2
61
- - 1
62
- version: 0.2.1
63
- type: :development
64
- version_requirements: *id003
65
- - !ruby/object:Gem::Dependency
66
- name: ore-tasks
67
- prerelease: false
68
- requirement: &id004 !ruby/object:Gem::Requirement
69
- none: false
70
- requirements:
71
- - - ~>
72
- - !ruby/object:Gem::Version
73
- segments:
74
61
  - 0
75
- - 1
76
- - 2
77
- version: 0.1.2
62
+ version: 0.2.0
78
63
  type: :development
79
- version_requirements: *id004
64
+ version_requirements: *id003
80
65
  - !ruby/object:Gem::Dependency
81
66
  name: rspec
82
67
  prerelease: false
83
- requirement: &id005 !ruby/object:Gem::Requirement
68
+ requirement: &id004 !ruby/object:Gem::Requirement
84
69
  none: false
85
70
  requirements:
86
71
  - - ~>
@@ -91,11 +76,11 @@ dependencies:
91
76
  - 0
92
77
  version: 2.0.0
93
78
  type: :development
94
- version_requirements: *id005
79
+ version_requirements: *id004
95
80
  - !ruby/object:Gem::Dependency
96
81
  name: yard
97
82
  prerelease: false
98
- requirement: &id006 !ruby/object:Gem::Requirement
83
+ requirement: &id005 !ruby/object:Gem::Requirement
99
84
  none: false
100
85
  requirements:
101
86
  - - ~>
@@ -106,7 +91,7 @@ dependencies:
106
91
  - 0
107
92
  version: 0.6.0
108
93
  type: :development
109
- version_requirements: *id006
94
+ version_requirements: *id005
110
95
  description: A Ruby interface to Nmap, the exploration tool and security / port scanner.
111
96
  email: postmodern.mod3@gmail.com
112
97
  executables: []
@@ -139,11 +124,13 @@ files:
139
124
  - lib/nmap/version.rb
140
125
  - lib/nmap/xml.rb
141
126
  - ruby-nmap.gemspec
127
+ - spec/helpers/nse.xml
142
128
  - spec/helpers/scan.xml
143
129
  - spec/helpers/xml.rb
144
130
  - spec/host_spec.rb
145
131
  - spec/nmap_spec.rb
146
132
  - spec/os_spec.rb
133
+ - spec/port_spec.rb
147
134
  - spec/spec_helper.rb
148
135
  - spec/task_spec.rb
149
136
  - spec/xml_spec.rb
@@ -181,6 +168,7 @@ specification_version: 3
181
168
  summary: A Ruby interface to Nmap.
182
169
  test_files:
183
170
  - spec/host_spec.rb
171
+ - spec/port_spec.rb
184
172
  - spec/nmap_spec.rb
185
173
  - spec/os_spec.rb
186
174
  - spec/xml_spec.rb