Class: BetterCap::Parsers::Redis

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

Overview

Redis 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

#initializeRedis

Returns a new instance of Redis.



22
23
24
# File 'lib/bettercap/sniffer/parsers/redis.rb', line 22

def initialize
  @name = 'REDIS'
end

Instance Method Details

#on_packet(pkt) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/bettercap/sniffer/parsers/redis.rb', line 25

def on_packet( pkt )
  return unless pkt.tcp_dst == 6379

  lines = pkt.to_s.split(/\r?\n/)
  lines.each do |line|
    if line =~ /config\s+set\s+requirepass\s+(.+)$/i
      pass = "#{$1}"
      StreamLogger.log_raw( pkt, @name, "password=#{pass}" )
    elsif line =~ /AUTH\s+(.+)$/i
      pass = "#{$1}"
      StreamLogger.log_raw( pkt, @name, "password=#{pass}" )
    end
  end
rescue
end