Skip to content

Commit 9243cfd

Browse files
committed
Minor fixes to ruby style things
1 parent 91aa5fa commit 9243cfd

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

lib/msf/core/exploit/tincd.rb

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ def send_recv(packet_payload)
7979
end
8080
rescue Errno::ECONNRESET
8181
if @state == :metakey_state
82-
fail 'Server reset the connection. Probably rejecting '\
83-
'the private key and/or client name (e.g. client name not associated '\
84-
'with client public key on server side). '\
85-
'Wrong server public key possible too. '\
86-
'Please recheck client name, client private key and '\
87-
'server public key.'
82+
fail 'Server reset the connection. Probably rejecting ' +
83+
'the private key and/or client name (e.g. client name not associated ' +
84+
'with client public key on server side). ' +
85+
'Wrong server public key possible too. ' +
86+
'Please recheck client name, client private key and ' +
87+
'server public key.'
8888
else
8989
fail 'Server reset the connection, reason unknown.'
9090
end
@@ -149,7 +149,7 @@ def process_data(data)
149149
data = read_line
150150
vprint_status("Received Metakey from server: [#{data[0..30]}...]")
151151
data = data.split(' ')
152-
fail 'Error in protocol. The first byte should be an ASCII 1.' unless data[0] == '1'
152+
fail 'Error in protocol. The first byte should be an ASCII 1.' unless data.first == '1'
153153
hexkey_s2 = data[5].rstrip # ("\n")
154154
fail "Error in protocol. metakey length should be #{@client_key_len}." unless hexkey_s2.length == @client_key_len * 2
155155
@enckey_s2 = [hexkey_s2].pack('H*')
@@ -179,10 +179,10 @@ def process_data(data)
179179
need_len = 2 * @client_key_len + 3
180180
if @inbuffer.length >= need_len
181181
data = pop_inbuffer_and_decrypt(need_len)
182-
vprint_status("Received challenge from server: "\
183-
"[#{data.unpack('H*')[0][0..30]}...]")
182+
vprint_status("Received challenge from server: " +
183+
"[#{data.unpack('H*')[0][0..30]}...]")
184184
data = data.split(' ', 2)
185-
fail 'Error in protocol. The first byte should be an ASCII 2. Got #{data[0]}.' unless data[0] == '2'
185+
fail 'Error in protocol. The first byte should be an ASCII 2. Got #{data[0]}.' unless data.first == '2'
186186
challenge2 = data[1][0...2 * @client_key_len]
187187
challenge2 = [challenge2].pack('H*')
188188
fail "Error in protocol. challenge2 length should be #{@client_key_len}." unless challenge2.length == @client_key_len
@@ -193,17 +193,17 @@ def process_data(data)
193193
need_len = 43
194194
if @inbuffer.length >= need_len
195195
data = pop_inbuffer_and_decrypt(need_len)
196-
vprint_status("Received challenge reply from server:"\
197-
" [#{data.unpack('H*')[0][0..30]}...]")
196+
vprint_status("Received challenge reply from server:" +
197+
" [#{data.unpack('H*')[0][0..30]}...]")
198198
@state = :ack_state
199199
ack
200200
end
201201
when :ack_state
202202
need_len = 12
203203
if @inbuffer.length >= need_len
204204
data = pop_inbuffer_and_decrypt(need_len)
205-
vprint_status("Received ack (server accepted challenge response):"\
206-
"[#{data.unpack('H*')[0][0..30]}...]")
205+
vprint_status("Received ack (server accepted challenge response):" +
206+
"[#{data.unpack('H*')[0][0..30]}...]")
207207
@state = :done_state
208208
send_packet
209209
end
@@ -216,7 +216,7 @@ def process_data(data)
216216
#
217217
def handle_write
218218
# handle encryption queue first
219-
if @encryption_queue.length > 0
219+
unless @encryption_queue.empty?
220220
msg = @encryption_queue[0]
221221
@encryption_queue.delete_at(0)
222222
@buffer = @bf_enc_cipher.update(msg)
@@ -225,10 +225,10 @@ def handle_write
225225
# the resulting block is used to encrypt the next block.
226226
end
227227

228-
if @buffer.length > 0
228+
unless @buffer.empty?
229229
sent = send_data(@buffer)
230-
vprint_status("Sent #{sent} bytes: "\
231-
"[#{@buffer.unpack('H*')[0][0..30]}...]")
230+
vprint_status("Sent #{sent} bytes: " +
231+
"[#{@buffer.unpack('H*')[0][0..30]}...]")
232232
@buffer = @buffer[sent..@buffer.length]
233233
end
234234
end
@@ -318,8 +318,8 @@ def challenge_reply(challenge2)
318318
# Ack state to signalise challenge/response was successfull
319319
#
320320
def ack
321-
vprint_status('Sending ack (signalise server that we accept challenge'\
322-
'reply, ciphertext)')
321+
vprint_status('Sending ack (signalise server that we accept challenge' +
322+
'reply, ciphertext)')
323323
@encryption_queue.push("4 #{datastore['RPORT']} 123 0 \n")
324324
handle_write
325325
end

modules/exploits/multi/vpn/tincd_bof.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def initialize(info = {})
9090
# Has to be short, usually either . or /tmp works
9191
# /tmp could be mounted as noexec
9292
# . is usually only working if tincd is running as root
93-
OptString.new('BINARY_DROP_LOCATION', [false, 'Location to drop executable on server, usually /tmp or .', '/tmp']),
93+
OptString.new('BINARY_DROP_LOCATION', [false, 'Short location to drop executable on server, usually /tmp or .', '/tmp']),
9494
OptInt.new('BRUTEFORCE_TRIES', [false, 'How many brute force tries (ASLR brute force)', 200]),
9595
OptInt.new('WAIT', [false, 'Waiting time for server daemon restart (ASLR brute force)', 3])
9696
], self

0 commit comments

Comments
 (0)