Class: BetterCap::Parsers::Base

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

Overview

Base class for BetterCap::Parsers.

Direct Known Subclasses

Custom, Ftp, Httpauth, Https, Irc, Mail, Ntlmss, Post, Url

Instance Method Summary collapse

Constructor Details

#initializeBase

Initialize this parser.


17
18
19
20
# File 'lib/bettercap/sniffer/parsers/base.rb', line 17

def initialize
  @filters = []
  @name = 'BASE'
end

Instance Method Details

#on_packet(pkt) ⇒ Object

This method will be called from the BetterCap::Sniffer for each incoming packet ( +pkt ) and will apply the parser filter to it.


24
25
26
27
28
29
30
31
# File 'lib/bettercap/sniffer/parsers/base.rb', line 24

def on_packet( pkt )
  s = pkt.to_s
  @filters.each do |filter|
    if s =~ filter
      StreamLogger.log_raw( pkt, @name, pkt.payload )
    end
  end
end