First pass of the python extension for windows meterpreter
This includes the basic construct for the python extension, and allows for single-shot commands to be run.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
# -*- coding: binary -*-
|
||||
|
||||
require 'rex/post/meterpreter/extensions/python/tlv'
|
||||
require 'set'
|
||||
|
||||
module Rex
|
||||
module Post
|
||||
module Meterpreter
|
||||
module Extensions
|
||||
module Python
|
||||
|
||||
###
|
||||
#
|
||||
# Python extension - gives remote python scripting capabilities on the target.
|
||||
#
|
||||
###
|
||||
|
||||
class Python < Extension
|
||||
|
||||
#
|
||||
# Typical extension initialization routine.
|
||||
#
|
||||
# @param client (see Extension#initialize)
|
||||
def initialize(client)
|
||||
super(client, 'python')
|
||||
|
||||
client.register_extension_aliases(
|
||||
[
|
||||
{
|
||||
'name' => 'python',
|
||||
'ext' => self
|
||||
}
|
||||
])
|
||||
end
|
||||
|
||||
#
|
||||
# Dump the LSA secrets from the target machine.
|
||||
#
|
||||
# @return [Hash<Symbol,Object>]
|
||||
def execute_string(code)
|
||||
request = Packet.create_request('python_execute_string')
|
||||
request.add_tlv(TLV_TYPE_PYTHON_STRING, code)
|
||||
|
||||
response = client.send_request(request)
|
||||
|
||||
response.get_tlv_value(TLV_TYPE_PYTHON_OUTPUT)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end; end; end; end; end
|
||||
|
||||
Reference in New Issue
Block a user