Skip to content

Commit 406051a

Browse files
committed
Added more session management to hwbridge. Commands 'sessions' and 'background' added.
Signed-off-by: Craig Smith <[email protected]>
1 parent 5537348 commit 406051a

File tree

1 file changed

+36
-0
lines changed
  • lib/rex/post/hwbridge/ui/console/command_dispatcher

1 file changed

+36
-0
lines changed

lib/rex/post/hwbridge/ui/console/command_dispatcher/core.rb

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ def initialize(shell)
4747
def commands
4848
c = {
4949
"?" => "Help menu",
50+
"background" => "Backgrounds the current session",
5051
"exit" => "Terminate the hardware bridge session",
5152
"help" => "Help menu",
5253
"irb" => "Drop into irb scripting mode",
@@ -55,6 +56,7 @@ def commands
5556
"bgrun" => "Executes a meterpreter script as a background thread",
5657
"bgkill" => "Kills a background meterpreter script",
5758
"bglist" => "Lists running background scripts",
59+
"sessions" => "Quickly switch to another session",
5860
"status" => "Fetch bridge status information",
5961
"specialty" => "Hardware devices specialty",
6062
"reset" => "Resets the device (NOTE: on some devices this is a FULL FACTORY RESET)",
@@ -73,6 +75,40 @@ def name
7375
"Core"
7476
end
7577

78+
def cmd_sessions_help
79+
print_line('Usage: sessions <id>')
80+
print_line
81+
print_line('Interact with a different session Id.')
82+
print_line('This works the same as calling this from the MSF shell: sessions -i <session id>')
83+
print_line
84+
end
85+
86+
def cmd_sessions(*args)
87+
if args.length == 0 || args[0].to_i == 0
88+
cmd_sessions_help
89+
elsif args[0].to_s == client.name.to_s
90+
print_status("Session #{client.name} is already interactive.")
91+
else
92+
print_status("Backgrounding session #{client.name}...")
93+
# store the next session id so that it can be referenced as soon
94+
# as this session is no longer interacting
95+
client.next_session = args[0]
96+
client.interacting = false
97+
end
98+
end
99+
100+
def cmd_background_help
101+
print_line "Usage: background"
102+
print_line
103+
print_line "Stop interacting with this session and return to the parent prompt"
104+
print_line
105+
end
106+
107+
def cmd_background
108+
print_status "Backgrounding session #{client.name}..."
109+
client.interacting = false
110+
end
111+
76112
#
77113
# Terminates the hwbridge
78114
#

0 commit comments

Comments
 (0)