@@ -86,6 +86,10 @@ def commands
86
86
# Yet to implement transport hopping for other meterpreters.
87
87
# Works for posix and native windows though.
88
88
c [ "transport" ] = "Change the current transport mechanism"
89
+
90
+ # sleep functionality relies on the transport features, so only
91
+ # wire that in with the transport stuff.
92
+ c [ "sleep" ] = "Force Meterpreter to go quiet, then re-establish session."
89
93
end
90
94
91
95
if ( msf_loaded? )
@@ -494,6 +498,45 @@ def cmd_ssl_verify(*args)
494
498
495
499
end
496
500
501
+ #
502
+ # Display help for the sleep.
503
+ #
504
+ def cmd_sleep_help
505
+ print_line ( 'Usage: sleep <time>' )
506
+ print_line
507
+ print_line ( ' time: Number of seconds to wait (positive integer)' )
508
+ print_line
509
+ print_line ( ' This command tells Meterpreter to go to sleep for the specified' )
510
+ print_line ( ' number of seconds. Sleeping will result in the transport being' )
511
+ print_line ( ' shut down and restarted after the designated timeout.' )
512
+ end
513
+
514
+ #
515
+ # Handle the sleep command.
516
+ #
517
+ def cmd_sleep ( *args )
518
+ if args . length == 0
519
+ cmd_sleep_help
520
+ return
521
+ end
522
+
523
+ seconds = args . shift . to_i
524
+
525
+ if seconds <= 0
526
+ cmd_sleep_help
527
+ return
528
+ end
529
+
530
+ print_status ( "Telling the target instance to sleep for #{ seconds } seconds ..." )
531
+ if client . core . transport_sleep ( seconds )
532
+ print_good ( "Target instance has gone to sleep, terminating current session." )
533
+ client . shutdown_passive_dispatcher
534
+ shell . stop
535
+ else
536
+ print_error ( "Target instance failed to go to sleep." )
537
+ end
538
+ end
539
+
497
540
#
498
541
# Arguments for transport switching
499
542
#
@@ -634,8 +677,9 @@ def cmd_transport(*args)
634
677
635
678
# next draw up a table of transport entries
636
679
tbl = Rex ::Ui ::Text ::Table . new (
637
- 'Indent' => 4 ,
638
- 'Columns' => columns )
680
+ 'SortIndex' => -1 , # disable any sorting
681
+ 'Indent' => 4 ,
682
+ 'Columns' => columns )
639
683
640
684
first = true
641
685
result [ :transports ] . each do |t |
0 commit comments