Fallback if the regex fails for some reason
parent
f56eac7f10
commit
1cebc9f3cb
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue