class Rex::Post::Meterpreter::Packet
The logical meterpreter packet class
Attributes
created_at[RW]
Public Class Methods
create_request(method = nil)
click to toggle source
Creates a request with the supplied method.
# File lib/rex/post/meterpreter/packet.rb, line 582 def Packet.create_request(method = nil) return Packet.new(PACKET_TYPE_REQUEST, method) end
create_response(request = nil)
click to toggle source
Creates a response to a request if one is provided.
# File lib/rex/post/meterpreter/packet.rb, line 589 def Packet.create_response(request = nil) response_type = PACKET_TYPE_RESPONSE method = nil if (request) if (request.type?(PACKET_TYPE_PLAIN_REQUEST)) response_type = PACKET_TYPE_PLAIN_RESPONSE end method = request.method end return Packet.new(response_type, method) end
new(type = nil, method = nil)
click to toggle source
Initializes the packet to the supplied packet type and method, if any. If the packet is a request, a request identifier is created.
Calls superclass method
Rex::Post::Meterpreter::GroupTlv::new
# File lib/rex/post/meterpreter/packet.rb, line 615 def initialize(type = nil, method = nil) super(type) if (method) self.method = method end self.created_at = ::Time.now # If it's a request, generate a random request identifier if ((type == PACKET_TYPE_REQUEST) || (type == PACKET_TYPE_PLAIN_REQUEST)) rid = '' 32.times { |val| rid << rand(10).to_s } add_tlv(TLV_TYPE_REQUEST_ID, rid) end end
Public Instance Methods
method()
click to toggle source
Returns the value of the packet’s method TLV.
# File lib/rex/post/meterpreter/packet.rb, line 672 def method return get_tlv_value(TLV_TYPE_METHOD) end
method=(method)
click to toggle source
Sets the packet’s method TLV to the method supplied.
# File lib/rex/post/meterpreter/packet.rb, line 665 def method=(method) add_tlv(TLV_TYPE_METHOD, method, true) end
method?(method)
click to toggle source
Checks to see if the packet’s method is equal to the supplied method.
# File lib/rex/post/meterpreter/packet.rb, line 658 def method?(method) return (get_tlv_value(TLV_TYPE_METHOD) == method) end
response?()
click to toggle source
Checks to see if the packet is a response.
# File lib/rex/post/meterpreter/packet.rb, line 644 def response? return ((self.type == PACKET_TYPE_RESPONSE) || (self.type == PACKET_TYPE_PLAIN_RESPONSE)) end
result()
click to toggle source
Gets the value of the packet’s result TLV.
# File lib/rex/post/meterpreter/packet.rb, line 694 def result return get_tlv_value(TLV_TYPE_RESULT) end
result=(result)
click to toggle source
Sets the packet’s result TLV.
# File lib/rex/post/meterpreter/packet.rb, line 687 def result=(result) add_tlv(TLV_TYPE_RESULT, result, true) end
result?(result)
click to toggle source
Checks to see if the packet’s result value is equal to the supplied result.
# File lib/rex/post/meterpreter/packet.rb, line 680 def result?(result) return (get_tlv_value(TLV_TYPE_RESULT) == result) end
rid()
click to toggle source
Gets the value of the packet’s request identifier TLV.
# File lib/rex/post/meterpreter/packet.rb, line 701 def rid return get_tlv_value(TLV_TYPE_REQUEST_ID) end