@@ -41,8 +41,6 @@ def initialize
41
41
] , self . class )
42
42
end
43
43
44
-
45
- # Define our batch size
46
44
def run_batch_size
47
45
datastore [ 'BATCHSIZE' ] . to_i
48
46
end
@@ -51,7 +49,6 @@ def rport
51
49
datastore [ 'RPORT' ] . to_i
52
50
end
53
51
54
- # Fingerprint a single host
55
52
def run_batch ( batch )
56
53
57
54
print_status ( "Finding ADDP nodes within #{ batch [ 0 ] } ->#{ batch [ -1 ] } (#{ batch . length } hosts)" )
@@ -68,16 +65,23 @@ def run_batch(batch)
68
65
69
66
batch . each do |ip |
70
67
begin
71
-
72
68
# Try all currently-known magic probe values
73
69
Rex ::Proto ::ADDP . request_config_all . each do |pkt |
74
- udp_sock . sendto ( pkt , ip , rport , 0 )
70
+ begin
71
+ udp_sock . sendto ( pkt , ip , rport , 0 )
72
+ rescue ::Errno ::ENOBUFS
73
+ print_status ( "Socket buffers are full, waiting for them to flush..." )
74
+ while ( r = udp_sock . recvfrom ( 65535 , 0.1 ) and r [ 1 ] )
75
+ parse_reply ( r )
76
+ end
77
+ select ( nil , nil , nil , 0.25 )
78
+ retry
79
+ end
75
80
end
76
81
77
82
rescue ::Interrupt
78
83
raise $!
79
- rescue ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionRefused
80
- nil
84
+ rescue ::Rex ::ConnectionError
81
85
end
82
86
83
87
if ( idx % 30 == 0 )
@@ -103,7 +107,18 @@ def run_batch(batch)
103
107
info = Rex ::Proto ::ADDP . reply_to_string ( res )
104
108
print_status ( "#{ ip } :#{ rport } Sending reboot request to device with MAC #{ res [ :mac ] } ..." )
105
109
pkt = Rex ::Proto ::ADDP . request_reboot ( res [ :magic ] , res [ :mac ] , datastore [ 'ADDP_PASSWORD' ] )
106
- udp_sock . sendto ( pkt , ip , rport , 0 )
110
+
111
+ begin
112
+ udp_sock . sendto ( pkt , ip , rport , 0 )
113
+ rescue ::Errno ::ENOBUFS
114
+ print_status ( "Socket buffers are full, waiting for them to flush..." )
115
+ while ( r = udp_sock . recvfrom ( 65535 , 0.1 ) and r [ 1 ] )
116
+ parse_reply ( r )
117
+ end
118
+ select ( nil , nil , nil , 0.25 )
119
+ retry
120
+ end
121
+
107
122
while ( r = udp_sock . recvfrom ( 65535 , 0.1 ) and r [ 1 ] )
108
123
parse_reply ( r )
109
124
end
@@ -115,12 +130,6 @@ def run_batch(batch)
115
130
116
131
rescue ::Interrupt
117
132
raise $!
118
- rescue ::Errno ::ENOBUFS
119
- print_status ( "Socket buffers are full, waiting for them to flush..." )
120
- while ( r = udp_sock . recvfrom ( 65535 , 0.1 ) and r [ 1 ] )
121
- parse_reply ( r )
122
- end
123
- select ( nil , nil , nil , 0.25 )
124
133
rescue ::Exception => e
125
134
print_error ( "Unknown error: #{ e . class } #{ e } #{ e . backtrace } " )
126
135
end
0 commit comments