wifimap 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bf34d96b423042eeb6528fc637a1d3b622d1d14881b495882b9be47212d31b38
4
+ data.tar.gz: 04c7fde8424f6885c1a932a7dffe0492465f0ab36fe11d37b37c012088ef614e
5
+ SHA512:
6
+ metadata.gz: 1152bf26fe94bdc03d45aac4d678d4c494912eac9a5977d81bccbdef58c412a27f48ce11c930876502e47350592552f0aa856c383b2d17d5a773d0a4d4a38a21
7
+ data.tar.gz: 6e8dfc0f49d28ee6b540f066548f80c77befbe74b9d9fecef0988e46c30e825718f313741468a0a91aaf7863cf8367a22cffbf431c598d9271d087aed40437c2
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.6.5
6
+ before_install: gem install bundler -v 2.1.4
data/CHANGELOG.md ADDED
File without changes
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at gianpiero.addis@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in wifimap.gemspec
4
+ gemspec
5
+
6
+ gem "rake", "~> 12.3"
7
+ gem "rspec", "~> 3.0"
8
+ gem 'coveralls', require: false
data/Gemfile.lock ADDED
@@ -0,0 +1,56 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ wifimap (0.1.0)
5
+ louis
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ coveralls (0.8.23)
11
+ json (>= 1.8, < 3)
12
+ simplecov (~> 0.16.1)
13
+ term-ansicolor (~> 1.3)
14
+ thor (>= 0.19.4, < 2.0)
15
+ tins (~> 1.6)
16
+ diff-lcs (1.3)
17
+ docile (1.3.2)
18
+ json (2.3.0)
19
+ louis (2.2.4)
20
+ rake (12.3.3)
21
+ rspec (3.9.0)
22
+ rspec-core (~> 3.9.0)
23
+ rspec-expectations (~> 3.9.0)
24
+ rspec-mocks (~> 3.9.0)
25
+ rspec-core (3.9.0)
26
+ rspec-support (~> 3.9.0)
27
+ rspec-expectations (3.9.0)
28
+ diff-lcs (>= 1.2.0, < 2.0)
29
+ rspec-support (~> 3.9.0)
30
+ rspec-mocks (3.9.0)
31
+ diff-lcs (>= 1.2.0, < 2.0)
32
+ rspec-support (~> 3.9.0)
33
+ rspec-support (3.9.0)
34
+ simplecov (0.16.1)
35
+ docile (~> 1.1)
36
+ json (>= 1.8, < 3)
37
+ simplecov-html (~> 0.10.0)
38
+ simplecov-html (0.10.2)
39
+ sync (0.5.0)
40
+ term-ansicolor (1.7.1)
41
+ tins (~> 1.0)
42
+ thor (1.0.1)
43
+ tins (1.24.1)
44
+ sync
45
+
46
+ PLATFORMS
47
+ ruby
48
+
49
+ DEPENDENCIES
50
+ coveralls
51
+ rake (~> 12.3)
52
+ rspec (~> 3.0)
53
+ wifimap!
54
+
55
+ BUNDLED WITH
56
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Gianpiero Addis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # Wifimap
2
+ [![Build Status](https://travis-ci.com/gpaddis/wifimap.svg?branch=master)](https://travis-ci.com/gpaddis/wifimap)
3
+ [![Coverage Status](https://coveralls.io/repos/github/gpaddis/wifimap/badge.svg?branch=master)](https://coveralls.io/github/gpaddis/wifimap?branch=master)
4
+
5
+ Parse wifi dump files and get a structured collection of access points and stations, including probes and associations (see [supported dump formats](#supported-dump-formats)). You can then import the formatted data into your application, e.g. to build a database or a map of wireless networks and clients.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'wifimap'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install wifimap
22
+
23
+ ## Usage
24
+
25
+ Require the parser and pass the content of a dump file to the `parse` method:
26
+ ```rb
27
+ require 'wifimap/parser'
28
+
29
+ dump = File.read('airodump.csv')
30
+ parsed = Wifimap::Parser.parse(dump)
31
+
32
+ parsed.access_points # returns an array of AccessPoint objects
33
+ parsed.stations # returns an array of Station objects
34
+ ```
35
+
36
+ ### Attributes
37
+
38
+ An AccessPoint instance contains the following attributes:
39
+
40
+ ```rb
41
+ access_point.bssid # ex.: '04:F0:21:13:32:29'
42
+ access_point.privacy # ex.: 'WPA2'
43
+ access_point.essid # ex.: 'Home Network'
44
+ access_point.manufacturer # ex.: 'Compex Systems Pte Ltd'
45
+ ```
46
+
47
+ A Station instance contains the following attributes:
48
+
49
+ ```rb
50
+ station.mac # ex.: 'AE:91:B5:23:87:9D'
51
+ station.associations # ex.: ['04:F0:21:13:32:29']
52
+ station.probes # ex.: ['Home Network']
53
+ station.manufacturer # ex.: 'Apple, Inc.'
54
+ ```
55
+
56
+ ### Supported dump formats
57
+ - Airodump CSV ([airodump-ng](https://www.aircrack-ng.org/doku.php?id=airodump-ng))
58
+
59
+ ## Development
60
+
61
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
62
+
63
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
64
+
65
+ ## Contributing
66
+
67
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gpaddis/wifimap. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/wifimap/blob/master/CODE_OF_CONDUCT.md).
68
+
69
+
70
+ ## License
71
+
72
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
73
+
74
+ ## Code of Conduct
75
+
76
+ Everyone interacting in the Wifimap project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/wifimap/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "wifimap"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wifimap
4
+ class AccessPoint
5
+ attr_reader :bssid, :privacy, :essid
6
+
7
+ def initialize(bssid:, privacy:, essid:)
8
+ @bssid = bssid
9
+ @privacy = privacy
10
+ @essid = essid
11
+ end
12
+
13
+ # Get the device manufacturer based on the bssid.
14
+ def manufacturer
15
+ Mac.manufacturer(bssid)
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'louis'
4
+
5
+ module Wifimap
6
+ class Mac
7
+ # Return true if the mac format is correct, false otherwise.
8
+ def self.valid?(mac)
9
+ mac =~ /([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]{2})/ ? true : false
10
+ end
11
+
12
+ # Get the manufacturer for the given mac address.
13
+ def self.manufacturer(mac)
14
+ Louis.lookup(mac)['long_vendor']
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'wifimap/mac'
4
+ require 'wifimap/station'
5
+ require 'wifimap/access_point'
6
+
7
+ module Wifimap
8
+ module Parser
9
+ # Parse the content of an airodump.csv file.
10
+ class Airodump
11
+ def initialize(dump)
12
+ @dump = dump
13
+ end
14
+
15
+ # Get the list of access points from the dump.
16
+ def access_points
17
+ aps = @dump.split("\n").filter do |row|
18
+ fields = row.split(',')
19
+ channel = fields[3].to_i
20
+ Mac.valid?(fields.first) && channel.between?(1, 16)
21
+ end
22
+
23
+ aps.map do |ap|
24
+ fields = ap.split(',')
25
+ AccessPoint.new(
26
+ bssid: fields.first,
27
+ privacy: fields[5].strip,
28
+ essid: fields[13].strip
29
+ )
30
+ end
31
+ end
32
+
33
+ # Get the list of stations from the dump.
34
+ def stations
35
+ stations = @dump.split("\n").filter do |row|
36
+ fields = row.split(',')
37
+ power = fields[3].to_i
38
+ Mac.valid?(fields.first) && power.negative?
39
+ end
40
+
41
+ stations.map do |row|
42
+ fields = row.split(',')
43
+ station = Station.new(mac: fields.first)
44
+ unless fields[5].include?('(not associated)')
45
+ station.associations << fields[5].strip
46
+ end
47
+
48
+ station.probes << fields[6].strip unless fields[6].strip.empty?
49
+
50
+ station
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'wifimap/parser/airodump'
4
+
5
+ module Wifimap
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
15
+ end
16
+
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
21
+ end
22
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Wifimap
4
+ class Station
5
+ attr_reader :mac
6
+ attr_accessor :associations, :probes
7
+
8
+ def initialize(mac:)
9
+ @mac = mac
10
+ @associations = []
11
+ @probes = []
12
+ end
13
+
14
+ # Get the device manufacturer based on the mac.
15
+ def manufacturer
16
+ Mac.manufacturer(mac)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,3 @@
1
+ module Wifimap
2
+ VERSION = "0.1.0"
3
+ end
data/lib/wifimap.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'wifimap/version'
4
+
5
+ module Wifimap
6
+ class Error < StandardError; end
7
+ end
data/wifimap.gemspec ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'lib/wifimap/version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'wifimap'
7
+ spec.version = Wifimap::VERSION
8
+ spec.authors = ['Gianpiero Addis']
9
+ spec.email = ['gianpiero.addis@gmail.com']
10
+
11
+ spec.summary = 'Parse wifi sniffer dump files.'
12
+ spec.homepage = 'https://github.com/gpaddis/wifimap'
13
+ spec.license = 'MIT'
14
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
15
+
16
+ spec.metadata['homepage_uri'] = spec.homepage
17
+ spec.metadata['source_code_uri'] = 'https://github.com/gpaddis/wifimap'
18
+ spec.metadata['changelog_uri'] = 'https://github.com/gpaddis/wifimap/blob/master/CHANGELOG.md'
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
23
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
+ end
25
+ spec.bindir = 'exe'
26
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
+ spec.require_paths = ['lib']
28
+
29
+ spec.add_dependency 'louis'
30
+ end
metadata ADDED
@@ -0,0 +1,80 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wifimap
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Gianpiero Addis
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-04-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: louis
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - gianpiero.addis@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - ".gitignore"
35
+ - ".rspec"
36
+ - ".travis.yml"
37
+ - CHANGELOG.md
38
+ - CODE_OF_CONDUCT.md
39
+ - Gemfile
40
+ - Gemfile.lock
41
+ - LICENSE.txt
42
+ - README.md
43
+ - Rakefile
44
+ - bin/console
45
+ - bin/setup
46
+ - lib/wifimap.rb
47
+ - lib/wifimap/access_point.rb
48
+ - lib/wifimap/mac.rb
49
+ - lib/wifimap/parser.rb
50
+ - lib/wifimap/parser/airodump.rb
51
+ - lib/wifimap/station.rb
52
+ - lib/wifimap/version.rb
53
+ - wifimap.gemspec
54
+ homepage: https://github.com/gpaddis/wifimap
55
+ licenses:
56
+ - MIT
57
+ metadata:
58
+ homepage_uri: https://github.com/gpaddis/wifimap
59
+ source_code_uri: https://github.com/gpaddis/wifimap
60
+ changelog_uri: https://github.com/gpaddis/wifimap/blob/master/CHANGELOG.md
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 2.3.0
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubygems_version: 3.0.3
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Parse wifi sniffer dump files.
80
+ test_files: []