Class: Rex::Post::Meterpreter::Packet
- Defined in:
- lib/rex/post/meterpreter/packet.rb
Overview
The logical meterpreter packet class
Instance Attribute Summary collapse
-
#created_at ⇒ Object
Returns the value of attribute created_at.
Attributes inherited from GroupTlv
Attributes inherited from Tlv
Class Method Summary collapse
-
.create_request(method = nil) ⇒ Object
Creates a request with the supplied method.
-
.create_response(request = nil) ⇒ Object
Creates a response to a request if one is provided.
Instance Method Summary collapse
-
#initialize(type = nil, method = nil) ⇒ Packet
constructor
Initializes the packet to the supplied packet type and method, if any.
-
#method ⇒ Object
Returns the value of the packet’s method TLV.
-
#method=(method) ⇒ Object
Sets the packet’s method TLV to the method supplied.
-
#method?(method) ⇒ Boolean
Checks to see if the packet’s method is equal to the supplied method.
-
#response? ⇒ Boolean
Checks to see if the packet is a response.
-
#result ⇒ Object
Gets the value of the packet’s result TLV.
-
#result=(result) ⇒ Object
Sets the packet’s result TLV.
-
#result?(result) ⇒ Boolean
Checks to see if the packet’s result value is equal to the supplied result.
-
#rid ⇒ Object
Gets the value of the packet’s request identifier TLV.
Methods inherited from GroupTlv
#add_tlv, #add_tlvs, #each, #each_tlv, #each_tlv_with_index, #each_with_index, #from_r, #get_tlv, #get_tlv_value, #get_tlv_values, #get_tlvs, #has_tlv?, #reset, #to_r
Methods inherited from Tlv
#from_r, #inspect, #meta_type?, #to_r, #type?, #value?
Constructor Details
#initialize(type = nil, method = nil) ⇒ Packet
Initializes the packet to the supplied packet type and method, if any. If the packet is a request, a request identifier is created.
597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 |
# File 'lib/rex/post/meterpreter/packet.rb', line 597 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 |
Instance Attribute Details
#created_at ⇒ Object
Returns the value of attribute created_at.
553 554 555 |
# File 'lib/rex/post/meterpreter/packet.rb', line 553 def created_at @created_at end |
Class Method Details
.create_request(method = nil) ⇒ Object
Creates a request with the supplied method.
564 565 566 |
# File 'lib/rex/post/meterpreter/packet.rb', line 564 def Packet.create_request(method = nil) return Packet.new(PACKET_TYPE_REQUEST, method) end |
.create_response(request = nil) ⇒ Object
Creates a response to a request if one is provided.
571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'lib/rex/post/meterpreter/packet.rb', line 571 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 |
Instance Method Details
#method ⇒ Object
Returns the value of the packet’s method TLV.
654 655 656 |
# File 'lib/rex/post/meterpreter/packet.rb', line 654 def method return get_tlv_value(TLV_TYPE_METHOD) end |
#method=(method) ⇒ Object
Sets the packet’s method TLV to the method supplied.
647 648 649 |
# File 'lib/rex/post/meterpreter/packet.rb', line 647 def method=(method) add_tlv(TLV_TYPE_METHOD, method, true) end |
#method?(method) ⇒ Boolean
Checks to see if the packet’s method is equal to the supplied method.
640 641 642 |
# File 'lib/rex/post/meterpreter/packet.rb', line 640 def method?(method) return (get_tlv_value(TLV_TYPE_METHOD) == method) end |
#response? ⇒ Boolean
Checks to see if the packet is a response.
626 627 628 629 |
# File 'lib/rex/post/meterpreter/packet.rb', line 626 def response? return ((self.type == PACKET_TYPE_RESPONSE) || (self.type == PACKET_TYPE_PLAIN_RESPONSE)) end |
#result ⇒ Object
Gets the value of the packet’s result TLV.
676 677 678 |
# File 'lib/rex/post/meterpreter/packet.rb', line 676 def result return get_tlv_value(TLV_TYPE_RESULT) end |
#result=(result) ⇒ Object
Sets the packet’s result TLV.
669 670 671 |
# File 'lib/rex/post/meterpreter/packet.rb', line 669 def result=(result) add_tlv(TLV_TYPE_RESULT, result, true) end |
#result?(result) ⇒ Boolean
Checks to see if the packet’s result value is equal to the supplied result.
662 663 664 |
# File 'lib/rex/post/meterpreter/packet.rb', line 662 def result?(result) return (get_tlv_value(TLV_TYPE_RESULT) == result) end |
#rid ⇒ Object
Gets the value of the packet’s request identifier TLV.
683 684 685 |
# File 'lib/rex/post/meterpreter/packet.rb', line 683 def rid return get_tlv_value(TLV_TYPE_REQUEST_ID) end |