waps 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +13 -5
- data/lib/waps.rb +18 -65
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: '04840c4eccccc86103afed5c6371b0ca066b64b8'
|
4
|
+
data.tar.gz: e801c70aca29adc216ebe7a196c0818304a4a829
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f04b14c31ec5b5d2c0b3f59bd263596ae41d78374aa319dc82d51d9ac4cab8a005dd8123735b89e0a9581c185812f36d781f075b7160dbc014525abfd679b2c
|
7
|
+
data.tar.gz: 36626b1ecfb0963f2c2566773694542a759a019ab678b38ad0ac4e5c6608fe5ab48a33cc137a0a4e3a1fb21118e13504fb8a8eb65c9808f8e22799983b9edb61
|
data/README.md
CHANGED
@@ -1,25 +1,33 @@
|
|
1
|
-
# Wireless Access Point Scanner
|
1
|
+
# Wireless Access Point Scanner <a href="https://badge.fury.io/rb/waps"><img src="https://badge.fury.io/rb/waps.svg" alt="Gem Version" height="18"></a>
|
2
2
|
|
3
3
|
WAPS uses iwlist to scan for wireless access points and convert the output into ruby hash format. Following is the usage of the gem.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
7
|
```
|
8
|
-
gem install
|
8
|
+
gem install waps
|
9
9
|
```
|
10
10
|
Require
|
11
11
|
|
12
12
|
```
|
13
|
-
require '
|
13
|
+
require 'waps'
|
14
14
|
```
|
15
15
|
|
16
16
|
## Usage
|
17
17
|
|
18
|
-
* First Require the gem: ``` require '
|
19
|
-
* Creating new instance require interface name. Leave it empty if not sure. ``` new_scan =
|
18
|
+
* First Require the gem: ``` require 'waps' ```
|
19
|
+
* Creating new instance require interface name. Leave it empty if not sure. ``` new_scan = Waps.new('Interface_name')```
|
20
20
|
* Start Scan. ```results = new_scan.scan```
|
21
21
|
* Get specific field. ``` mac_address = new_scan.get('address') ```
|
22
22
|
|
23
|
+
```
|
24
|
+
require 'waps'
|
25
|
+
|
26
|
+
new_scan = Waps.new('')
|
27
|
+
new_scan.scan
|
28
|
+
mac_addresses = new_scan.get('address')
|
29
|
+
```
|
30
|
+
|
23
31
|
## Response Field
|
24
32
|
|
25
33
|
* Address
|
data/lib/waps.rb
CHANGED
@@ -1,72 +1,26 @@
|
|
1
|
-
require '
|
1
|
+
require './lib/waps_linux.rb'
|
2
|
+
require './lib/waps_mac.rb'
|
3
|
+
|
2
4
|
|
3
5
|
class Waps
|
4
6
|
|
5
|
-
def initialize(interface_name)
|
7
|
+
def initialize(interface_name = '')
|
6
8
|
@interface_name = interface_name
|
7
9
|
@output = []
|
8
10
|
end
|
9
11
|
|
10
12
|
def scan
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
output,error,status = Open3.capture3("sudo iwlist #{@interface_name} scan")
|
23
|
-
return output == "" ? {error: error} : {output: output}
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
def parse_cell(cell)
|
28
|
-
raw_data = cell.split("\n")
|
29
|
-
result = {
|
30
|
-
address: paddress(raw_data[0]),
|
31
|
-
channel: pchannel(raw_data[1]),
|
32
|
-
frequency: pfrequency(raw_data[2]),
|
33
|
-
quality: pquality(raw_data[3]),
|
34
|
-
signal_level: psignal_level(raw_data[3]),
|
35
|
-
encryption_key: pencryption_key(raw_data[4]),
|
36
|
-
ssid: pssid(raw_data[5])
|
37
|
-
}
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
#Parse Values from the raw data. All methods below
|
42
|
-
|
43
|
-
|
44
|
-
def paddress(data)
|
45
|
-
data.split("Address:")[-1].delete(" ")
|
46
|
-
end
|
47
|
-
|
48
|
-
def pchannel(data)
|
49
|
-
data.split(":")[-1]
|
50
|
-
end
|
51
|
-
|
52
|
-
def pfrequency(data)
|
53
|
-
data.split(":")[-1].split(" ")[0]
|
54
|
-
end
|
55
|
-
|
56
|
-
def pquality(data)
|
57
|
-
data.split(" ")[0].split("=")[-1]
|
58
|
-
end
|
59
|
-
|
60
|
-
def psignal_level(data)
|
61
|
-
data.split(" ")[2].split("=")[-1] + " dBm"
|
62
|
-
end
|
63
|
-
|
64
|
-
def pencryption_key(data)
|
65
|
-
data.split(":")[-1]
|
66
|
-
end
|
67
|
-
|
68
|
-
def pssid(data)
|
69
|
-
data.split('"').count == 1 ? "" : data.split('"')[-1]
|
13
|
+
if RUBY_PLATFORM =~ /win32/
|
14
|
+
return {error: "Not support for windows. Coming Soon."}
|
15
|
+
elsif RUBY_PLATFORM =~ /linux/
|
16
|
+
new_scan = Waps_linux.new(@interface_name)
|
17
|
+
return @output = new_scan.scan
|
18
|
+
elsif RUBY_PLATFORM =~ /darwin/
|
19
|
+
new_scan = Waps_mac.new
|
20
|
+
return @output = new_scan.scan
|
21
|
+
else
|
22
|
+
return {error: "No support for this OS."}
|
23
|
+
end
|
70
24
|
end
|
71
25
|
|
72
26
|
|
@@ -75,12 +29,11 @@ class Waps
|
|
75
29
|
|
76
30
|
|
77
31
|
def get(find)
|
78
|
-
|
79
|
-
|
80
|
-
result = @output.map { |cell| cell[find.to_sym] }
|
32
|
+
if (@output[0].keys.include? find.to_sym) && !@output.empty?
|
33
|
+
return @output.map { |cell| cell[find.to_sym] }
|
81
34
|
end
|
82
|
-
result
|
83
35
|
end
|
84
36
|
|
37
|
+
|
85
38
|
end
|
86
39
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gurjant Singh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '3.7'
|
27
|
-
description: Gem
|
27
|
+
description: Gem scans Wireless Access Points and return ruby hash
|
28
28
|
email:
|
29
29
|
- waps@defensestation.ca
|
30
30
|
executables: []
|
@@ -54,7 +54,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
54
54
|
version: '0'
|
55
55
|
requirements: []
|
56
56
|
rubyforge_project:
|
57
|
-
rubygems_version: 2.
|
57
|
+
rubygems_version: 2.5.2.3
|
58
58
|
signing_key:
|
59
59
|
specification_version: 4
|
60
60
|
summary: Gem to scan wirless access point
|