Fallback if the regex fails for some reason

bug/bundler_fix
HD Moore 2015-04-26 15:59:36 -05:00
parent f56eac7f10
commit 1cebc9f3cb
1 changed files with 6 additions and 3 deletions

View File

@ -6,14 +6,17 @@ class Msf::Sessions::PowerShell < Msf::Sessions::CommandShell
# Execute any specified auto-run scripts for this session
#
def process_autoruns(datastore)
# Read the initial output (PS banner) and toss it)
# Read the username and hostname from the initial banner
initial_output = shell_read(-1, 0.01)
if initial_output =~ /running as user ([^\s]+) on ([^\s]+)/
username = $1
hostname = $2
self.info = "#{username} @ #{hostname}"
else
self.info = initial_output.gsub(/[\r\n]/, ' ')
end
# Set the session info
self.info = "#{username} @ #{hostname}"
# Call our parent class's autoruns processing method
super
end