Class: BetterCap::Parsers::Cookie
- Defined in:
- lib/bettercap/sniffer/parsers/cookie.rb
Overview
HTTP cookies parser.
Constant Summary collapse
- FILTER =
Cookies to ignore.
[ '__cfduid', '_ga', '_gat' ].freeze
Instance Method Summary collapse
-
#initialize ⇒ Cookie
constructor
A new instance of Cookie.
- #on_packet(pkt) ⇒ Object
Methods inherited from Base
available, from_cmdline, from_exclusion_list, inherited, load_by_names, load_custom, #match_port?
Constructor Details
Instance Method Details
#on_packet(pkt) ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/bettercap/sniffer/parsers/cookie.rb', line 59 def on_packet( pkt ) hostname = nil = {} pkt.to_s.split("\n").each do |line| if line =~ /Host:\s*([^\s]+)/i hostname = $1 elsif line =~ /.*Cookie:\s*(.+)/i $1.strip.split(';').each do |v| k, v = v.split('=').map(&:strip) next if k.nil? or v.nil? unless k.empty? or v.empty? or FILTER.include?(k) [k] = v end end end end unless hostname.nil? or .empty? unless @jar.( pkt.ip_saddr, hostname, ) StreamLogger.log_raw( pkt, "COOKIE", "[#{hostname.yellow}] #{.map{|k,v| "#{k.green}=#{v.yellow}"}.join('; ')}" ) @jar.store( pkt.ip_saddr, hostname, ) end end end |