waps 1.0.0 → 1.0.1
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/lib/waps.rb +2 -2
- data/lib/waps_linux.rb +75 -0
- data/lib/waps_mac.rb +49 -0
- metadata +5 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9af8da7a34cfb334e5a34f6b209c70f7773487ea
|
|
4
|
+
data.tar.gz: b14cb5063a9393bb742795ef666ce7cf7e81c36c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: df00b9cca89cf15f656af52a3457c98cba3857db9e0fdc7932b96a95d8c2d15c60c7290cdaaf69533dfa59005324926946c76c3da08e76105c86d79244585755
|
|
7
|
+
data.tar.gz: 8153c0d1811b7aff7b9736e1bd66de73bbc6c701ac0749562238f6e1912128c06fb4a12c3c1b09cf2bb0cbe2f87bfce63331f84f02ac0dac38f3daa914209988
|
data/lib/waps.rb
CHANGED
data/lib/waps_linux.rb
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
|
|
3
|
+
class Waps_linux
|
|
4
|
+
|
|
5
|
+
def initialize(interface_name)
|
|
6
|
+
@interface_name = interface_name
|
|
7
|
+
@output = []
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def scan
|
|
11
|
+
raw_input = run_command
|
|
12
|
+
@output = (raw_input.keys.include? :error) ? raw_input : parse(raw_input[:output])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def parse(raw_input)
|
|
16
|
+
cells = raw_input.split("Cell")[1..-1]
|
|
17
|
+
|
|
18
|
+
cells.map { |cell| parse_cell(cell)}
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def run_command
|
|
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]
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
data/lib/waps_mac.rb
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
require 'open3'
|
|
2
|
+
|
|
3
|
+
class Waps_mac
|
|
4
|
+
|
|
5
|
+
def initialize
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def scan
|
|
9
|
+
raw_input = run_command
|
|
10
|
+
@output = (raw_input.keys.include? :error) ? raw_input : parse(raw_input[:output])
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def parse(raw_input)
|
|
14
|
+
cells = raw_input.split("\n")[1..-1]
|
|
15
|
+
|
|
16
|
+
cells.map { |cell| parse_cell(cell)}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def run_command
|
|
20
|
+
output,error,status = Open3.capture3("/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -s")
|
|
21
|
+
return output == "" ? {error: error} : {output: output}
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def parse_cell(cell)
|
|
26
|
+
raw_data = cell.split(" ")
|
|
27
|
+
result = {
|
|
28
|
+
address: raw_data[1],
|
|
29
|
+
channel: raw_data[3],
|
|
30
|
+
signal_level: raw_data[2],
|
|
31
|
+
encryption_key: pencryption_key(raw_data[6]),
|
|
32
|
+
ssid: raw_data[0]
|
|
33
|
+
}
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
#Parse Values from the raw data. All methods below
|
|
38
|
+
|
|
39
|
+
def pencryption_key(data)
|
|
40
|
+
data == "NONE" ? "off" : "On"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
end
|
|
49
|
+
|
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: 1.0.
|
|
4
|
+
version: 1.0.1
|
|
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-12-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -26,7 +26,7 @@ dependencies:
|
|
|
26
26
|
version: '3.7'
|
|
27
27
|
description: Gem scans Wireless Access Points and return ruby hash
|
|
28
28
|
email:
|
|
29
|
-
-
|
|
29
|
+
- info@defensestation.ca
|
|
30
30
|
executables: []
|
|
31
31
|
extensions: []
|
|
32
32
|
extra_rdoc_files:
|
|
@@ -34,6 +34,8 @@ extra_rdoc_files:
|
|
|
34
34
|
files:
|
|
35
35
|
- README.md
|
|
36
36
|
- lib/waps.rb
|
|
37
|
+
- lib/waps_linux.rb
|
|
38
|
+
- lib/waps_mac.rb
|
|
37
39
|
homepage: https://github.com/gurjant31/waps
|
|
38
40
|
licenses:
|
|
39
41
|
- MIT
|