Class: BetterCap::Parsers::Url

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

Overview

HTTP GET requests parser.

Instance Method Summary collapse

Methods inherited from Base

available, from_cmdline, from_exclusion_list, inherited, #initialize, load_by_names, load_custom, #match_port?

Constructor Details

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

Instance Method Details

#on_packet(pkt) ⇒ Object



18
19
20
21
22
23
24
25
26
27
# File 'lib/bettercap/sniffer/parsers/url.rb', line 18

def on_packet( pkt )
  s = pkt.to_s
  return unless s =~ /GET\s+([^\s]+)\s+HTTP.+Host:\s+([^\s]+).+/m

  host = $2
  url = $1
  unless url =~ /.+\.(png|jpg|jpeg|bmp|gif|img|ttf|woff|css|js).*/i
    StreamLogger.log_raw( pkt, 'GET', "http://#{host}#{url}" )
  end
end