spior 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +6 -0
- data/README.md +7 -0
- data/lib/spior/clear.rb +2 -1
- data/lib/spior/copy.rb +7 -3
- data/lib/spior/helpers.rb +19 -0
- data/lib/spior/install.rb +9 -4
- data/lib/spior/iptables.rb +3 -12
- data/lib/spior/persist.rb +11 -3
- data/lib/spior/reload.rb +2 -1
- data/lib/spior/tor.rb +4 -2
- data/spior.gemspec +1 -2
- data.tar.gz.sig +1 -2
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 967b9db246b956fa477b0fcc62212846720f4722799997aff7fa95eb45ff9775
|
4
|
+
data.tar.gz: 3469b8d3829a26bc46b576da7c15cc7bf420516e498d37fde8a39453cd2cff75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0e6279b2427995067d4bf4dded5ed0b7a412724009cab08ef5c779558b8e4e80f54b82b0520ca4e949ce7d445ec2fb86a7f954e426358a2162fcd333bd689e
|
7
|
+
data.tar.gz: 2154da0c94cce48f71ff39fac3832ba3145388176b480a392f810ffeb5fa40e7dc66592bdf7aaf695bd2d26d6f27a4f03700a2dcaf375cfd5069afa5eeba8a3c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## 0.1.2, release 2020-05-13
|
2
|
+
* Add instructions for the persistent mode
|
3
|
+
* Add dependency iptables-persistant for distro based on debian
|
4
|
+
* Avoid to use sudo if no need
|
5
|
+
* Add lib/spior/helpers
|
6
|
+
|
1
7
|
## 0.1.1, release 2020-05-09
|
2
8
|
* The tor class now check for dependencies and service start|restart
|
3
9
|
* Call Spior without arguments now display the interactive menu
|
data/README.md
CHANGED
@@ -10,6 +10,13 @@ And install the gem
|
|
10
10
|
|
11
11
|
$ gem install spior -P MediumSecurity
|
12
12
|
|
13
|
+
To be able to use the `persist mode` (with systemd for now), the gem should be installed system-wide:
|
14
|
+
+ For gentoo, a package is available on my repo [ninjatools](https://github.com/szorfein/ninjatools/tree/master/dev-ruby/spior).
|
15
|
+
+ Arch seem to use [Quarry](https://wiki.archlinux.org/index.php/Ruby#Quarry).
|
16
|
+
+ On distro based on debian, gem are installed system-wide.
|
17
|
+
|
18
|
+
If you can, i recommend that you create a package for your distribution.
|
19
|
+
|
13
20
|
## Usage
|
14
21
|
|
15
22
|
$ spior -h
|
data/lib/spior/clear.rb
CHANGED
@@ -2,6 +2,7 @@ require 'tty-which'
|
|
2
2
|
require 'nomansland'
|
3
3
|
require_relative 'copy'
|
4
4
|
require_relative 'msg'
|
5
|
+
require_relative 'helpers'
|
5
6
|
|
6
7
|
module Spior
|
7
8
|
module Clear
|
@@ -30,7 +31,7 @@ module Spior
|
|
30
31
|
|
31
32
|
def ipt_restore(path)
|
32
33
|
puts "Restoring rules #{path}..."
|
33
|
-
|
34
|
+
Helpers::Exec.new("iptables-restore").run("#{path}")
|
34
35
|
end
|
35
36
|
|
36
37
|
def rez_configs
|
data/lib/spior/copy.rb
CHANGED
@@ -2,11 +2,13 @@ require 'nomansland'
|
|
2
2
|
require 'date'
|
3
3
|
require 'digest'
|
4
4
|
require_relative 'msg'
|
5
|
+
require_relative 'helpers'
|
5
6
|
|
6
7
|
module Spior
|
7
8
|
class Copy
|
8
9
|
|
9
10
|
def self.config_files
|
11
|
+
@cp = Helpers::Exec.new("cp -a")
|
10
12
|
@conf_dir = File.expand_path('../..' + '/conf', __dir__)
|
11
13
|
copy_torrc
|
12
14
|
copy_file(@conf_dir + "/resolv.conf", "/etc/resolv.conf")
|
@@ -14,6 +16,7 @@ module Spior
|
|
14
16
|
end
|
15
17
|
|
16
18
|
def self.restore_files
|
19
|
+
@cp = Helpers::Exec.new("cp -a")
|
17
20
|
backup_exist("/etc/tor/torrc")
|
18
21
|
backup_exist("/etc/resolv.conf")
|
19
22
|
end
|
@@ -30,6 +33,7 @@ module Spior
|
|
30
33
|
end
|
31
34
|
|
32
35
|
def self.systemd_services
|
36
|
+
@cp = Helpers::Exec.new("cp -a")
|
33
37
|
search_systemd_dir
|
34
38
|
case Nomansland::installer?
|
35
39
|
when :gentoo
|
@@ -79,12 +83,12 @@ module Spior
|
|
79
83
|
def self.backup_file(target)
|
80
84
|
d = DateTime.now
|
81
85
|
backup = target + ".backup-" + d.strftime('%b-%d_%I-%M')
|
82
|
-
|
86
|
+
@cp.run("#{target} #{backup}")
|
83
87
|
puts "Renamed file #{backup}"
|
84
88
|
end
|
85
89
|
|
86
90
|
def self.add_file(target)
|
87
|
-
|
91
|
+
@cp.run("#{@config_file} #{target}")
|
88
92
|
Msg.p "File #{@config_file} has been successfully copied at #{target}"
|
89
93
|
end
|
90
94
|
|
@@ -92,7 +96,7 @@ module Spior
|
|
92
96
|
backup=`ls #{target}.backup-* | head -n 1`.chomp
|
93
97
|
if File.exist? backup
|
94
98
|
if ! check_hash(target, backup)
|
95
|
-
|
99
|
+
@cp.run("#{backup} #{target}")
|
96
100
|
Msg.p "Restored #{backup}"
|
97
101
|
end
|
98
102
|
else
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Helpers
|
2
|
+
class Exec
|
3
|
+
def initialize(name)
|
4
|
+
@search_uid=`id -u`.chomp
|
5
|
+
@search_uid ||= 1000 unless $?.success?
|
6
|
+
@name = name
|
7
|
+
end
|
8
|
+
|
9
|
+
def run(args)
|
10
|
+
if @search_uid == '0' then
|
11
|
+
#puts "found root - uid #{@search_uid}"
|
12
|
+
system(@name + " " + args)
|
13
|
+
else
|
14
|
+
#puts "no root - call sudo - uid #{@search_uid}"
|
15
|
+
system("sudo " + @name + " " + args)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/spior/install.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'nomansland'
|
2
2
|
require 'tty-which'
|
3
3
|
require_relative 'msg'
|
4
|
+
require_relative 'helpers'
|
4
5
|
|
5
6
|
module Spior
|
6
7
|
class Install
|
@@ -24,13 +25,17 @@ module Spior
|
|
24
25
|
if not TTY::Which.exist?('iptables') or not TTY::Which.exist?('tor')
|
25
26
|
case Nomansland::installer?
|
26
27
|
when :emerge
|
27
|
-
|
28
|
+
emerge = Helpers::Exec.new("emerge -av --changed-use")
|
29
|
+
emerge.run("tor iptables")
|
28
30
|
when :pacman
|
29
|
-
|
31
|
+
pacman = Helpers::Exec.new("pacman -S --needed")
|
32
|
+
pacman.run("tor iptables")
|
30
33
|
when :yum
|
31
|
-
|
34
|
+
yum = Helpers::Exec.new("yum install")
|
35
|
+
yum.run("tor iptables")
|
32
36
|
else
|
33
|
-
|
37
|
+
apt_get = Helpers::Exec.new("apt-get install")
|
38
|
+
apt_get.run("tor iptables iptables-persistent")
|
34
39
|
end
|
35
40
|
end
|
36
41
|
end
|
data/lib/spior/iptables.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'interfacez'
|
2
2
|
require_relative 'tor'
|
3
3
|
require_relative 'msg'
|
4
|
+
require_relative 'helpers'
|
4
5
|
|
5
6
|
module Spior
|
6
7
|
class Iptables
|
7
8
|
|
8
9
|
def self.tor(interface = false)
|
9
10
|
initialize(interface)
|
10
|
-
select_cmd
|
11
11
|
flush_rules
|
12
12
|
bogus_tcp_flags
|
13
13
|
bad_packets
|
@@ -22,7 +22,7 @@ module Spior
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.flush_rules
|
25
|
-
|
25
|
+
@i = Helpers::Exec.new("iptables")
|
26
26
|
ipt "-F"
|
27
27
|
ipt "-X"
|
28
28
|
ipt "-t nat -F"
|
@@ -46,17 +46,8 @@ module Spior
|
|
46
46
|
Spior::Copy::config_files
|
47
47
|
end
|
48
48
|
|
49
|
-
def self.select_cmd
|
50
|
-
id=`id -u`
|
51
|
-
if id == 0 then
|
52
|
-
@i = "iptables"
|
53
|
-
else
|
54
|
-
@i = "sudo iptables"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
49
|
def self.ipt(line)
|
59
|
-
|
50
|
+
@i.run("#{line}")
|
60
51
|
#puts "added - #{@i} #{line}"
|
61
52
|
end
|
62
53
|
|
data/lib/spior/persist.rb
CHANGED
@@ -2,6 +2,7 @@ require 'nomansland'
|
|
2
2
|
require 'tty-which'
|
3
3
|
require_relative 'copy'
|
4
4
|
require_relative 'msg'
|
5
|
+
require_relative 'helpers'
|
5
6
|
|
6
7
|
module Spior
|
7
8
|
module Persist
|
@@ -17,10 +18,15 @@ module Spior
|
|
17
18
|
|
18
19
|
def search_for_systemd
|
19
20
|
return if !TTY::Which.exist?('systemctl')
|
21
|
+
@systemctl = Helpers::Exec.new("systemctl")
|
22
|
+
@iptables_save = Helpers::Exec.new("iptables-save")
|
20
23
|
Spior::Copy::systemd_services
|
21
24
|
@services.each do |service|
|
22
25
|
Msg.p "Search for service #{service}..."
|
23
|
-
|
26
|
+
`systemctl is-enabled #{service}`
|
27
|
+
if not $?.success? then
|
28
|
+
@systemctl.run("enable #{service}")
|
29
|
+
end
|
24
30
|
end
|
25
31
|
iptables_systemd
|
26
32
|
end
|
@@ -28,9 +34,11 @@ module Spior
|
|
28
34
|
def iptables_systemd
|
29
35
|
case Nomansland::installer?
|
30
36
|
when :pacman
|
31
|
-
|
37
|
+
@iptables_save.run("-f /etc/iptables/iptables.rules")
|
32
38
|
when :emerge
|
33
|
-
|
39
|
+
@systemctl.run("start iptables-store")
|
40
|
+
when :apt_get
|
41
|
+
@iptables_save.run("> /etc/iptables/rules.v4")
|
34
42
|
else
|
35
43
|
Msg.report "Fail for save iptables-rule, your system is not yet supported"
|
36
44
|
end
|
data/lib/spior/reload.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'tty-which'
|
2
2
|
require_relative 'msg'
|
3
|
+
require_relative 'helpers'
|
3
4
|
|
4
5
|
module Spior
|
5
6
|
module Reload
|
6
7
|
def self.tor
|
7
8
|
if TTY::Which.exist?('systemctl')
|
8
|
-
|
9
|
+
Helpers::Exec.new("systemctl").run("restart tor")
|
9
10
|
Msg.p "ip changed"
|
10
11
|
end
|
11
12
|
end
|
data/lib/spior/tor.rb
CHANGED
@@ -4,12 +4,14 @@ require 'tty-which'
|
|
4
4
|
require_relative 'msg'
|
5
5
|
require_relative 'install'
|
6
6
|
require_relative 'copy'
|
7
|
+
require_relative 'helpers'
|
7
8
|
|
8
9
|
module Spior
|
9
10
|
class Tor
|
10
11
|
attr_accessor :dns, :uid, :trans_port, :virt_addr
|
11
12
|
|
12
13
|
def initialize
|
14
|
+
@systemctl = Helpers::Exec.new("systemctl")
|
13
15
|
check_deps
|
14
16
|
@dns = search_dns
|
15
17
|
@uid = search_uid
|
@@ -53,10 +55,10 @@ module Spior
|
|
53
55
|
state = `systemctl is-active tor`.chomp
|
54
56
|
if state == 'active'
|
55
57
|
#puts "Restart tor"
|
56
|
-
|
58
|
+
@systemctl.run('restart tor')
|
57
59
|
else
|
58
60
|
#puts "Start tor"
|
59
|
-
|
61
|
+
@systemctl.run('start tor')
|
60
62
|
end
|
61
63
|
else
|
62
64
|
Msg.for_no_systemd
|
data/spior.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "spior"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.2"
|
4
4
|
s.summary = "A tool to make TOR your default gateway and randomize your hardware"
|
5
5
|
s.description = <<-EOF
|
6
6
|
A tool to make TOR your default gateway and randomize your hardware.
|
@@ -30,7 +30,6 @@ Gem::Specification.new do |s|
|
|
30
30
|
s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
|
31
31
|
|
32
32
|
s.requirements << 'tor'
|
33
|
-
s.requirements << 'sudo'
|
34
33
|
s.requirements << 'iptables'
|
35
34
|
|
36
35
|
s.required_ruby_version = '>=2.4'
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
����gJ�x{����?��O�d ��3[�G9�qojz�,�?ky{Gиo_ۈ_�efY�9���$��/C�9�y�Ŭ#�+�K�9
|
1
|
+
<�c*��2C'�E�>�@@sO�
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spior
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- szorfein
|
@@ -35,7 +35,7 @@ cert_chain:
|
|
35
35
|
J/zT/q2Ac7BWpSLbv6p9lChBiEnD9j24x463LR5QQjDNS5SsjzRQfFuprsa9Nqf2
|
36
36
|
Tw==
|
37
37
|
-----END CERTIFICATE-----
|
38
|
-
date: 2020-05-
|
38
|
+
date: 2020-05-13 00:00:00.000000000 Z
|
39
39
|
dependencies:
|
40
40
|
- !ruby/object:Gem::Dependency
|
41
41
|
name: rainbow
|
@@ -117,6 +117,7 @@ files:
|
|
117
117
|
- conf/torrc/torrc_default
|
118
118
|
- lib/spior/clear.rb
|
119
119
|
- lib/spior/copy.rb
|
120
|
+
- lib/spior/helpers.rb
|
120
121
|
- lib/spior/install.rb
|
121
122
|
- lib/spior/iptables.rb
|
122
123
|
- lib/spior/mac.rb
|
@@ -155,7 +156,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
156
|
version: '0'
|
156
157
|
requirements:
|
157
158
|
- tor
|
158
|
-
- sudo
|
159
159
|
- iptables
|
160
160
|
rubygems_version: 3.1.2
|
161
161
|
signing_key:
|
metadata.gz.sig
CHANGED
Binary file
|