nmap-parser 0.3 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +1 -1
- data/README +5 -2
- data/lib/nmap/parser.rb +123 -138
- metadata +40 -33
data/LICENSE
CHANGED
data/README
CHANGED
@@ -3,18 +3,21 @@
|
|
3
3
|
== Kris Katterjohn katterjohn@gmail.com ==
|
4
4
|
===============================================================================
|
5
5
|
|
6
|
-
$Id: README
|
6
|
+
$Id: README 91 2009-01-01 20:50:08Z kjak $
|
7
7
|
|
8
8
|
|
9
9
|
OVERVIEW
|
10
10
|
========
|
11
11
|
|
12
12
|
This library provides a Ruby interface to Nmap's scan data. It can run Nmap
|
13
|
-
and parse
|
13
|
+
and parse its XML output directly from the scan, parse a file containing the
|
14
14
|
XML data from a separate scan, parse a String of XML data from a scan, or parse
|
15
15
|
XML data from an object via its read() method. This information is presented
|
16
16
|
in an easy-to-use and intuitive fashion for storing and manipulating.
|
17
17
|
|
18
|
+
This is not just some Ruby port of Anthony Persaud's Perl Nmap::Parser! There
|
19
|
+
are more classes, many different methods, and blocks are extensively available.
|
20
|
+
|
18
21
|
|
19
22
|
REQUIREMENTS and RECOMMENDATIONS
|
20
23
|
================================
|
data/lib/nmap/parser.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
#
|
5
5
|
# Author: Kris Katterjohn <katterjohn@gmail.com>
|
6
6
|
#
|
7
|
-
# Copyright (c) 2007, 2008 Kris Katterjohn
|
7
|
+
# Copyright (c) 2007, 2008, 2009 Kris Katterjohn
|
8
8
|
#
|
9
9
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
10
10
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -24,7 +24,7 @@
|
|
24
24
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
25
25
|
# THE SOFTWARE.
|
26
26
|
|
27
|
-
# $Id: parser.rb
|
27
|
+
# $Id: parser.rb 92 2009-01-01 21:14:58Z kjak $
|
28
28
|
# https://rubynmap.svn.sourceforge.net/svnroot/rubynmap
|
29
29
|
|
30
30
|
require 'rexml/document'
|
@@ -44,22 +44,20 @@ end
|
|
44
44
|
== What Is This Library For?
|
45
45
|
|
46
46
|
This library provides a Ruby interface to Nmap's scan data. It can run Nmap
|
47
|
-
and parse
|
47
|
+
and parse its XML output directly from the scan, parse a file containing the
|
48
48
|
XML data from a separate scan, parse a String of XML data from a scan, or parse
|
49
49
|
XML data from an object via its read() method. This information is presented
|
50
50
|
in an easy-to-use and intuitive fashion for storing and manipulating.
|
51
51
|
|
52
|
+
This is not just some Ruby port of Anthony Persaud's Perl Nmap::Parser! There
|
53
|
+
are more classes, many different methods, and blocks are extensively available.
|
54
|
+
|
52
55
|
The Nmap Security Scanner is a great program written and maintained by
|
53
56
|
Fyodor <fyodor@insecure.org>. Its main function is port scanning, but it also
|
54
|
-
has service and operating system detection,
|
55
|
-
whole lot more. One of
|
57
|
+
has service and operating system detection, its own scripting engine and a
|
58
|
+
whole lot more. One of its many available output formats is XML, which allows
|
56
59
|
machines to handle all of the information instead of us slowly sifting through
|
57
|
-
tons of output
|
58
|
-
|
59
|
-
If you've ever used Anthony Persaud's Perl Nmap::Parser, you'll notice some
|
60
|
-
similarities and should pick up on this API quickly. Just remember, it's far
|
61
|
-
from exactly the same! There are more classes, many different methods, and
|
62
|
-
blocks are used extensively (or available for use).
|
60
|
+
tons of output.
|
63
61
|
|
64
62
|
== Conventions
|
65
63
|
|
@@ -78,29 +76,29 @@ is given.
|
|
78
76
|
|
79
77
|
Nmap::Parser
|
80
78
|
|
|
81
|
-
+
|
79
|
+
+ Session <- Scan session information
|
82
80
|
|
|
83
|
-
+
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
81
|
+
+ Host <- General host information
|
82
|
+
|
|
83
|
+
+ ExtraPorts <- Ports consolidated in an "ignored" state
|
84
|
+
|
|
85
|
+
+ Port <- General port information
|
86
|
+
| |
|
87
|
+
| + Service <- Port Service information
|
88
|
+
|
|
89
|
+
+ Script <- NSE Script information (both host and port)
|
90
|
+
|
|
91
|
+
+ Times <- Timimg information (srtt, etc)
|
92
|
+
|
|
93
|
+
+ Traceroute <- General Traceroute information
|
94
|
+
| |
|
95
|
+
| + Hop <- Individual Hop information
|
96
|
+
|
|
97
|
+
+ OS <- OS Detection information
|
98
|
+
|
|
99
|
+
+ OSClass <- OS Class information
|
100
|
+
|
|
101
|
+
+ OSMatch <- OS Match information
|
104
102
|
|
105
103
|
== Parsing XML Data Already Available
|
106
104
|
|
@@ -116,9 +114,8 @@ is given.
|
|
116
114
|
|
117
115
|
== Reading and Parsing from an Object
|
118
116
|
|
119
|
-
|
120
|
-
|
121
|
-
method that returns a String.
|
117
|
+
This method can read from any object that responds to a read() method that
|
118
|
+
returns a String: $stdin is just one example.
|
122
119
|
|
123
120
|
require 'nmap/parser'
|
124
121
|
|
@@ -126,11 +123,11 @@ method that returns a String.
|
|
126
123
|
|
127
124
|
== Scanning and Parsing
|
128
125
|
|
129
|
-
This is the only parser
|
126
|
+
This is the only parser method that requires Nmap to be available.
|
130
127
|
|
131
128
|
require 'nmap/parser'
|
132
129
|
|
133
|
-
parser = Nmap::Parser.parsescan("sudo nmap", "
|
130
|
+
parser = Nmap::Parser.parsescan("sudo nmap", "-sVC 192.168.1.0/24")
|
134
131
|
|
135
132
|
== Actually Doing Something
|
136
133
|
|
@@ -140,9 +137,7 @@ open TCP ports, along with the name and output of any scripts that
|
|
140
137
|
ran (on the host and individual ports).
|
141
138
|
|
142
139
|
puts "Nmap args: #{parser.session.scan_args}"
|
143
|
-
|
144
140
|
puts "Runtime: #{parser.session.scan_time} seconds"
|
145
|
-
|
146
141
|
puts
|
147
142
|
|
148
143
|
parser.hosts("up") do |host|
|
@@ -155,7 +150,7 @@ ran (on the host and individual ports).
|
|
155
150
|
puts "Port ##{port.num} is open (#{port.reason})"
|
156
151
|
puts "\tService: #{srv.name}" if srv.name
|
157
152
|
puts "\tProduct: #{srv.product}" if srv.product
|
158
|
-
puts "\tVersion: #{srv.
|
153
|
+
puts "\tVersion: #{srv.version}" if srv.version
|
159
154
|
puts
|
160
155
|
|
161
156
|
port.scripts do |script|
|
@@ -183,7 +178,7 @@ ran (on the host and individual ports).
|
|
183
178
|
class Nmap::Parser
|
184
179
|
# Holds the raw XML output from Nmap
|
185
180
|
attr_reader :rawxml
|
186
|
-
#
|
181
|
+
# Session object for this scan
|
187
182
|
attr_reader :session
|
188
183
|
|
189
184
|
# Read and parse XML from the +obj+. +obj+ can be any object type
|
@@ -199,7 +194,9 @@ class Nmap::Parser
|
|
199
194
|
|
200
195
|
r = obj.read
|
201
196
|
|
202
|
-
|
197
|
+
if not r.is_a?String
|
198
|
+
raise "read() returned #{r.class} instead of a String"
|
199
|
+
end
|
203
200
|
|
204
201
|
p = new(r)
|
205
202
|
|
@@ -305,7 +302,7 @@ class Nmap::Parser
|
|
305
302
|
# get_ips(), calling this method on a host passed to the block may
|
306
303
|
# lead to adverse effects:
|
307
304
|
#
|
308
|
-
# parser.hosts { |
|
305
|
+
# parser.hosts { |h| puts h.addr; parser.del_host(h) } # Don't do this!
|
309
306
|
def del_host(hostip)
|
310
307
|
@hosts.delete_if do |host|
|
311
308
|
host.addr == hostip or host.hostname == hostip
|
@@ -361,10 +358,8 @@ class Nmap::Parser
|
|
361
358
|
|
362
359
|
@session = Session.new(root)
|
363
360
|
|
364
|
-
@hosts =
|
365
|
-
|
366
|
-
root.each_element('host') do |host|
|
367
|
-
@hosts << Host.new(host)
|
361
|
+
@hosts = root.elements.collect('host') do |host|
|
362
|
+
Host.new(host)
|
368
363
|
end
|
369
364
|
end
|
370
365
|
end
|
@@ -432,6 +427,16 @@ class Nmap::Parser::Session
|
|
432
427
|
types
|
433
428
|
end
|
434
429
|
|
430
|
+
# Returns the scanflags associated with the specified scan +type+
|
431
|
+
# (e.g. "PSHACK" for type "ack")
|
432
|
+
def scanflags(type)
|
433
|
+
@scaninfo.each do |info|
|
434
|
+
return info.scanflags if info.type == type
|
435
|
+
end
|
436
|
+
|
437
|
+
nil
|
438
|
+
end
|
439
|
+
|
435
440
|
private
|
436
441
|
|
437
442
|
def initialize(root)
|
@@ -456,16 +461,14 @@ class Nmap::Parser::Session
|
|
456
461
|
@verbose = root.elements['verbose'].attributes['level'].to_i
|
457
462
|
@debug = root.elements['debugging'].attributes['level'].to_i
|
458
463
|
|
459
|
-
@scaninfo =
|
460
|
-
|
461
|
-
root.each_element('scaninfo') do |info|
|
462
|
-
@scaninfo << ScanInfo.new(info)
|
464
|
+
@scaninfo = root.elements.collect('scaninfo') do |info|
|
465
|
+
ScanInfo.new(info)
|
463
466
|
end
|
464
467
|
end
|
465
468
|
end
|
466
469
|
|
467
470
|
class Nmap::Parser::Session::ScanInfo # :nodoc: all
|
468
|
-
attr_reader :type, :proto, :numservices
|
471
|
+
attr_reader :type, :scanflags, :proto, :numservices
|
469
472
|
|
470
473
|
private
|
471
474
|
|
@@ -475,6 +478,7 @@ class Nmap::Parser::Session::ScanInfo # :nodoc: all
|
|
475
478
|
|
476
479
|
def parse(info)
|
477
480
|
@type = info.attributes['type']
|
481
|
+
@scanflags = info.attributes['scanflags']
|
478
482
|
@proto = info.attributes['protocol']
|
479
483
|
@numservices = info.attributes['numservices'].to_i
|
480
484
|
end
|
@@ -498,7 +502,7 @@ class Nmap::Parser::Host
|
|
498
502
|
attr_reader :mac_addr
|
499
503
|
# The MAC vendor
|
500
504
|
attr_reader :mac_vendor
|
501
|
-
#
|
505
|
+
# OS object holding Operating System information
|
502
506
|
attr_reader :os
|
503
507
|
# The number of "weird responses"
|
504
508
|
attr_reader :smurf
|
@@ -512,12 +516,14 @@ class Nmap::Parser::Host
|
|
512
516
|
attr_reader :tcptssequence_class, :tcptssequence_values
|
513
517
|
# Uptime information
|
514
518
|
attr_reader :uptime_seconds, :uptime_lastboot
|
515
|
-
#
|
519
|
+
# Traceroute object
|
516
520
|
attr_reader :traceroute
|
517
521
|
# Network distance (not necessarily the same as from traceroute)
|
518
522
|
attr_reader :distance
|
519
|
-
#
|
523
|
+
# Times object holding timing information
|
520
524
|
attr_reader :times
|
525
|
+
# Host start and end times
|
526
|
+
attr_reader :starttime, :endtime
|
521
527
|
|
522
528
|
alias ipv4_addr ip4_addr
|
523
529
|
alias ipv6_addr ip6_addr
|
@@ -572,13 +578,9 @@ class Nmap::Parser::Host
|
|
572
578
|
# If an argument is given, only ports matching +state+ are given.
|
573
579
|
# Note: "open" will also match "open|filtered", but not vice versa.
|
574
580
|
def tcp_ports(state = "")
|
575
|
-
list =
|
576
|
-
|
577
|
-
|
578
|
-
list << port if state.empty? or port.state >= state
|
579
|
-
end
|
580
|
-
|
581
|
-
list.sort!
|
581
|
+
list = @tcpPorts.invert.keys.find_all { |port|
|
582
|
+
state.empty? or port.state >= state
|
583
|
+
}.sort
|
582
584
|
|
583
585
|
if block_given?
|
584
586
|
list.each do |port|
|
@@ -595,13 +597,9 @@ class Nmap::Parser::Host
|
|
595
597
|
# If an argument is given, only ports matching +state+ are given.
|
596
598
|
# Note: "open" will also match "open|filtered", but not vice versa.
|
597
599
|
def tcp_port_list(state = "")
|
598
|
-
list =
|
599
|
-
|
600
|
-
|
601
|
-
list << port.num if state.empty? or port.state >= state
|
602
|
-
end
|
603
|
-
|
604
|
-
list.sort!
|
600
|
+
list = @tcpPorts.invert.keys.map { |port|
|
601
|
+
port.num if state.empty? or port.state >= state
|
602
|
+
}.compact.sort
|
605
603
|
|
606
604
|
if block_given?
|
607
605
|
list.each do |port|
|
@@ -612,7 +610,7 @@ class Nmap::Parser::Host
|
|
612
610
|
list
|
613
611
|
end
|
614
612
|
|
615
|
-
# Returns state reason of TCP port +portnum+
|
613
|
+
# Returns the state reason of TCP port +portnum+
|
616
614
|
def tcp_reason(portnum)
|
617
615
|
return nil if @tcpPorts[portnum.to_s].nil?
|
618
616
|
|
@@ -655,7 +653,7 @@ class Nmap::Parser::Host
|
|
655
653
|
@tcpPorts[portnum.to_s].service
|
656
654
|
end
|
657
655
|
|
658
|
-
# Returns state of TCP port +portnum+
|
656
|
+
# Returns the state of TCP port +portnum+
|
659
657
|
def tcp_state(portnum)
|
660
658
|
return nil if @tcpPorts[portnum.to_s].nil?
|
661
659
|
|
@@ -676,13 +674,9 @@ class Nmap::Parser::Host
|
|
676
674
|
# If an argument is given, only ports matching +state+ are given.
|
677
675
|
# Note: "open" will also match "open|filtered", but not vice versa.
|
678
676
|
def udp_ports(state = "")
|
679
|
-
list =
|
680
|
-
|
681
|
-
|
682
|
-
list << port if state.empty? or port.state >= state
|
683
|
-
end
|
684
|
-
|
685
|
-
list.sort!
|
677
|
+
list = @udpPorts.invert.keys.find_all { |port|
|
678
|
+
state.empty? or port.state >= state
|
679
|
+
}.sort
|
686
680
|
|
687
681
|
if block_given?
|
688
682
|
list.each do |port|
|
@@ -699,13 +693,9 @@ class Nmap::Parser::Host
|
|
699
693
|
# If an argument is given, only ports matching +state+ are given.
|
700
694
|
# Note: "open" will also match "open|filtered", but not vice versa.
|
701
695
|
def udp_port_list(state = "")
|
702
|
-
list =
|
703
|
-
|
704
|
-
|
705
|
-
list << port.num if state.empty? or port.state >= state
|
706
|
-
end
|
707
|
-
|
708
|
-
list.sort!
|
696
|
+
list = @udpPorts.invert.keys.map { |port|
|
697
|
+
port.num if state.empty? or port.state >= state
|
698
|
+
}.compact.sort
|
709
699
|
|
710
700
|
if block_given?
|
711
701
|
list.each do |port|
|
@@ -716,7 +706,7 @@ class Nmap::Parser::Host
|
|
716
706
|
list
|
717
707
|
end
|
718
708
|
|
719
|
-
# Returns state reason of UDP port +portnum+
|
709
|
+
# Returns the state reason of UDP port +portnum+
|
720
710
|
def udp_reason(portnum)
|
721
711
|
return nil if @udpPorts[portnum.to_s].nil?
|
722
712
|
|
@@ -759,7 +749,7 @@ class Nmap::Parser::Host
|
|
759
749
|
@udpPorts[portnum.to_s].service
|
760
750
|
end
|
761
751
|
|
762
|
-
# Returns state of UDP port +portnum+
|
752
|
+
# Returns the state of UDP port +portnum+
|
763
753
|
def udp_state(portnum)
|
764
754
|
return nil if @udpPorts[portnum.to_s].nil?
|
765
755
|
|
@@ -780,13 +770,9 @@ class Nmap::Parser::Host
|
|
780
770
|
# If an argument is given, only protocols matching +state+ are given.
|
781
771
|
# Note: "open" will also match "open|filtered", but not vice versa.
|
782
772
|
def ip_protos(state = "")
|
783
|
-
list =
|
784
|
-
|
785
|
-
|
786
|
-
list << proto if state.empty? or proto.state >= state
|
787
|
-
end
|
788
|
-
|
789
|
-
list.sort!
|
773
|
+
list = @ipProtos.invert.keys.find_all { |proto|
|
774
|
+
state.empty? or proto.state >= state
|
775
|
+
}.sort
|
790
776
|
|
791
777
|
if block_given?
|
792
778
|
list.each do |proto|
|
@@ -803,13 +789,9 @@ class Nmap::Parser::Host
|
|
803
789
|
# If an argument is given, only protocols matching +state+ are given.
|
804
790
|
# Note: "open" will also match "open|filtered", but not vice versa.
|
805
791
|
def ip_proto_list(state = "")
|
806
|
-
list =
|
807
|
-
|
808
|
-
|
809
|
-
list << proto.num if state.empty? or proto.state >= state
|
810
|
-
end
|
811
|
-
|
812
|
-
list.sort!
|
792
|
+
list = @ipProtos.invert.keys.map { |proto|
|
793
|
+
proto.num if state.empty? or proto.state >= state
|
794
|
+
}.compact.sort
|
813
795
|
|
814
796
|
if block_given?
|
815
797
|
list.each do |proto|
|
@@ -820,7 +802,7 @@ class Nmap::Parser::Host
|
|
820
802
|
list
|
821
803
|
end
|
822
804
|
|
823
|
-
# Returns state reason of IP protocol +protonum+
|
805
|
+
# Returns the state reason of IP protocol +protonum+
|
824
806
|
def ip_reason(protonum)
|
825
807
|
return nil if @ipProtos[protonum.to_s].nil?
|
826
808
|
|
@@ -834,7 +816,7 @@ class Nmap::Parser::Host
|
|
834
816
|
@ipProtos[protonum.to_s].service
|
835
817
|
end
|
836
818
|
|
837
|
-
# Returns state of IP protocol +protonum+
|
819
|
+
# Returns the state of IP protocol +protonum+
|
838
820
|
def ip_state(protonum)
|
839
821
|
return nil if @ipProtos[protonum.to_s].nil?
|
840
822
|
|
@@ -875,25 +857,26 @@ class Nmap::Parser::Host
|
|
875
857
|
parse(hostinfo)
|
876
858
|
end
|
877
859
|
|
878
|
-
# Convert a string like
|
860
|
+
# Convert a string like "22-25,80,110-900" into
|
879
861
|
# an array with all the uncondensed elements, e.g.
|
880
|
-
# [
|
862
|
+
# [ 22, 23, 24, 25, 80, 110, 111 ... ]
|
881
863
|
def parsePortlist(ports)
|
882
864
|
list = []
|
883
865
|
|
884
|
-
|
885
|
-
|
866
|
+
# Build array from port specification
|
867
|
+
ports.split(/,/).each do |item|
|
868
|
+
start, stop = item.split(/-/).map { |p| p.to_i }
|
886
869
|
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
end
|
870
|
+
start ||= 0
|
871
|
+
stop ||= item.match(/-/) ? 65535 : start
|
872
|
+
|
873
|
+
start, stop = stop, start if stop < start
|
874
|
+
|
875
|
+
start.upto(stop) { |p| list << p }
|
894
876
|
end
|
895
877
|
|
896
|
-
|
878
|
+
# Sort, and remove dups and invalid ports
|
879
|
+
list.sort.uniq.delete_if { |p| p < 0 or p > 65535 }
|
897
880
|
end
|
898
881
|
|
899
882
|
def parseAddr(elem)
|
@@ -913,8 +896,8 @@ class Nmap::Parser::Host
|
|
913
896
|
|
914
897
|
return nil if elem.nil?
|
915
898
|
|
916
|
-
elem.
|
917
|
-
|
899
|
+
@hostnames = elem.elements.collect('hostname') do |name|
|
900
|
+
name.attributes['name']
|
918
901
|
end
|
919
902
|
end
|
920
903
|
|
@@ -944,8 +927,8 @@ class Nmap::Parser::Host
|
|
944
927
|
|
945
928
|
return nil if ports.nil?
|
946
929
|
|
947
|
-
ports.
|
948
|
-
|
930
|
+
@extraports = ports.elements.collect('extraports') do |e|
|
931
|
+
ExtraPorts.new(e)
|
949
932
|
end
|
950
933
|
|
951
934
|
@extraports.sort! do |x, y|
|
@@ -958,8 +941,8 @@ class Nmap::Parser::Host
|
|
958
941
|
|
959
942
|
return nil if scriptlist.nil?
|
960
943
|
|
961
|
-
scriptlist.
|
962
|
-
|
944
|
+
@scripts = scriptlist.elements.collect('script') do |script|
|
945
|
+
Script.new(script)
|
963
946
|
end
|
964
947
|
end
|
965
948
|
|
@@ -1035,6 +1018,12 @@ class Nmap::Parser::Host
|
|
1035
1018
|
@distance = distance.attributes['value'].to_i if distance
|
1036
1019
|
|
1037
1020
|
@times = Times.new(host.elements['times'])
|
1021
|
+
|
1022
|
+
stime = host.attributes['starttime']
|
1023
|
+
@starttime = stime.to_i if stime
|
1024
|
+
|
1025
|
+
etime = host.attributes['endtime']
|
1026
|
+
@endtime = etime.to_i if etime
|
1038
1027
|
end
|
1039
1028
|
end
|
1040
1029
|
|
@@ -1089,7 +1078,7 @@ end
|
|
1089
1078
|
class Nmap::Parser::Host::Port
|
1090
1079
|
# Port number
|
1091
1080
|
attr_reader :num
|
1092
|
-
#
|
1081
|
+
# Service object for this port
|
1093
1082
|
attr_reader :service
|
1094
1083
|
# Port state ("open", "closed", "filtered", etc)
|
1095
1084
|
attr_reader :state
|
@@ -1150,10 +1139,8 @@ class Nmap::Parser::Host::Port
|
|
1150
1139
|
|
1151
1140
|
@service = Service.new(port)
|
1152
1141
|
|
1153
|
-
@scripts =
|
1154
|
-
|
1155
|
-
port.each_element('script') do |script|
|
1156
|
-
@scripts << Nmap::Parser::Host::Script.new(script)
|
1142
|
+
@scripts = port.elements.collect('script') do |script|
|
1143
|
+
Nmap::Parser::Host::Script.new(script)
|
1157
1144
|
end
|
1158
1145
|
end
|
1159
1146
|
end
|
@@ -1219,7 +1206,7 @@ class Nmap::Parser::Host::Traceroute
|
|
1219
1206
|
|
1220
1207
|
# Returns an array of Hop objects, which are each a responsive hop,
|
1221
1208
|
# and passes them each to a block if one if given.
|
1222
|
-
def hops
|
1209
|
+
def hops() # :yields: hop
|
1223
1210
|
if block_given?
|
1224
1211
|
@hops.each do |h|
|
1225
1212
|
yield h
|
@@ -1239,10 +1226,8 @@ class Nmap::Parser::Host::Traceroute
|
|
1239
1226
|
@port = trace.attributes['port'].to_i
|
1240
1227
|
@proto = trace.attributes['proto']
|
1241
1228
|
|
1242
|
-
@hops =
|
1243
|
-
|
1244
|
-
trace.each_element('hop') do |hop|
|
1245
|
-
@hops << Hop.new(hop)
|
1229
|
+
@hops = trace.each_element('hop') do |hop|
|
1230
|
+
Hop.new(hop)
|
1246
1231
|
end
|
1247
1232
|
end
|
1248
1233
|
end
|
@@ -1506,18 +1491,18 @@ class Nmap::Parser::Host::OS
|
|
1506
1491
|
|
1507
1492
|
return nil if os.nil?
|
1508
1493
|
|
1509
|
-
os.
|
1510
|
-
|
1494
|
+
@portsused = os.elements.collect('portused') do |port|
|
1495
|
+
PortUsed.new(port)
|
1511
1496
|
end
|
1512
1497
|
|
1513
|
-
os.
|
1514
|
-
|
1498
|
+
@osclasses = os.elements.collect('osclass') do |osclass|
|
1499
|
+
OSClass.new(osclass)
|
1515
1500
|
end
|
1516
1501
|
|
1517
1502
|
@osclasses.sort!.reverse!
|
1518
1503
|
|
1519
|
-
os.
|
1520
|
-
|
1504
|
+
@osmatches = os.elements.collect('osmatch') do |match|
|
1505
|
+
OSMatch.new(match)
|
1521
1506
|
end
|
1522
1507
|
|
1523
1508
|
@osmatches.sort!.reverse!
|
metadata
CHANGED
@@ -1,52 +1,59 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.4
|
3
|
-
specification_version: 1
|
4
2
|
name: nmap-parser
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version:
|
7
|
-
date: 2008-04-24 00:00:00 -05:00
|
8
|
-
summary: Ruby Interface to Nmap's Scan Data (Nmap::Parser Library)
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: katterjohn@gmail.com
|
12
|
-
homepage: http://rubynmap.sourceforge.net
|
13
|
-
rubyforge_project: rubynmap
|
14
|
-
description: Nmap::Parser Library
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.3.1
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Kris Katterjohn
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-01-01 00:00:00 -06:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Nmap::Parser Library
|
17
|
+
email: katterjohn@gmail.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
31
24
|
files:
|
32
25
|
- BUGS
|
33
26
|
- LICENSE
|
34
27
|
- README
|
35
28
|
- lib/nmap/parser.rb
|
36
|
-
|
37
|
-
|
29
|
+
has_rdoc: true
|
30
|
+
homepage: http://rubynmap.sourceforge.net
|
31
|
+
post_install_message:
|
38
32
|
rdoc_options:
|
39
33
|
- --title
|
40
34
|
- Ruby Nmap::Parser Library
|
41
35
|
- --main
|
42
36
|
- Nmap::Parser
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
49
51
|
requirements: []
|
50
52
|
|
51
|
-
|
53
|
+
rubyforge_project: rubynmap
|
54
|
+
rubygems_version: 1.2.0
|
55
|
+
signing_key:
|
56
|
+
specification_version: 2
|
57
|
+
summary: Ruby Interface to Nmap's Scan Data (Nmap::Parser Library)
|
58
|
+
test_files: []
|
52
59
|
|