panopticon 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +43 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/panopticond +52 -0
- data/extra/install.sh +14 -0
- data/extra/panopticond +62 -0
- data/extra/public/css/bootstrap-theme.css +384 -0
- data/extra/public/css/bootstrap-theme.min.css +1 -0
- data/extra/public/css/bootstrap.css +6805 -0
- data/extra/public/css/bootstrap.min.css +9 -0
- data/extra/public/css/panopticon.css +15 -0
- data/extra/public/fonts/glyphicons-halflings-regular.eot +0 -0
- data/extra/public/fonts/glyphicons-halflings-regular.svg +228 -0
- data/extra/public/fonts/glyphicons-halflings-regular.ttf +0 -0
- data/extra/public/fonts/glyphicons-halflings-regular.woff +0 -0
- data/extra/public/index.html +135 -0
- data/extra/public/js/bootstrap.js +1999 -0
- data/extra/public/js/bootstrap.min.js +6 -0
- data/extra/public/js/canvasjs.min.js +555 -0
- data/extra/public/js/jquery-3.1.0.min.js +4 -0
- data/extra/public/js/script.js +512 -0
- data/lib/panopticon.rb +10 -0
- data/lib/panopticon/api.rb +59 -0
- data/lib/panopticon/command/panopticond.rb +47 -0
- data/lib/panopticon/log.rb +36 -0
- data/lib/panopticon/version.rb +3 -0
- data/lib/panopticon/wlan_capture.rb +135 -0
- data/lib/panopticon/wlan_control.rb +275 -0
- data/lib/panopticon/wlan_utilization.rb +128 -0
- data/panopticon.gemspec +30 -0
- metadata +151 -0
@@ -0,0 +1,128 @@
|
|
1
|
+
module Panopticon
|
2
|
+
class WlanUtilization
|
3
|
+
FREQ2CHAN = {
|
4
|
+
0 => 0, # why radiotap.channel.freq can be 0?
|
5
|
+
# 2.4GHz
|
6
|
+
2412 => 1,
|
7
|
+
2417 => 2,
|
8
|
+
2422 => 3,
|
9
|
+
2427 => 4,
|
10
|
+
2432 => 5,
|
11
|
+
2437 => 6,
|
12
|
+
2442 => 7,
|
13
|
+
2447 => 8,
|
14
|
+
2452 => 9,
|
15
|
+
2457 => 10,
|
16
|
+
2462 => 11,
|
17
|
+
2467 => 12,
|
18
|
+
2472 => 13,
|
19
|
+
2484 => 14,
|
20
|
+
|
21
|
+
# japan client only
|
22
|
+
5170 => 34,
|
23
|
+
5190 => 38,
|
24
|
+
5210 => 42,
|
25
|
+
5230 => 46,
|
26
|
+
|
27
|
+
# W52
|
28
|
+
5180 => 36,
|
29
|
+
5200 => 40,
|
30
|
+
5220 => 44,
|
31
|
+
5240 => 48,
|
32
|
+
|
33
|
+
# W53
|
34
|
+
5260 => 52,
|
35
|
+
5280 => 56,
|
36
|
+
5300 => 60,
|
37
|
+
5320 => 64,
|
38
|
+
|
39
|
+
# W56
|
40
|
+
5500 => 100,
|
41
|
+
5520 => 104,
|
42
|
+
5540 => 108,
|
43
|
+
5560 => 112,
|
44
|
+
5580 => 116,
|
45
|
+
5600 => 120,
|
46
|
+
5620 => 124,
|
47
|
+
5640 => 128,
|
48
|
+
5660 => 132,
|
49
|
+
5680 => 136,
|
50
|
+
5700 => 140,
|
51
|
+
5745 => 149,
|
52
|
+
5765 => 153,
|
53
|
+
5785 => 157,
|
54
|
+
5805 => 161,
|
55
|
+
5825 => 165,
|
56
|
+
|
57
|
+
|
58
|
+
# 802.11j
|
59
|
+
4920 => 184,
|
60
|
+
4940 => 188,
|
61
|
+
4960 => 192,
|
62
|
+
4980 => 194,
|
63
|
+
}
|
64
|
+
|
65
|
+
REG_FREQ=/^\s*frequency:\s+(\d+) /
|
66
|
+
REG_ACTIVE=/^\s*channel active time:\s+(\d+) (|m)s$/
|
67
|
+
REG_BUSY=/^\s*channel busy time:\s+(\d+) (|m)s$/
|
68
|
+
|
69
|
+
def initialize ifname
|
70
|
+
@ifname = ifname
|
71
|
+
@ifname_exists = interface_exists?(ifname)
|
72
|
+
unless @ifname_exists
|
73
|
+
STDERR.puts("WARNING: interface #{ifname} does not exists, run in dummy mode")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def current_data
|
78
|
+
unless @ifname.match(/^wlan\d+$/)
|
79
|
+
$log.debug("non-wlan skips utilization acquirement")
|
80
|
+
return [0, 0, 0, 0]
|
81
|
+
end
|
82
|
+
|
83
|
+
unless @ifname_exists
|
84
|
+
$log.warn("interface not available for utilizationm aquirement")
|
85
|
+
return [0, 0, 0, 0]
|
86
|
+
end
|
87
|
+
|
88
|
+
str = get_survey_dump()
|
89
|
+
active = 0
|
90
|
+
busy = 0
|
91
|
+
channel = 0
|
92
|
+
|
93
|
+
str.split("\n").map{|line| line.strip}.each do |line|
|
94
|
+
case line
|
95
|
+
when REG_FREQ
|
96
|
+
channel = FREQ2CHAN[$1.to_i]
|
97
|
+
when REG_ACTIVE
|
98
|
+
active = $1.to_i
|
99
|
+
active *= 1000 if $2 != "m"
|
100
|
+
when REG_BUSY
|
101
|
+
busy = $1.to_i
|
102
|
+
busy *= 1000 if $2 != "m"
|
103
|
+
end
|
104
|
+
end
|
105
|
+
return [0, 0, 0, 0] if active == 0
|
106
|
+
|
107
|
+
return [channel, active, busy, fto2f(busy.to_f * 100 / active.to_f) ]
|
108
|
+
end
|
109
|
+
|
110
|
+
private
|
111
|
+
def get_survey_dump
|
112
|
+
return `iw #{@ifname} survey dump | grep -A 4 "in use"`
|
113
|
+
end
|
114
|
+
|
115
|
+
def fto2f f
|
116
|
+
return (f * 100).to_i.to_f / 100
|
117
|
+
end
|
118
|
+
|
119
|
+
def interface_exists?(ifname)
|
120
|
+
return system("ifconfig #{ifname} 1>/dev/null 2>&1")
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
if __FILE__ == $0
|
126
|
+
wlanutils = Panopticon::WlanUtilization.new("wlan0")
|
127
|
+
p wlanutils.current_data
|
128
|
+
end
|
data/panopticon.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'panopticon/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "panopticon"
|
8
|
+
spec.version = Panopticon::VERSION
|
9
|
+
spec.authors = ["enukane"]
|
10
|
+
spec.email = ["enukane@glenda9.org"]
|
11
|
+
|
12
|
+
spec.summary = %q{Wi-Fi packet capture software set on Raspberry Pi }
|
13
|
+
spec.homepage = "https://github.com/enukane/panopticon"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
17
|
+
# delete this section to allow pushing this gem to any host.
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
27
|
+
|
28
|
+
spec.add_dependency 'pidfile', "~> 0.3.0"
|
29
|
+
spec.add_dependency 'sinatra', "~> 1.4.7"
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: panopticon
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- enukane
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-12-02 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: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
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: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pidfile
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.3.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 0.3.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: sinatra
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.4.7
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.4.7
|
83
|
+
description:
|
84
|
+
email:
|
85
|
+
- enukane@glenda9.org
|
86
|
+
executables:
|
87
|
+
- panopticond
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
93
|
+
- ".travis.yml"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.md
|
97
|
+
- Rakefile
|
98
|
+
- bin/console
|
99
|
+
- bin/setup
|
100
|
+
- exe/panopticond
|
101
|
+
- extra/install.sh
|
102
|
+
- extra/panopticond
|
103
|
+
- extra/public/css/bootstrap-theme.css
|
104
|
+
- extra/public/css/bootstrap-theme.min.css
|
105
|
+
- extra/public/css/bootstrap.css
|
106
|
+
- extra/public/css/bootstrap.min.css
|
107
|
+
- extra/public/css/panopticon.css
|
108
|
+
- extra/public/fonts/glyphicons-halflings-regular.eot
|
109
|
+
- extra/public/fonts/glyphicons-halflings-regular.svg
|
110
|
+
- extra/public/fonts/glyphicons-halflings-regular.ttf
|
111
|
+
- extra/public/fonts/glyphicons-halflings-regular.woff
|
112
|
+
- extra/public/index.html
|
113
|
+
- extra/public/js/bootstrap.js
|
114
|
+
- extra/public/js/bootstrap.min.js
|
115
|
+
- extra/public/js/canvasjs.min.js
|
116
|
+
- extra/public/js/jquery-3.1.0.min.js
|
117
|
+
- extra/public/js/script.js
|
118
|
+
- lib/panopticon.rb
|
119
|
+
- lib/panopticon/api.rb
|
120
|
+
- lib/panopticon/command/panopticond.rb
|
121
|
+
- lib/panopticon/log.rb
|
122
|
+
- lib/panopticon/version.rb
|
123
|
+
- lib/panopticon/wlan_capture.rb
|
124
|
+
- lib/panopticon/wlan_control.rb
|
125
|
+
- lib/panopticon/wlan_utilization.rb
|
126
|
+
- panopticon.gemspec
|
127
|
+
homepage: https://github.com/enukane/panopticon
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.4.5
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Wi-Fi packet capture software set on Raspberry Pi
|
151
|
+
test_files: []
|