Skip to content

Commit 1cebc9f

Browse files
author
HD Moore
committed
Fallback if the regex fails for some reason
1 parent f56eac7 commit 1cebc9f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/msf/base/sessions/powershell.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ class Msf::Sessions::PowerShell < Msf::Sessions::CommandShell
66
# Execute any specified auto-run scripts for this session
77
#
88
def process_autoruns(datastore)
9-
# Read the initial output (PS banner) and toss it)
9+
10+
# Read the username and hostname from the initial banner
1011
initial_output = shell_read(-1, 0.01)
1112
if initial_output =~ /running as user ([^\s]+) on ([^\s]+)/
1213
username = $1
1314
hostname = $2
15+
self.info = "#{username} @ #{hostname}"
16+
else
17+
self.info = initial_output.gsub(/[\r\n]/, ' ')
1418
end
15-
# Set the session info
16-
self.info = "#{username} @ #{hostname}"
19+
1720
# Call our parent class's autoruns processing method
1821
super
1922
end

0 commit comments

Comments
 (0)