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

#initialize

Constructor Details

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

Instance Method Details

#on_packet(pkt) ⇒ Object


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

def on_packet( pkt )
  s = pkt.to_s
  if s =~ /GET\s+([^\s]+)\s+HTTP.+Host:\s+([^\s]+).+/m
    host = $2
    url = $1
    if not url =~ /.+\.(png|jpg|jpeg|bmp|gif|img|ttf|woff|css|js).*/i
      StreamLogger.log_raw( pkt, 'GET', "http://#{host}#{url}" )
    end
  end
end