Skip to content

Commit 82fe480

Browse files
Update session to display username and hostname
1 parent ea0204b commit 82fe480

File tree

3 files changed

+5
-7
lines changed

3 files changed

+5
-7
lines changed

lib/msf/base/sessions/powershell.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ class Msf::Sessions::PowerShell < Msf::Sessions::CommandShell
88
def process_autoruns(datastore)
99
# Read the initial output (PS banner) and toss it)
1010
initial_output = shell_read(-1, 0.01)
11-
# TODO: send command for getting the username
12-
# TODO: parse out the username and set it to a variable
13-
# TODO: send command for getting the hostname
14-
# TODO: parse out the hostname and set it to a variable
11+
if initial_output =~ /running as user ([^\s]+) on ([^\s]+)/
12+
username = $1
13+
hostname = $2
14+
end
1515
# Set the session info
16-
self.info = initial_output
16+
self.info = "#{username} @ #{hostname}"
1717
# Call our parent class's autoruns processing method
1818
super
1919
end

modules/payloads/singles/cmd/windows/powershell_bind_tcp.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def initialize(info = {})
3131
'Arch' => ARCH_CMD,
3232
'Handler' => Msf::Handler::BindTcp,
3333
'Session' => Msf::Sessions::PowerShell,
34-
'PayloadType' => 'cmd_interact',
3534
'RequiredCmd' => 'generic',
3635
'Payload' =>
3736
{

modules/payloads/singles/cmd/windows/powershell_reverse_tcp.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ def initialize(info = {})
3131
'Arch' => ARCH_CMD,
3232
'Handler' => Msf::Handler::ReverseTcp,
3333
'Session' => Msf::Sessions::PowerShell,
34-
'PayloadType' => 'cmd_interact',
3534
'RequiredCmd' => 'generic',
3635
'Payload' =>
3736
{

0 commit comments

Comments
 (0)