mirror of
https://github.com/rapid7/metasploit-framework
synced 2024-11-12 11:52:01 +01:00
Added error handling to m_exec function since some commands are not present on all versions of Windows
git-svn-id: file:///home/svn/framework3/trunk@9792 4d416f70-5f16-0410-b530-b9f4589650da
This commit is contained in:
parent
5b3fa182ba
commit
fdc22dabf6
@ -8,7 +8,7 @@
|
||||
#
|
||||
# hdm[at]metasploit.com
|
||||
#
|
||||
|
||||
@client = client
|
||||
opts = Rex::Parser::Arguments.new(
|
||||
"-h" => [ false,"Help menu." ]
|
||||
)
|
||||
@ -40,7 +40,8 @@ end
|
||||
|
||||
# Exec a command and return the results
|
||||
def m_exec(session, cmd)
|
||||
r = session.sys.process.execute(cmd, nil, {'Hidden' => true, 'Channelized' => true})
|
||||
begin
|
||||
r = @client.sys.process.execute(cmd, nil, {'Hidden' => true, 'Channelized' => true})
|
||||
b = ""
|
||||
while(d = r.channel.read)
|
||||
b << d
|
||||
@ -48,6 +49,10 @@ def m_exec(session, cmd)
|
||||
r.channel.close
|
||||
r.close
|
||||
b
|
||||
rescue ::Exception => e
|
||||
print_error("Failed to run command #{cmd}")
|
||||
print_error("Error: #{e.class} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user