@@ -45,36 +45,28 @@ def initialize
45
45
deregister_options ( 'RHOST' )
46
46
end
47
47
48
- def to
49
- return 5 if datastore [ 'TIMEOUT' ] . to_i . zero?
50
- datastore [ 'TIMEOUT' ] . to_i
51
- end
52
-
53
48
def run_host ( rhost )
54
49
begin
55
- ::Timeout . timeout ( to ) do
56
- connect_udp
57
- pkt = Rex ::Text . rand_text_alpha_lower ( 1 )
58
- req = udp_sock . write ( pkt )
50
+ connect_udp
51
+ pkt = Rex ::Text . rand_text_alpha_lower ( 1 )
52
+ req = udp_sock . write ( pkt )
59
53
60
- while ( ( res = udp_sock . recvfrom ( 65535 , 0.1 ) ) && ( res [ 1 ] ) )
54
+ while ( ( res = udp_sock . recvfrom ( 65535 , 0.1 ) ) && ( res [ 1 ] ) )
61
55
62
- vprint_status ( "#{ rhost } :#{ rport } - Response: #{ res [ 0 ] . to_s } " )
56
+ vprint_status ( "#{ rhost } :#{ rport } - Response: #{ res [ 0 ] . to_s } " )
63
57
64
- res = res [ 0 ] . to_s . strip
65
- if ( res . match ( /ABCDEFGHIJKLMNOPQRSTUVWXYZ/i ) || res . match ( /0123456789/ ) )
66
- print_good ( "#{ rhost } :#{ rport } answers with #{ res . length } bytes (headers + UDP payload)" )
67
- report_service ( :host => rhost , :port => rport , :name => "chargen" , :info => res . length )
68
- end
58
+ res = res [ 0 ] . to_s . strip
59
+ if ( res . match ( /ABCDEFGHIJKLMNOPQRSTUVWXYZ/i ) || res . match ( /0123456789/ ) )
60
+ print_good ( "#{ rhost } :#{ rport } answers with #{ res . length } bytes (headers + UDP payload)" )
61
+ report_service ( :host => rhost , :port => rport , :name => "chargen" , :info => res . length )
69
62
end
63
+ end
70
64
71
- disconnect_udp
72
- end
73
- rescue ::Rex ::ConnectionError
74
- rescue Timeout ::Error
75
- vprint_error ( "#{ rhost } :#{ rport } server timed out after #{ to } seconds. Skipping." )
76
- rescue ::Exception => e
77
- vprint_error ( "#{ e } #{ e . backtrace } " )
65
+ disconnect_udp
66
+ rescue ::Interrupt
67
+ raise $!
68
+ rescue ::Rex ::HostUnreachable , ::Rex ::ConnectionTimeout , ::Rex ::ConnectionRefused
69
+ nil
78
70
end
79
71
end
80
72
end
0 commit comments