Class: BetterCap::Parsers::Asterisk

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

Overview

Asterisk Call Manager authentication parser.

Instance Method Summary collapse

Methods inherited from Base

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

Constructor Details

#initialize ⇒ Asterisk

Returns a new instance of Asterisk.



21
22
23
# File 'lib/bettercap/sniffer/parsers/asterisk.rb', line 21

def initialize
  @name = 'Asterisk'
end

Instance Method Details

#on_packet(pkt) ⇒ Object



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

def on_packet( pkt )
  return unless pkt.tcp_dst == 5038
  return unless pkt.to_s =~ /action:\s+login\r?\n/i

  if pkt.to_s =~ /username:\s+(.+?)\r?\n/i && pkt.to_s =~ /secret:\s+(.+?)\r?\n/i
    user = pkt.to_s.scan(/username:\s+(.+?)\r?\n/i).flatten.first
    pass = pkt.to_s.scan(/secret:\s+(.+?)\r?\n/i).flatten.first
    StreamLogger.log_raw( pkt, @name, "username=#{user} password=#{pass}" )
  end
rescue
end