wifimap 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -3
- data/lib/wifimap/parser/sniff_probes.rb +43 -0
- data/lib/wifimap/parser.rb +20 -13
- data/lib/wifimap/version.rb +1 -1
- data/lib/wifimap.rb +20 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93a98307084f4ecda1bb218964bece248af40a57b95ad2b423dac9654154dd89
|
4
|
+
data.tar.gz: 897d5c06126dadf291ab26207cce1abb75a36a17a2ef8e2697c7c89edcd0b4a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dcbd8568e6634cf0a59d0048db5d43145ed61dfbca93c85dd3ab2d9bc8166c96bcaafa7a707a50a8ecff1eb3451385968e38535ef60ae65e9bad56aa1cd1eb81
|
7
|
+
data.tar.gz: d54d442bda06642a18a10c51a64b3488f7bb963a3f4b3d81e43ccf1e8a75d8e02f1465279ff189c8722d352530d5ee45ea89efb4529d6815a5dc8b9d8f7c2a88
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -22,12 +22,14 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
Require
|
25
|
+
Require wifimap and pass the content of a dump file to the `parse` method:
|
26
26
|
```rb
|
27
|
-
require 'wifimap
|
27
|
+
require 'wifimap'
|
28
28
|
|
29
29
|
dump = File.read('airodump.csv')
|
30
|
-
parsed = Wifimap
|
30
|
+
parsed = Wifimap.parse(dump)
|
31
|
+
# Alternative:
|
32
|
+
# parsed = Wifimap.parse_file('airodump.csv')
|
31
33
|
|
32
34
|
parsed.access_points # returns an array of AccessPoint objects
|
33
35
|
parsed.stations # returns an array of Station objects
|
@@ -55,6 +57,7 @@ station.manufacturer # ex.: 'Apple, Inc.'
|
|
55
57
|
|
56
58
|
### Supported dump formats
|
57
59
|
- Airodump CSV ([airodump-ng](https://www.aircrack-ng.org/doku.php?id=airodump-ng))
|
60
|
+
- Sniff Probes ([sniff-probes](https://github.com/brannondorsey/sniff-probes))
|
58
61
|
|
59
62
|
## Development
|
60
63
|
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'wifimap/station'
|
4
|
+
|
5
|
+
module Wifimap
|
6
|
+
module Parser
|
7
|
+
# Parse the content of a sniff-probes file.
|
8
|
+
class SniffProbes
|
9
|
+
attr_reader :access_points
|
10
|
+
|
11
|
+
def initialize(dump)
|
12
|
+
@dump = dump
|
13
|
+
@access_points = []
|
14
|
+
end
|
15
|
+
|
16
|
+
# Get the list of stations from the dump.
|
17
|
+
def stations
|
18
|
+
unique_macs.map do |mac|
|
19
|
+
station = Station.new(mac: mac)
|
20
|
+
rows.each do |row|
|
21
|
+
fields = row.split('"')
|
22
|
+
unless station.probes.include?(fields[1])
|
23
|
+
station.probes << fields[1] if fields[0].include?(mac)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
station
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
# Return an array of lines from the dump content.
|
33
|
+
def rows
|
34
|
+
@dump.split("\n")
|
35
|
+
end
|
36
|
+
|
37
|
+
# Return all unique mac addresses.
|
38
|
+
def unique_macs
|
39
|
+
rows.map { |row| row.split[2] }.uniq
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/wifimap/parser.rb
CHANGED
@@ -1,22 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'wifimap/
|
3
|
+
require 'wifimap/mac'
|
4
4
|
|
5
5
|
module Wifimap
|
6
6
|
module Parser
|
7
|
-
#
|
8
|
-
def self.
|
9
|
-
|
10
|
-
|
11
|
-
Wifimap::Parser::Airodump.new(file_content)
|
12
|
-
else
|
13
|
-
raise Error, 'Unsupported dump format'
|
14
|
-
end
|
7
|
+
# Check the file content and identify the correct dump format.
|
8
|
+
def self.dump_format(file_content)
|
9
|
+
return :airodump if airodump_format?(file_content)
|
10
|
+
return :sniff_probes if sniff_probes_format?(file_content)
|
15
11
|
end
|
16
12
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
13
|
+
class << self
|
14
|
+
private
|
15
|
+
|
16
|
+
def airodump_format?(file_content)
|
17
|
+
airodump_header = 'BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power'
|
18
|
+
file_content.include?(airodump_header)
|
19
|
+
end
|
20
|
+
|
21
|
+
def sniff_probes_format?(file_content)
|
22
|
+
file_content.split("\n").all? do |row|
|
23
|
+
fields = row.split
|
24
|
+
fields[1].include?('dBm') && Wifimap::Mac.valid?(fields[2])
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
21
28
|
end
|
22
29
|
end
|
data/lib/wifimap/version.rb
CHANGED
data/lib/wifimap.rb
CHANGED
@@ -1,7 +1,27 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'wifimap/version'
|
4
|
+
require 'wifimap/parser'
|
5
|
+
require 'wifimap/parser/airodump'
|
4
6
|
|
5
7
|
module Wifimap
|
6
8
|
class Error < StandardError; end
|
9
|
+
|
10
|
+
# Parse the content of a dump file and return a hash of APs, stations and probes.
|
11
|
+
def self.parse(file_content)
|
12
|
+
case Wifimap::Parser.dump_format(file_content)
|
13
|
+
when :airodump
|
14
|
+
Wifimap::Parser::Airodump.new(file_content)
|
15
|
+
when :sniff_probes
|
16
|
+
Wifimap::Parser::SniffProbes.new(file_content)
|
17
|
+
else
|
18
|
+
raise Error, 'Unsupported dump format'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
# A wrapper on .parse to read directly from a file.
|
23
|
+
def self.parse_file(filename)
|
24
|
+
file_content = File.read(filename)
|
25
|
+
parse(file_content)
|
26
|
+
end
|
7
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wifimap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gianpiero Addis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: louis
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/wifimap/mac.rb
|
49
49
|
- lib/wifimap/parser.rb
|
50
50
|
- lib/wifimap/parser/airodump.rb
|
51
|
+
- lib/wifimap/parser/sniff_probes.rb
|
51
52
|
- lib/wifimap/station.rb
|
52
53
|
- lib/wifimap/version.rb
|
53
54
|
- wifimap.gemspec
|