@@ -102,13 +102,13 @@ def scanner_postscan(batch)
102
102
:proto => 'udp' ,
103
103
:port => rport ,
104
104
:type => 'ntp.addresses' ,
105
- :data => { :addresses => peers . map { |p | p [ 1 ] } . sort . uniq }
105
+ :data => { :addresses => peers . map { |p | p . last } . sort . uniq }
106
106
)
107
107
108
108
if ( datastore [ 'StoreNTPClients' ] )
109
109
print_status ( "#{ peer } Storing #{ peers . length } NTP client hosts in the database..." )
110
110
peers . each do |r |
111
- maddr , mserv , mport = r
111
+ maddr , mport , mserv = r
112
112
report_note (
113
113
:host => maddr ,
114
114
:type => 'ntp.client.history' ,
@@ -140,6 +140,7 @@ def scanner_postscan(batch)
140
140
141
141
end
142
142
143
+ # Examine the monlist reponse +data+ and extract all peer tuples (saddd, dport, daddr)
143
144
def extract_peer_tuples ( data )
144
145
return [ ] if data . length < 76
145
146
@@ -162,55 +163,9 @@ def extract_peer_tuples(data)
162
163
163
164
_ , _ , _ , _ , saddr , daddr , _ , dport = data [ idx , 30 ] . unpack ( "NNNNNNNn" )
164
165
165
- peer_tuples << [ Rex ::Socket . addr_itoa ( saddr ) , Rex ::Socket . addr_itoa ( daddr ) , dport ]
166
+ peer_tuples << [ Rex ::Socket . addr_itoa ( saddr ) , dport , Rex ::Socket . addr_itoa ( daddr ) ]
166
167
idx += plen
167
168
end
168
169
peer_tuples
169
170
end
170
-
171
- # Fingerprint a single host
172
- def parse_reply ( pkt )
173
-
174
- # Ignore "empty" packets
175
- return if not pkt [ 1 ]
176
-
177
- if ( pkt [ 1 ] =~ /^::ffff:/ )
178
- pkt [ 1 ] = pkt [ 1 ] . sub ( /^::ffff:/ , '' )
179
- end
180
-
181
- data = pkt [ 0 ]
182
- host = pkt [ 1 ]
183
- port = pkt [ 2 ]
184
-
185
- return if pkt [ 0 ] . length < ( 72 + 16 )
186
-
187
- # NTP headers 8 bytes
188
- ntp_flags , ntp_auth , ntp_vers , ntp_code = data . slice! ( 0 , 4 ) . unpack ( 'C*' )
189
- vprint_status ( "#{ host } :#{ port } - ntp_auth: #{ ntp_auth } , ntp_vers: #{ ntp_vers } " )
190
- pcnt , plen = data . slice! ( 0 , 4 ) . unpack ( 'nn' )
191
- return if plen != 72
192
-
193
- idx = 0
194
- 1 . upto ( pcnt ) do
195
- #u_int32 firsttime; /* first time we received a packet */
196
- #u_int32 lasttime; /* last packet from this host */
197
- #u_int32 restr; /* restrict bits (was named lastdrop) */
198
- #u_int32 count; /* count of packets received */
199
- #u_int32 addr; /* host address V4 style */
200
- #u_int32 daddr; /* destination host address */
201
- #u_int32 flags; /* flags about destination */
202
- #u_short port; /* port number of last reception */
203
-
204
- firsttime , lasttime , restr , count , saddr , daddr , flags , dport = data [ idx , 30 ] . unpack ( "NNNNNNNn" )
205
-
206
- @results [ host ] ||= [ ]
207
- @aliases [ host ] ||= { }
208
- @results [ host ] << [ Rex ::Socket . addr_itoa ( daddr ) , dport , Rex ::Socket . addr_itoa ( saddr ) ]
209
- @aliases [ host ] [ Rex ::Socket . addr_itoa ( saddr ) ] = true
210
- if datastore [ 'SHOW_LIST' ]
211
- print_status ( "#{ host } :#{ port } #{ Rex ::Socket . addr_itoa ( saddr ) } (lst: #{ lasttime } sec., cnt: #{ count } )" )
212
- end
213
- idx += plen
214
- end
215
- end
216
171
end
0 commit comments