ruby_wifi_scanner 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +7 -0
- data/CHANGELOG.md +11 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +21 -0
- data/README.md +15 -0
- data/Rakefile +10 -0
- data/exe/rws +7 -0
- data/lib/ruby_wifi_scanner/linux_scanner.rb +20 -0
- data/lib/ruby_wifi_scanner/osx_scanner.rb +24 -0
- data/lib/ruby_wifi_scanner/scanner.rb +47 -0
- data/lib/ruby_wifi_scanner/version.rb +3 -0
- data/lib/ruby_wifi_scanner.rb +12 -0
- data/ruby_wifi_scanner.gemspec +43 -0
- data/version_bump +3 -0
- metadata +120 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 11203ff609e63334559ff5c04eed2c29a2b85caa70e4630f09a03b88772e0cad
|
4
|
+
data.tar.gz: a4320ffcacef6deeae4e6a500275d3fc3bb9e6c2a43cbe9700244cf4fe48607f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5e80e9d9a207913568e254101a0214a29de4bd5da638081b8a186f990ba049ba4a1a74a3e900e836999444a974ff5c3dda226acb1235aaf0f8ce2076eb8aacd6
|
7
|
+
data.tar.gz: 221981969a0c834a91f68d577deab8f6020d32189d2f553ecb14e4225c907d3b2b9d196493ded53e29a825b3d707ab8fca96ade4e748fa6235bf8b2a1cb4e763
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# (2019-05-27)
|
2
|
+
|
3
|
+
|
4
|
+
### Bug Fixes
|
5
|
+
|
6
|
+
* Fixed a bug where an unnamed SSID for OS X would cause an error ([7a42b41](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/7a42b41))
|
7
|
+
|
8
|
+
|
9
|
+
### Features
|
10
|
+
|
11
|
+
* First release ([6078fa3](https://github.com/D3MNetworks/ruby-wifi-scanner/commit/6078fa3))
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby_wifi_scanner (0.1.4)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
byebug (11.0.1)
|
10
|
+
minitest (5.11.3)
|
11
|
+
rake (10.5.0)
|
12
|
+
|
13
|
+
PLATFORMS
|
14
|
+
ruby
|
15
|
+
|
16
|
+
DEPENDENCIES
|
17
|
+
bundler (~> 2.0)
|
18
|
+
byebug
|
19
|
+
minitest (~> 5.0)
|
20
|
+
rake (~> 10.0)
|
21
|
+
ruby_wifi_scanner!
|
22
|
+
|
23
|
+
BUNDLED WITH
|
24
|
+
2.0.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2019 Uri Gorelik
|
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
data/Rakefile
ADDED
data/exe/rws
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
module RubyWifiScanner
|
2
|
+
class LinuxScanner < Scanner
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def parse
|
7
|
+
res = raw_scan.split "\n"
|
8
|
+
res[1..-1].map do |row|
|
9
|
+
m = row.strip.match(/(?<level>-?[\d.]{4,6})\s+(?<rssi>[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2})\s*(?<ssid>\w+)?/i)
|
10
|
+
WifiInfo.new(m[:ssid], m[:rssi], m[:level]) if m
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def raw_scan
|
15
|
+
@raw_scan ||=
|
16
|
+
%x{sudo iw dev $DEVICE scan | awk -f wlan_scan.awk | sort}
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module RubyWifiScanner
|
2
|
+
class OSXScanner < Scanner
|
3
|
+
|
4
|
+
protected
|
5
|
+
|
6
|
+
def parse
|
7
|
+
split = raw_scan.split "\n"
|
8
|
+
resp = []
|
9
|
+
split[1..-1].each do |row|
|
10
|
+
break if row == ""
|
11
|
+
m = row.strip.match(/(?<ssid>\w+)? ?(?<rssi>[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}:[a-f0-9]{2}) (?<level>-?[\d]{1,4})/i)
|
12
|
+
resp << WifiInfo.new(m[:ssid], m[:rssi], m[:level]) if m
|
13
|
+
end
|
14
|
+
resp.compact
|
15
|
+
end
|
16
|
+
|
17
|
+
def raw_scan
|
18
|
+
@raw_scan ||=
|
19
|
+
%x{/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport --scan}
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module RubyWifiScanner
|
2
|
+
class Scanner
|
3
|
+
attr_reader :networks
|
4
|
+
|
5
|
+
WifiInfo = Struct.new(:ssid, :rssi, :level)
|
6
|
+
|
7
|
+
def self.create(raw_scan=nil)
|
8
|
+
case
|
9
|
+
when osx? then OSXScanner.new(raw_scan)
|
10
|
+
when linux? then LinuxScanner.new(raw_scan)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
private_class_method
|
15
|
+
def self.osx?
|
16
|
+
RUBY_PLATFORM =~ /darwin/
|
17
|
+
end
|
18
|
+
|
19
|
+
private_class_method
|
20
|
+
def self.linux?
|
21
|
+
RUBY_PLATFORM =~ /linux/
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
def initialize(raw_scan = nil)
|
26
|
+
@raw_scan = raw_scan || self.raw_scan
|
27
|
+
@networks = parse.sort_by { |w| -w.level }
|
28
|
+
end
|
29
|
+
|
30
|
+
def print_fmt
|
31
|
+
@networks.map do |n|
|
32
|
+
"#{n.rssi}\t#{n.level}\t#{n.ssid}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
|
38
|
+
def parse
|
39
|
+
raise NotImplemented
|
40
|
+
end
|
41
|
+
|
42
|
+
def raw_scan
|
43
|
+
raise NotImplemented
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require "ruby_wifi_scanner/version"
|
2
|
+
require "ruby_wifi_scanner/scanner"
|
3
|
+
require "ruby_wifi_scanner/osx_scanner"
|
4
|
+
require "ruby_wifi_scanner/linux_scanner"
|
5
|
+
|
6
|
+
|
7
|
+
module RubyWifiScanner
|
8
|
+
class Error < StandardError; end
|
9
|
+
class NotImplemented < Error ; end
|
10
|
+
# Your code goes here...
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require "ruby_wifi_scanner/version"
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "ruby_wifi_scanner"
|
8
|
+
spec.version = RubyWifiScanner::VERSION
|
9
|
+
spec.authors = ["Uri Gorelik"]
|
10
|
+
spec.email = ["uri.gore@gmail.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Scans local wifi networks names}
|
13
|
+
spec.description = %q{Scans local wifi networks names}
|
14
|
+
spec.homepage = "https://github.com/D3MNetworks/ruby-wifi-scanner"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
18
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
19
|
+
if spec.respond_to?(:metadata)
|
20
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
21
|
+
|
22
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
23
|
+
spec.metadata["source_code_uri"] = "https://github.com/D3MNetworks/ruby-wifi-scanner"
|
24
|
+
spec.metadata["changelog_uri"] = "https://github.com/D3MNetworks/ruby-wifi-scanner/blob/master/CHANGELOG.md"
|
25
|
+
else
|
26
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
27
|
+
"public gem pushes."
|
28
|
+
end
|
29
|
+
|
30
|
+
# Specify which files should be added to the gem when it is released.
|
31
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
32
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
33
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
34
|
+
end
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
|
39
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
40
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
41
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
42
|
+
spec.add_development_dependency "byebug"
|
43
|
+
end
|
data/version_bump
ADDED
metadata
ADDED
@@ -0,0 +1,120 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_wifi_scanner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.4
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Uri Gorelik
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-05-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: byebug
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description: Scans local wifi networks names
|
70
|
+
email:
|
71
|
+
- uri.gore@gmail.com
|
72
|
+
executables:
|
73
|
+
- rws
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- CHANGELOG.md
|
80
|
+
- Gemfile
|
81
|
+
- Gemfile.lock
|
82
|
+
- LICENSE.txt
|
83
|
+
- README.md
|
84
|
+
- Rakefile
|
85
|
+
- exe/rws
|
86
|
+
- lib/ruby_wifi_scanner.rb
|
87
|
+
- lib/ruby_wifi_scanner/linux_scanner.rb
|
88
|
+
- lib/ruby_wifi_scanner/osx_scanner.rb
|
89
|
+
- lib/ruby_wifi_scanner/scanner.rb
|
90
|
+
- lib/ruby_wifi_scanner/version.rb
|
91
|
+
- ruby_wifi_scanner.gemspec
|
92
|
+
- version_bump
|
93
|
+
homepage: https://github.com/D3MNetworks/ruby-wifi-scanner
|
94
|
+
licenses:
|
95
|
+
- MIT
|
96
|
+
metadata:
|
97
|
+
allowed_push_host: https://rubygems.org
|
98
|
+
homepage_uri: https://github.com/D3MNetworks/ruby-wifi-scanner
|
99
|
+
source_code_uri: https://github.com/D3MNetworks/ruby-wifi-scanner
|
100
|
+
changelog_uri: https://github.com/D3MNetworks/ruby-wifi-scanner/blob/master/CHANGELOG.md
|
101
|
+
post_install_message:
|
102
|
+
rdoc_options: []
|
103
|
+
require_paths:
|
104
|
+
- lib
|
105
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
|
+
requirements:
|
112
|
+
- - ">="
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '0'
|
115
|
+
requirements: []
|
116
|
+
rubygems_version: 3.0.3
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: Scans local wifi networks names
|
120
|
+
test_files: []
|