Module: Rex::Post::Meterpreter::HttpPacketDispatcher
- Defined in:
- lib/rex/post/meterpreter/packet_dispatcher.rb
Instance Method Summary collapse
- #connection_uuid ⇒ Object
- #initialize_passive_dispatcher ⇒ Object
- #on_passive_request(cli, req) ⇒ Object
- #shutdown_passive_dispatcher ⇒ Object
Instance Method Details
#connection_uuid ⇒ Object
713 714 715 |
# File 'lib/rex/post/meterpreter/packet_dispatcher.rb', line 713 def connection_uuid self.conn_id.to_s.split('?')[0].split('/').compact.last.gsub(/(^\/|\/$)/, '') end |
#initialize_passive_dispatcher ⇒ Object
717 718 719 720 721 722 723 724 725 726 727 728 729 |
# File 'lib/rex/post/meterpreter/packet_dispatcher.rb', line 717 def initialize_passive_dispatcher super self.passive_service = self.passive_dispatcher self.passive_service.remove_resource(self.connection_uuid) self.passive_service.add_resource(self.connection_uuid, 'Proc' => Proc.new { |cli, req| on_passive_request(cli, req) }, 'VirtualDirectory' => true, ) # Add a reference count to the handler self.passive_service.ref end |
#on_passive_request(cli, req) ⇒ Object
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 |
# File 'lib/rex/post/meterpreter/packet_dispatcher.rb', line 741 def on_passive_request(cli, req) begin resp = Rex::Proto::Http::Response.new(200, "OK") resp['Content-Type'] = 'application/octet-stream' resp['Connection'] = 'close' self.last_checkin = ::Time.now if req.method == 'GET' rpkt = send_queue.shift || '' rpkt = self.wrap_packet(rpkt) if self.respond_to?(:wrap_packet) resp.body = rpkt begin cli.send_response(resp) rescue ::Exception => e send_queue.unshift(rpkt) if rpkt elog("Exception sending a reply to the reader request #{cli.inspect}", error: e) end else resp.body = "" body = req.body if body && body.length > 0 body = self.unwrap_packet(body) if self.respond_to?(:unwrap_packet) packet = Packet.new(0) packet.add_raw(body) packet.parse_header! packet = decrypt_inbound_packet(packet) dispatch_inbound_packet(packet) end cli.send_response(resp) end rescue ::Exception => e elog("Exception handling request: #{cli.inspect} #{req.inspect}", error: e) end end |
#shutdown_passive_dispatcher ⇒ Object
731 732 733 734 735 736 737 738 739 |
# File 'lib/rex/post/meterpreter/packet_dispatcher.rb', line 731 def shutdown_passive_dispatcher if self.passive_service self.passive_service.remove_resource(self.connection_uuid) if self.passive_service self.passive_service.deref self.passive_service = nil end super end |