Class: BetterCap::Parsers::Https

Inherits:
Base
  • Object
show all
Defined in:
lib/bettercap/sniffer/parsers/https.rb

Overview

HTTPS connections parser.

Constant Summary collapse

@@prev =
nil

Instance Method Summary collapse

Methods inherited from Base

available, from_cmdline, inherited, #initialize, load_by_names, load_custom

Constructor Details

This class inherits a constructor from BetterCap::Parsers::Base

Instance Method Details

#on_packet(pkt) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bettercap/sniffer/parsers/https.rb', line 20

def on_packet( pkt )
  begin
    if pkt.tcp_dst == 443
      # the DNS resolution could take a while and block other parsers.
      Thread.new do
        begin
            hostname = Resolv.getname pkt.ip_daddr
        rescue
            hostname = pkt.ip_daddr.to_s
        end

        if @@prev.nil? or @@prev != hostname
          StreamLogger.log_raw( pkt, 'HTTPS', "https://#{hostname}/" )
          @@prev = hostname
        end
      end
    end
  rescue
  end
end