Sha256: 43bfc9d802b9cd88b39e2c48e6ebf872f96431bc2c395587ad80b7d4f3102bef

Contents?: true

Size: 1.47 KB

Versions: 18

Compression:

Stored size: 1.47 KB

Contents

#!/usr/bin/env ruby

$:.push(File.expand_path(File.join('..', '..', 'lib'), __FILE__))

require 'optparse'
require 'dm-sqlite-adapter'
require 'patronus_fati'

options = {
  'database' => 'sqlite::memory:',
  'port'   => 2501,
  'server' => '127.0.0.1'
}

OptionParser.new(nil, 32, '  ') do |opts|
  opts.on('-d', '--db-path DB_PATH', 'Path where SQLite database will be stored') do |path|
    options['database'] = ('sqlite://%s' % File.expand_path(path))
  end

  opts.on('-s', '--server SERVER', 'IP or hostname of running kismet server.') do |srv|
    options['server'] = srv
  end

  opts.on('-p', '--port PORT', 'Port that kismet server is running on.') do |port|
    options['port'] = port.to_i
  end
end.parse(ARGV)

def exception_logger(tag)
  yield
rescue Interrupt
  warn('Quitting...')
rescue => e
  puts "(#{tag}) Rescued from error: #{e.message}"
  puts e.backtrace
end

exception_logger('process') do
  connection = PatronusFati.setup(options['server'], options['port'], options['database'])
  connection.connect

  PatronusFati.event_handler.on(:any) do |asset_type, event_type, msg, opts|
    puts JSON.generate({asset_type: asset_type, event_type: event_type, data: msg, additional_data: opts, timestamp: Time.now})
  end

  while (line = connection.read_queue.pop)
    next unless (obj = PatronusFati::MessageParser.parse(line))
    responses = PatronusFati::MessageProcessor.handle(obj)

    Array(responses).each { |msg| connection.write(msg) }
  end

  connection.disconnect
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
patronus_fati-0.8.17 bin/patronus_fati
patronus_fati-0.8.16 bin/patronus_fati
patronus_fati-0.8.15 bin/patronus_fati
patronus_fati-0.8.14 bin/patronus_fati
patronus_fati-0.8.13 bin/patronus_fati
patronus_fati-0.8.12 bin/patronus_fati
patronus_fati-0.8.11 bin/patronus_fati
patronus_fati-0.8.10 bin/patronus_fati
patronus_fati-0.8.9 bin/patronus_fati
patronus_fati-0.8.8 bin/patronus_fati
patronus_fati-0.8.7 bin/patronus_fati
patronus_fati-0.8.6 bin/patronus_fati
patronus_fati-0.8.5 bin/patronus_fati
patronus_fati-0.8.4 bin/patronus_fati
patronus_fati-0.8.3 bin/patronus_fati
patronus_fati-0.8.2 bin/patronus_fati
patronus_fati-0.8.1 bin/patronus_fati
patronus_fati-0.8.0 bin/patronus_fati