zlown 0.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.
@@ -0,0 +1,32 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ require 'gli'
8
+ require 'pathname'
9
+ require 'pp'
10
+
11
+ require_relative 'shared'
12
+ require_relative '../version'
13
+
14
+ module Zlown::CLI
15
+ include GLI::App
16
+ extend self
17
+
18
+ def self.launch(args)
19
+ exit run ARGV
20
+ end
21
+
22
+ program_desc 'Rogue Access Point'
23
+
24
+ cmds = File.absolute_path(File.join(File.dirname(__FILE__), 'cmd'))
25
+ Dir.glob(cmds + '/**/*_cmd.rb').each do |file|
26
+ require file
27
+ end
28
+
29
+ end
30
+
31
+ Zlown::CLI.launch(ARGV)
32
+
@@ -0,0 +1,8 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ require_relative 'app'
8
+
@@ -0,0 +1,12 @@
1
+ require_relative '../shared'
2
+
3
+ require_relative '../../core/core'
4
+
5
+ module Zlown::CLI
6
+ desc 'Init Daemon'
7
+ command 'init' do |c|
8
+ c.action do |global_options, options, args|
9
+ Zlown::Core.init(args, options)
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,13 @@
1
+ require_relative '../shared'
2
+
3
+ require_relative '../../daemon/daemon'
4
+
5
+ module Zlown::CLI
6
+ desc 'Run Daemon'
7
+ command 'run' do |c|
8
+ c.action do |global_options, options, args|
9
+ daemon = Zlown::Daemon.new
10
+ daemon.run(args, options)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,25 @@
1
+ require_relative '../shared'
2
+
3
+ require_relative '../../script/script'
4
+
5
+ module Zlown::CLI
6
+ desc 'Manage scripts'
7
+ command 'script' do |c|
8
+ c.desc 'Manage httpry'
9
+ c.command 'httpry' do |cmd|
10
+ cmd.desc 'Start httpry'
11
+ cmd.command 'start' do |script_cmd|
12
+ script_cmd.action do |global_options, options, args|
13
+ Zlown::Script.httpry_start(args, options)
14
+ end
15
+ end
16
+
17
+ cmd.desc 'Stop httpry'
18
+ cmd.command 'stop' do |script_cmd|
19
+ script_cmd.action do |global_options, options, args|
20
+ Zlown::Script.httpry_stop(args, options)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,50 @@
1
+ require_relative '../shared'
2
+
3
+ require_relative '../../systemctl/systemctl'
4
+
5
+ module Zlown::CLI
6
+ desc 'Manage systemctl'
7
+ command 'systemctl' do |c|
8
+ c.desc 'Enable systemctl service'
9
+ c.command 'enable' do |cmd|
10
+ cmd.action do |global_options, options, args|
11
+ Zlown::Systemctl.enable(args, options)
12
+ end
13
+ end
14
+
15
+ c.desc 'Disable systemctl service'
16
+ c.command 'disable' do |cmd|
17
+ cmd.action do |global_options, options, args|
18
+ Zlown::Systemctl.disable(args, options)
19
+ end
20
+ end
21
+
22
+ c.desc 'Start systemctl service'
23
+ c.command 'start' do |cmd|
24
+ cmd.action do |global_options, options, args|
25
+ Zlown::Systemctl.start(args, options)
26
+ end
27
+ end
28
+
29
+ c.desc 'Stop systemctl service'
30
+ c.command 'stop' do |cmd|
31
+ cmd.action do |global_options, options, args|
32
+ Zlown::Systemctl.stop(args, options)
33
+ end
34
+ end
35
+
36
+ c.desc 'Status of systemctl service'
37
+ c.command 'status' do |cmd|
38
+ cmd.action do |global_options, options, args|
39
+ Zlown::Systemctl.status(args, options)
40
+ end
41
+ end
42
+
43
+ c.desc 'Log of systemctl service'
44
+ c.command 'log' do |cmd|
45
+ cmd.action do |global_options, options, args|
46
+ Zlown::Systemctl.log(args, options)
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2010-2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ require_relative '../../version'
8
+ require_relative '../shared'
9
+
10
+ module Zlown::CLI
11
+ desc 'Print version info'
12
+ skips_pre
13
+ command :version do |c|
14
+ c.action do |_global_options, _options, _args|
15
+ puts Zlown::VERSION
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,23 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ require 'gli'
8
+ require 'pathname'
9
+
10
+ require_relative '../version'
11
+
12
+ module Zlown::CLI
13
+ # include
14
+ extend GLI::App
15
+
16
+ desc 'Verbose mode'
17
+ arg_name 'verbose'
18
+ switch [:v, :verbose]
19
+
20
+ pre do |global_options,command,options,args|
21
+ true
22
+ end
23
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ require 'fileutils'
8
+
9
+ module Zlown
10
+ class Core
11
+ APP_DIR = File.expand_path('~/.zlown')
12
+ APP_BINARY = File.expand_path('../../../../bin/zlown', __FILE__)
13
+
14
+ DATA_DIR = File.join(APP_DIR, 'data')
15
+ RUN_DIR = File.join(APP_DIR, 'run')
16
+
17
+ SERVICE_TEMPLATE = File.expand_path('../../../../etc/systemd/system/zlown.service', __FILE__)
18
+ SERVICE_FILE = File.expand_path("#{APP_DIR}/zlown.service")
19
+
20
+ RUN_CMD = "#{APP_BINARY} run"
21
+
22
+ def self.init(args = [], opts = {})
23
+ unless File.directory?(APP_DIR)
24
+ puts "Creating directory #{APP_DIR}"
25
+ FileUtils.mkdir_p(APP_DIR)
26
+ end
27
+
28
+ unless File.directory?(DATA_DIR)
29
+ puts "Creating directory #{DATA_DIR}"
30
+ FileUtils.mkdir_p(DATA_DIR)
31
+ end
32
+
33
+ unless File.directory?(RUN_DIR)
34
+ puts "Creating directory #{RUN_DIR}"
35
+ FileUtils.mkdir_p(RUN_DIR)
36
+ end
37
+
38
+ template = File.read(SERVICE_TEMPLATE)
39
+ content = template.gsub('#{RUN_CMD}', RUN_CMD)
40
+
41
+ # To write changes to the file, use:
42
+ File.open(SERVICE_FILE, 'w') do |file|
43
+ puts "Writting file #{SERVICE_FILE}"
44
+ file.puts content
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ module Zlown
8
+ class Daemon
9
+ def run(args = [], opts = {})
10
+ puts 'Running Zlown loop'
11
+ STDOUT.flush
12
+
13
+ while true
14
+ sleep 1
15
+ end
16
+ end
17
+ end
18
+ end
19
+
@@ -0,0 +1,24 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ module Zlown
8
+ class Script
9
+ HTTPRY_PID_FILE = '/root/.zlown/run/httpry.pid'
10
+
11
+ def self.httpry_start(args = [], opts = {})
12
+ cmd = "httpry -d -P #{HTTPRY_PID_FILE} -i wlan1 -o /root/.zlown/data/httpry.log -b /root/.zlown/data/httpry.bin"
13
+ puts cmd
14
+ system cmd
15
+ end
16
+
17
+ def self.httpry_stop(args = [], opts = {})
18
+ pid = File.open(HTTPRY_PID_FILE).read.to_i
19
+ cmd = "kill #{pid}"
20
+ puts cmd
21
+ system cmd
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,48 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ module Zlown
8
+ class Systemctl
9
+ SERVICE_FILE = File.expand_path('~/.zlown/zlown.service')
10
+ SERVICE_NAME = 'zlown'
11
+
12
+ def self.enable(args = [], opts = {})
13
+ puts 'Enabling systemctl service'
14
+ cmd = "systemctl enable #{SERVICE_FILE}"
15
+ puts cmd
16
+ system cmd
17
+ end
18
+
19
+ def self.disable(args = [], opts = {})
20
+ puts 'Disabling systemctl service'
21
+ cmd = "systemctl disable #{SERVICE_NAME}"
22
+ system cmd
23
+ end
24
+
25
+ def self.start(args = [], opts = {})
26
+ puts 'Starting systemctl service'
27
+ cmd = "systemctl start #{SERVICE_NAME}"
28
+ system cmd
29
+ end
30
+
31
+ def self.stop(args = [], opts = {})
32
+ puts 'Stopping systemctl service'
33
+ cmd = "systemctl stop #{SERVICE_NAME}"
34
+ system cmd
35
+ end
36
+
37
+ def self.status(args = [], opts = {})
38
+ cmd = "systemctl status #{SERVICE_NAME}"
39
+ system cmd
40
+ end
41
+
42
+ def self.log(args = [], opts = {})
43
+ cmd = "journalctl -u #{SERVICE_NAME}"
44
+ system cmd
45
+ end
46
+ end
47
+ end
48
+
@@ -0,0 +1,10 @@
1
+ # encoding: UTF-8
2
+ #
3
+ # Copyright (c) 2016 Tomas Korcak <korczis@gmail.com>. All rights reserved.
4
+ # This source code is licensed under the MIT-style license found in the
5
+ # LICENSE file in the root directory of this source tree.
6
+
7
+ module Zlown
8
+ VERSION = '0.0.1'.freeze
9
+ end
10
+
@@ -0,0 +1,12 @@
1
+ #! /usr/bin/env bash
2
+
3
+ IF_WIFI=wlan1
4
+ IF_LTE=eth1
5
+
6
+ iptables -t nat -F
7
+ iptables -F
8
+ iptables -t nat -A POSTROUTING -o ${IF_LTE} -j MASQUERADE
9
+ iptables -A FORWARD -i ${IF_WIFI} -o ${IF_LTE} -j ACCEPT
10
+
11
+ # echo '1' > /proc/sys/net/ipv4/ip_forward
12
+
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env bash
2
+
3
+ httpry -d -i wlan1 -o /root/data/httpry.log -b /root/data/httpry.bin
4
+
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env bash
2
+
3
+ ngrep -q -d wlan1 -W byline port 80 > /root/data/ngrep.log
4
+
@@ -0,0 +1,7 @@
1
+ #! /usr/bin/env bash
2
+
3
+ IFACE=wlan1
4
+
5
+ iw reg set BO
6
+ iwconfig $IFACE txpower 30
7
+
data/zlown.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_relative 'lib/zlown/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'zlown'
8
+ spec.version = Zlown::VERSION
9
+ spec.authors = ['Tomas Korcak']
10
+ spec.email = ['korczis@gmail.com']
11
+ spec.summary = 'Evil Access Point'
12
+ spec.description = 'Rogue Evil Access Point'
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+ spec.executables = ['zlown']
16
+
17
+ spec.files = `git ls-files -z`.split("\x0")
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ['lib']
21
+
22
+ spec.add_development_dependency 'bundler', '~> 1.7'
23
+ spec.add_development_dependency 'rake', '~> 10.0'
24
+ spec.add_development_dependency 'rspec'
25
+ spec.add_development_dependency 'rubocop'
26
+ spec.add_development_dependency 'simplecov', '~> 0.11'
27
+
28
+ spec.add_dependency 'gli'
29
+ end
30
+
metadata ADDED
@@ -0,0 +1,157 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: zlown
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Tomas Korcak
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-14 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.7'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.7'
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: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
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
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.11'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.11'
83
+ - !ruby/object:Gem::Dependency
84
+ name: gli
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Rogue Evil Access Point
98
+ email:
99
+ - korczis@gmail.com
100
+ executables:
101
+ - zlown
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - ".gitignore"
106
+ - Gemfile
107
+ - Gemfile.lock
108
+ - LICENSE
109
+ - README.md
110
+ - bin/zlown
111
+ - etc/dnsmasq.conf
112
+ - etc/hostapd/hostapd.conf
113
+ - etc/rc.local
114
+ - etc/systemd/system/zlown.service
115
+ - lib/zlown/cli/app.rb
116
+ - lib/zlown/cli/cli.rb
117
+ - lib/zlown/cli/cmd/init_cmd.rb
118
+ - lib/zlown/cli/cmd/run_cmd.rb
119
+ - lib/zlown/cli/cmd/script_cmd.rb
120
+ - lib/zlown/cli/cmd/systemctl_cmd.rb
121
+ - lib/zlown/cli/cmd/version_cmd.rb
122
+ - lib/zlown/cli/shared.rb
123
+ - lib/zlown/core/core.rb
124
+ - lib/zlown/daemon/daemon.rb
125
+ - lib/zlown/script/script.rb
126
+ - lib/zlown/systemctl/systemctl.rb
127
+ - lib/zlown/version.rb
128
+ - scripts/enable-rogue.sh
129
+ - scripts/sniff-httpry.sh
130
+ - scripts/sniff-ngrep.sh
131
+ - scripts/wifi-power.sh
132
+ - zlown.gemspec
133
+ homepage: ''
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.2.2
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Evil Access Point
157
+ test_files: []