2011-01-12 00:10:32 +00:00
|
|
|
module Msf
|
|
|
|
class Post
|
|
|
|
|
|
|
|
module Common
|
|
|
|
|
2011-01-15 05:08:42 +00:00
|
|
|
# Execute given command as hidden and channelized, output of command given as a multiline string.
|
|
|
|
# For certain versions of Meterpreter options can not be included in the cmd var
|
|
|
|
def cmd_exec(cmd,opts = nil)
|
2011-01-12 00:10:32 +00:00
|
|
|
session.response_timeout=120
|
2011-01-15 05:08:42 +00:00
|
|
|
cmd = session.sys.process.execute(cmd, opts, {'Hidden' => true, 'Channelized' => true})
|
2011-01-12 00:10:32 +00:00
|
|
|
o = ""
|
|
|
|
while(d = cmd.channel.read)
|
|
|
|
o << d
|
|
|
|
break if d == ""
|
|
|
|
end
|
|
|
|
cmd.channel.close
|
|
|
|
return o
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|