wifimap 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf34d96b423042eeb6528fc637a1d3b622d1d14881b495882b9be47212d31b38
4
- data.tar.gz: 04c7fde8424f6885c1a932a7dffe0492465f0ab36fe11d37b37c012088ef614e
3
+ metadata.gz: 93a98307084f4ecda1bb218964bece248af40a57b95ad2b423dac9654154dd89
4
+ data.tar.gz: 897d5c06126dadf291ab26207cce1abb75a36a17a2ef8e2697c7c89edcd0b4a3
5
5
  SHA512:
6
- metadata.gz: 1152bf26fe94bdc03d45aac4d678d4c494912eac9a5977d81bccbdef58c412a27f48ce11c930876502e47350592552f0aa856c383b2d17d5a773d0a4d4a38a21
7
- data.tar.gz: 6e8dfc0f49d28ee6b540f066548f80c77befbe74b9d9fecef0988e46c30e825718f313741468a0a91aaf7863cf8367a22cffbf431c598d9271d087aed40437c2
6
+ metadata.gz: dcbd8568e6634cf0a59d0048db5d43145ed61dfbca93c85dd3ab2d9bc8166c96bcaafa7a707a50a8ecff1eb3451385968e38535ef60ae65e9bad56aa1cd1eb81
7
+ data.tar.gz: d54d442bda06642a18a10c51a64b3488f7bb963a3f4b3d81e43ccf1e8a75d8e02f1465279ff189c8722d352530d5ee45ea89efb4529d6815a5dc8b9d8f7c2a88
data/.gitignore CHANGED
@@ -6,6 +6,7 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+ .DS_Store
9
10
 
10
11
  # rspec failure tracking
11
12
  .rspec_status
data/CHANGELOG.md CHANGED
@@ -0,0 +1,4 @@
1
+ # v0.2.0
2
+ - The parse method is now on the top-level namespace (`Wifimap.parse`).
3
+ - Added `Wifimap.parse_file(filename)`.
4
+ - Added support for [sniff-probes](https://github.com/brannondorsey/sniff-probes).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- wifimap (0.1.0)
4
+ wifimap (0.2.0)
5
5
  louis
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -22,12 +22,14 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- Require the parser and pass the content of a dump file to the `parse` method:
25
+ Require wifimap and pass the content of a dump file to the `parse` method:
26
26
  ```rb
27
- require 'wifimap/parser'
27
+ require 'wifimap'
28
28
 
29
29
  dump = File.read('airodump.csv')
30
- parsed = Wifimap::Parser.parse(dump)
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
@@ -1,22 +1,29 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'wifimap/parser/airodump'
3
+ require 'wifimap/mac'
4
4
 
5
5
  module Wifimap
6
6
  module Parser
7
- # Parse the content of a dump file and return a hash of APs, stations and probes.
8
- def self.parse(file_content)
9
- case dump_format(file_content)
10
- when :airodump
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
- # Check the file content and identify the dump format.
18
- def self.dump_format(file_content)
19
- airodump_header = 'BSSID, First time seen, Last time seen, channel, Speed, Privacy, Cipher, Authentication, Power'
20
- :airodump if file_content.include?(airodump_header) end
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
@@ -1,3 +1,3 @@
1
1
  module Wifimap
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
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.1.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-17 00:00:00.000000000 Z
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