patronus_fati 0.9.24 → 0.9.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/patronus_fati.rb +8 -1
- data/lib/patronus_fati/connection.rb +8 -4
- data/lib/patronus_fati/data_observers/connection_observer.rb +2 -2
- data/lib/patronus_fati/factory_base.rb +1 -2
- data/lib/patronus_fati/message_parser.rb +1 -1
- data/lib/patronus_fati/message_processor.rb +8 -6
- data/lib/patronus_fati/message_processor/critfail.rb +1 -1
- data/lib/patronus_fati/message_processor/error.rb +1 -1
- data/lib/patronus_fati/message_processor/ssid.rb +0 -3
- data/lib/patronus_fati/message_processor/terminate.rb +1 -2
- data/lib/patronus_fati/version.rb +1 -1
- data/spec/data_models/access_point_spec.rb +0 -8
- data/spec/data_models/client_spec.rb +0 -8
- metadata +4 -7
- data/spec/data_models/alert_spec.rb +0 -12
- data/spec/data_models/mac_spec.rb +0 -26
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4504c4467db0ddf6060de0a08568462ac8eef16d
|
4
|
+
data.tar.gz: 04b5dbd957cc2c07eee869bd3b65819765c19c99
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab7e424bf53de49f26a09894ce09a53e0d186038340a6dea6085cb278f091073b1079d11c1d11bac10f843908d42bd10d4b6dc6b3a5f510a18193776f3893381
|
7
|
+
data.tar.gz: 27cf289e7c84b3ae0565e171480b289e7407d8d7cdb97e954401f40a6140a5fdabb97e1682001f09c2ae1881d87266b98c06d914002dc36c555f1f30906251bf
|
data/lib/patronus_fati.rb
CHANGED
@@ -3,6 +3,7 @@ STDOUT.sync = true
|
|
3
3
|
require 'date'
|
4
4
|
require 'digest'
|
5
5
|
require 'json'
|
6
|
+
require 'logger'
|
6
7
|
require 'openssl'
|
7
8
|
require 'socket'
|
8
9
|
require 'timeout'
|
@@ -52,7 +53,6 @@ module PatronusFati
|
|
52
53
|
end
|
53
54
|
|
54
55
|
def self.setup(kismet_server, kismet_port, database_uri)
|
55
|
-
#DataMapper::Logger.new('pf-db.log', :debug)
|
56
56
|
DataMapper.setup(:default, database_uri)
|
57
57
|
DataMapper.repository(:default).adapter.resource_naming_convention = PatronusFati::NullTablePrefix
|
58
58
|
DataMapper.finalize
|
@@ -61,6 +61,13 @@ module PatronusFati
|
|
61
61
|
PatronusFati::Connection.new(kismet_server, kismet_port)
|
62
62
|
end
|
63
63
|
|
64
|
+
def logger
|
65
|
+
@logger ||= Logger.new
|
66
|
+
end
|
67
|
+
|
68
|
+
def logger=(logger)
|
69
|
+
@logger = logger
|
70
|
+
|
64
71
|
def self.startup_time
|
65
72
|
@@startup_time
|
66
73
|
end
|
@@ -60,8 +60,10 @@ module PatronusFati
|
|
60
60
|
rescue IOError, EOFError => e
|
61
61
|
raise DisconnectError
|
62
62
|
rescue => e
|
63
|
-
|
64
|
-
|
63
|
+
PatronusFati.logger.error(format('Error in read thread: %s %s', e.class.to_s, e.message))
|
64
|
+
e.backtrace.each do |l|
|
65
|
+
PatronusFati.logger.error(l)
|
66
|
+
end
|
65
67
|
ensure
|
66
68
|
socket.close if socket && !socket.closed?
|
67
69
|
end
|
@@ -77,8 +79,10 @@ module PatronusFati
|
|
77
79
|
count += 1
|
78
80
|
end
|
79
81
|
rescue => e
|
80
|
-
|
81
|
-
|
82
|
+
PatronusFati.logger.error(format('Error in write thread: %s %s', e.class.to_s, e.message))
|
83
|
+
e.backtrace.each do |l|
|
84
|
+
PatronusFati.logger.error(l)
|
85
|
+
end
|
82
86
|
ensure
|
83
87
|
socket.close if socket && !socket.closed?
|
84
88
|
end
|
@@ -42,7 +42,7 @@ module PatronusFati::DataObservers
|
|
42
42
|
)
|
43
43
|
else
|
44
44
|
# Weird situation, new record that is already disconnected...
|
45
|
-
warn('Connection (%i) created that is already disconnected' % id)
|
45
|
+
PatronusFati.logger.warn('Connection (%i) created that is already disconnected' % id)
|
46
46
|
end
|
47
47
|
else
|
48
48
|
if @change_list.keys.include?('disconnected_at') && @change_list['disconnected_at'][0] == nil && !disconnected_at.nil?
|
@@ -52,7 +52,7 @@ module PatronusFati::DataObservers
|
|
52
52
|
self.full_state.merge(duration: duration)
|
53
53
|
)
|
54
54
|
else
|
55
|
-
warn('Connection (%i) updated in a weird way: %s' % [id, @change_list.inspect])
|
55
|
+
PatronusFati.logger.warn('Connection (%i) updated in a weird way: %s' % [id, @change_list.inspect])
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
@@ -21,8 +21,7 @@ module PatronusFati
|
|
21
21
|
def factory(type, opts = {})
|
22
22
|
return if ignored_types.include?(type)
|
23
23
|
if registered_factories[type].nil?
|
24
|
-
warn("Unknown factory #{type} (Available: #{registered_factories.keys})")
|
25
|
-
#puts opts.inspect
|
24
|
+
PatronusFati.logger.warn("Unknown factory #{type} (Available: #{registered_factories.keys})")
|
26
25
|
return
|
27
26
|
end
|
28
27
|
registered_factories[type].process(opts)
|
@@ -9,7 +9,7 @@ module PatronusFati
|
|
9
9
|
return unless (raw_data = handle_msg(msg))
|
10
10
|
|
11
11
|
unless (cap = get_model(raw_data[0]))
|
12
|
-
warn('Message received had unknown message type: ' + raw_data[0])
|
12
|
+
PatronusFati.logger.warn('Message received had unknown message type: ' + raw_data[0])
|
13
13
|
return
|
14
14
|
end
|
15
15
|
|
@@ -86,14 +86,16 @@ module PatronusFati
|
|
86
86
|
rescue DataObjects::SyntaxError => e
|
87
87
|
# SQLite dropped our database. We need to log the condition and bail out
|
88
88
|
# of the program completely.
|
89
|
-
|
90
|
-
|
89
|
+
PatronusFati.logger.error('SQLite dropped our database: %s: %s' % [e.class, e.message])
|
90
|
+
PatronusFati.logger.error('Exiting since we don\'t have a database...')
|
91
91
|
exit 1
|
92
92
|
rescue => e
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
93
|
+
PatronusFati.logger.error('Error processing the following message object:')
|
94
|
+
PatronusFati.logger.error(message_obj.inspect)
|
95
|
+
PatronusFati.logger.error('%s: %s' % [e.class, e.message])
|
96
|
+
e.backtrace.each do |l|
|
97
|
+
PatronusFati.logger.error(l)
|
98
|
+
end
|
97
99
|
end
|
98
100
|
|
99
101
|
def self.ignored_types
|
@@ -2,6 +2,6 @@ module PatronusFati::MessageProcessor::Error
|
|
2
2
|
include PatronusFati::MessageProcessor
|
3
3
|
|
4
4
|
def self.process(opts)
|
5
|
-
warn('Failed command ID %i with error: %s' % [opts.cmdid, opts.text])
|
5
|
+
PatronusFati.logger.warn('Failed command ID %i with error: %s' % [opts.cmdid, opts.text])
|
6
6
|
end
|
7
7
|
end
|
@@ -29,9 +29,6 @@ module PatronusFati::MessageProcessor::Ssid
|
|
29
29
|
|
30
30
|
return if obj[:ssid].nil? || obj[:ssid].empty?
|
31
31
|
client.probes.first_or_create(essid: obj[:ssid])
|
32
|
-
else
|
33
|
-
# The only thing left is the 'file' type which no one seems to understand
|
34
|
-
#puts ('Unknown SSID type (%s): %s' % [obj[:type], obj.inspect])
|
35
32
|
end
|
36
33
|
|
37
34
|
nil
|
@@ -2,8 +2,7 @@ module PatronusFati::MessageProcessor::Terminate
|
|
2
2
|
include PatronusFati::MessageProcessor
|
3
3
|
|
4
4
|
def self.process(obj)
|
5
|
-
|
6
|
-
|
5
|
+
PatronusFati.logger.info('Kismet announced it\'s intention to gracefully terminate')
|
7
6
|
nil
|
8
7
|
end
|
9
8
|
end
|
@@ -15,12 +15,4 @@ RSpec.describe 'DataModels::AccessPoint' do
|
|
15
15
|
it { expect(subject).to have_many(:ssids) }
|
16
16
|
|
17
17
|
it { expect(subject).to have_many(:clients).through(:connections) }
|
18
|
-
|
19
|
-
it { expect(subject).to belong_to(:mac) }
|
20
|
-
|
21
|
-
it 'should associate to a MAC object before saving' do
|
22
|
-
expect(unsaved_instance.mac).to be_nil
|
23
|
-
unsaved_instance.save
|
24
|
-
expect(unsaved_instance.mac).to be_instance_of(PatronusFati::DataModels::Mac)
|
25
|
-
end
|
26
18
|
end
|
@@ -14,12 +14,4 @@ RSpec.describe 'DataModels::Client' do
|
|
14
14
|
|
15
15
|
it { expect(subject).to have_many(:connections) }
|
16
16
|
it { expect(subject).to have_many(:access_points).through(:connections) }
|
17
|
-
|
18
|
-
it { expect(subject).to belong_to(:mac) }
|
19
|
-
|
20
|
-
it 'should associate to a MAC object before saving' do
|
21
|
-
expect(unsaved_instance.mac).to be_nil
|
22
|
-
unsaved_instance.save
|
23
|
-
expect(unsaved_instance.mac).to be_instance_of(PatronusFati::DataModels::Mac)
|
24
|
-
end
|
25
17
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: patronus_fati
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.30
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Stelfox
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dm-constraints
|
@@ -345,10 +345,8 @@ files:
|
|
345
345
|
- lib/patronus_fati/version.rb
|
346
346
|
- patronus_fati.gemspec
|
347
347
|
- spec/data_models/access_point_spec.rb
|
348
|
-
- spec/data_models/alert_spec.rb
|
349
348
|
- spec/data_models/client_spec.rb
|
350
349
|
- spec/data_models/connection_spec.rb
|
351
|
-
- spec/data_models/mac_spec.rb
|
352
350
|
- spec/patronus_fati_spec.rb
|
353
351
|
- spec/spec_helper.rb
|
354
352
|
homepage: ''
|
@@ -371,15 +369,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
371
369
|
version: '0'
|
372
370
|
requirements: []
|
373
371
|
rubyforge_project:
|
374
|
-
rubygems_version: 2.
|
372
|
+
rubygems_version: 2.5.1
|
375
373
|
signing_key:
|
376
374
|
specification_version: 4
|
377
375
|
summary: A ruby implementation of the Kismet client protocol.
|
378
376
|
test_files:
|
379
377
|
- spec/data_models/access_point_spec.rb
|
380
|
-
- spec/data_models/alert_spec.rb
|
381
378
|
- spec/data_models/client_spec.rb
|
382
379
|
- spec/data_models/connection_spec.rb
|
383
|
-
- spec/data_models/mac_spec.rb
|
384
380
|
- spec/patronus_fati_spec.rb
|
385
381
|
- spec/spec_helper.rb
|
382
|
+
has_rdoc:
|
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'DataModels::Alert' do
|
4
|
-
subject { PatronusFati::DataModels::Alert }
|
5
|
-
|
6
|
-
it { expect(subject).to have_property(:created_at) }
|
7
|
-
it { expect(subject).to have_property(:message) }
|
8
|
-
|
9
|
-
it { expect(subject).to belong_to(:src_mac) }
|
10
|
-
it { expect(subject).to belong_to(:dst_mac) }
|
11
|
-
it { expect(subject).to belong_to(:other_mac) }
|
12
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
RSpec.describe 'DataModels::Mac' do
|
4
|
-
subject { PatronusFati::DataModels::Mac }
|
5
|
-
|
6
|
-
let(:unsaved_instance) { subject.new(mac: '00:12:34:00:00:00') }
|
7
|
-
let(:saved_instance) { unsaved_instance.save }
|
8
|
-
|
9
|
-
it { expect(subject).to have_property(:mac) }
|
10
|
-
it { expect(subject).to have_property(:vendor) }
|
11
|
-
|
12
|
-
it { expect(subject).to have_many(:access_points) }
|
13
|
-
it { expect(subject).to have_many(:clients) }
|
14
|
-
|
15
|
-
it { expect(subject).to have_many(:dst_alerts) }
|
16
|
-
it { expect(subject).to have_many(:other_alerts) }
|
17
|
-
it { expect(subject).to have_many(:src_alerts) }
|
18
|
-
|
19
|
-
# This is a tad bit annoying, data mapper generates Ruby warnings about
|
20
|
-
# uninitialized instance variables.
|
21
|
-
it 'should set the vendor on the MAC object before saving' do
|
22
|
-
expect(unsaved_instance.vendor).to be_nil
|
23
|
-
unsaved_instance.save
|
24
|
-
expect(unsaved_instance.vendor).to_not be_nil
|
25
|
-
end
|
26
|
-
end
|