spior 0.1.0 → 0.1.5
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.tar.gz.sig +0 -0
- data/CHANGELOG.md +32 -0
- data/README.md +11 -8
- data/Rakefile +20 -0
- data/bin/spior +2 -3
- data/{conf → ext}/ipt_mod.conf +0 -0
- data/{conf → ext}/iptables.service +0 -0
- data/lib/spior.rb +42 -0
- data/lib/spior/clear.rb +14 -18
- data/lib/spior/copy.rb +57 -75
- data/lib/spior/helpers.rb +118 -0
- data/lib/spior/install.rb +21 -78
- data/lib/spior/iptables.rb +5 -192
- data/lib/spior/iptables/default.rb +38 -0
- data/lib/spior/iptables/root.rb +92 -0
- data/lib/spior/iptables/tor.rb +64 -0
- data/lib/spior/menu.rb +43 -0
- data/lib/spior/msg.rb +12 -5
- data/lib/spior/network.rb +0 -1
- data/lib/spior/options.rb +13 -19
- data/lib/spior/persist.rb +33 -21
- data/lib/spior/status.rb +30 -12
- data/lib/spior/tor.rb +4 -38
- data/lib/spior/tor/info.rb +113 -0
- data/lib/spior/{reload.rb → tor/restart.rb} +4 -4
- data/lib/spior/version.rb +3 -0
- data/spior.gemspec +19 -13
- metadata +21 -20
- metadata.gz.sig +0 -0
- data/conf/resolv.conf +0 -1
- data/conf/ssh.conf +0 -29
- data/conf/sshd.conf +0 -46
- data/conf/sshuttle.service +0 -11
- data/conf/torrc/torrc_archlinux +0 -18
- data/conf/torrc/torrc_default +0 -20
- data/lib/spior/mac.rb +0 -11
- data/lib/spior/runner.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52ad58e21c256642931525e2625cb10e14a74ad17ea95825940b87f6d667fdac
|
4
|
+
data.tar.gz: 143940314f5a3e3387f094cdeb6c371a0e34a2227b803f9cb0eaeebc8ebb512d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eadbf46e6b47eb820fbd88fd3d71c31183ca49a611ac0c6e0576724abc6357d6409fbf2edc9f69d38441889f262102af47f6fecadc2fe82bcbeea856d0557dc1
|
7
|
+
data.tar.gz: f774d5a4bec3474eccaf71e8495fc813cf71681fe609e7f7d1b6bf8e386d46c525bb138b4538f23cb4634706a578cbca96bac80fc85bb37c9700c99aff984ef1
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
+
## 0.1.5, release 2020-11-01
|
2
|
+
* Simplify lib/spior/copy, lib/spior/clear
|
3
|
+
* Write iptables rules for --clearnet and --tor
|
4
|
+
* Refacto code
|
5
|
+
* Enhance --status with open-uri and json
|
6
|
+
* Remove argument --net-card
|
7
|
+
|
8
|
+
## 0.1.4, release 2020-05-21
|
9
|
+
* torrc and resolv.conf are generate dynamically
|
10
|
+
* Remove conf/resolv
|
11
|
+
* Correct path of conf_dir for the install on gentoo
|
12
|
+
* Remove self from lib/copy
|
13
|
+
* Correct little error on lib/copy with undefined method `deps`
|
14
|
+
|
15
|
+
## 0.1.3, release 2020-05-14
|
16
|
+
* Rename conf dir by ext
|
17
|
+
* Clearing all codes about MAC
|
18
|
+
* Remove deceitmac
|
19
|
+
* Mac change and other randomize features will go on another gem amnesie
|
20
|
+
|
21
|
+
## 0.1.2, release 2020-05-13
|
22
|
+
* Add instructions for the persistent mode
|
23
|
+
* Add dependency iptables-persistant for distro based on debian
|
24
|
+
* Avoid to use sudo if no need
|
25
|
+
* Add lib/spior/helpers
|
26
|
+
|
27
|
+
## 0.1.1, release 2020-05-09
|
28
|
+
* The tor class now check for dependencies and service start|restart
|
29
|
+
* Call Spior without arguments now display the interactive menu
|
30
|
+
* New option -m|--menu
|
31
|
+
* Reorder the spior.gemspec
|
32
|
+
|
1
33
|
## 0.1.0, release 2020-05-08
|
2
34
|
* Will manage differents version of torrc, if your distro fail to start TOR, report an issue.
|
3
35
|
* Ensure than TOR is start before proceed.
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# spior
|
2
|
-
(Spider|Tor) A tool to make TOR your default gateway
|
2
|
+
(Spider|Tor) A tool to make TOR your default gateway.
|
3
3
|
|
4
4
|
## Install
|
5
5
|
Spior is cryptographically signed, so add my public key (if you haven’t already) as a trusted certificate.
|
@@ -15,18 +15,21 @@ And install the gem
|
|
15
15
|
$ spior -h
|
16
16
|
|
17
17
|
### Examples
|
18
|
-
|
18
|
+
Redirect traffic through TOR:
|
19
19
|
|
20
|
-
$ spior
|
20
|
+
$ spior --tor
|
21
21
|
|
22
|
-
|
22
|
+
Change your ip address by reloading the TOR circuit:
|
23
23
|
|
24
|
-
$ spior
|
25
|
-
$ spior -t -n eth0
|
24
|
+
$ spior --reload
|
26
25
|
|
27
|
-
Look informations about your current ip address
|
26
|
+
Look informations about your current ip address:
|
28
27
|
|
29
|
-
$ spior
|
28
|
+
$ spior --status
|
29
|
+
|
30
|
+
Return to clearnet navigation
|
31
|
+
|
32
|
+
$ spior --clearnet
|
30
33
|
|
31
34
|
## Left Over
|
32
35
|
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# https://github.com/seattlerb/minitest#running-your-tests-
|
2
|
+
require "rake/testtask"
|
3
|
+
require File.dirname(__FILE__) + "/lib/spior/version"
|
4
|
+
|
5
|
+
Rake::TestTask.new(:test) do |t|
|
6
|
+
t.libs << "test"
|
7
|
+
t.libs << "lib"
|
8
|
+
t.test_files = FileList["test/test_*.rb"]
|
9
|
+
end
|
10
|
+
|
11
|
+
namespace :gem do
|
12
|
+
desc "build the gem"
|
13
|
+
task :build do
|
14
|
+
Dir["spior*.gem"].each {|f| File.unlink(f) }
|
15
|
+
system("gem build spior.gemspec")
|
16
|
+
system("gem install spior-#{Spior::VERSION}.gem -P MediumSecurity")
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
task :default => :test
|
data/bin/spior
CHANGED
data/{conf → ext}/ipt_mod.conf
RENAMED
File without changes
|
File without changes
|
data/lib/spior.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative 'spior/clear'
|
2
|
+
require_relative 'spior/copy'
|
3
|
+
require_relative 'spior/install'
|
4
|
+
require_relative 'spior/iptables'
|
5
|
+
require_relative 'spior/msg'
|
6
|
+
require_relative 'spior/options'
|
7
|
+
require_relative 'spior/status'
|
8
|
+
require_relative 'spior/tor'
|
9
|
+
require_relative 'spior/persist'
|
10
|
+
require_relative 'spior/network'
|
11
|
+
require_relative 'spior/menu'
|
12
|
+
require_relative 'spior/helpers'
|
13
|
+
|
14
|
+
module Spior
|
15
|
+
class Main
|
16
|
+
def initialize(argv)
|
17
|
+
@argv = argv
|
18
|
+
run
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def run
|
24
|
+
options = Options.new(@argv)
|
25
|
+
|
26
|
+
if options.install
|
27
|
+
Msg.head
|
28
|
+
Install::check_deps
|
29
|
+
Copy.new.save
|
30
|
+
end
|
31
|
+
|
32
|
+
if options.tor
|
33
|
+
Msg.head
|
34
|
+
Iptables::Tor.new.run!
|
35
|
+
end
|
36
|
+
|
37
|
+
if options.persist
|
38
|
+
Persist.enable
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
data/lib/spior/clear.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require 'tty-which'
|
2
2
|
require 'nomansland'
|
3
|
-
require_relative 'copy'
|
4
|
-
require_relative 'msg'
|
5
3
|
|
6
4
|
module Spior
|
7
5
|
module Clear
|
@@ -9,32 +7,30 @@ module Spior
|
|
9
7
|
|
10
8
|
def all
|
11
9
|
iptables
|
12
|
-
|
10
|
+
Spior::Copy.new.restore
|
13
11
|
end
|
14
12
|
|
15
13
|
private
|
16
14
|
|
17
15
|
def iptables
|
18
16
|
puts "Clearing rules.."
|
19
|
-
Spior::Iptables::
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
ipt = Spior::Iptables::Default.new
|
18
|
+
ipt.stop!
|
19
|
+
#if File.exist?("/var/lib/iptables/rules-save")
|
20
|
+
# ipt_restore "/var/lib/iptables/rules-save"
|
21
|
+
#elsif File.exist?("/etc/iptables/rules.save")
|
22
|
+
# ipt_restore "/etc/iptables/iptables.rules"
|
23
|
+
#elsif File.exist?("/etc/iptables.rules")
|
24
|
+
# ipt_restore "/etc/iptables.rules"
|
25
|
+
#else
|
26
|
+
#Msg.p "Couldn't find any previous rules for iptables, create basic rules..."
|
27
|
+
ipt.run!
|
28
|
+
#end
|
29
29
|
end
|
30
30
|
|
31
31
|
def ipt_restore(path)
|
32
32
|
puts "Restoring rules #{path}..."
|
33
|
-
|
34
|
-
end
|
35
|
-
|
36
|
-
def rez_configs
|
37
|
-
Spior::Copy::restore_files
|
33
|
+
Helpers::Exec.new("iptables-restore").run("#{path}")
|
38
34
|
end
|
39
35
|
end
|
40
36
|
end
|
data/lib/spior/copy.rb
CHANGED
@@ -1,103 +1,85 @@
|
|
1
|
-
require 'nomansland'
|
2
|
-
require 'date'
|
3
1
|
require 'digest'
|
4
|
-
require_relative 'msg'
|
5
2
|
|
6
3
|
module Spior
|
7
4
|
class Copy
|
8
|
-
|
9
|
-
|
10
|
-
@
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.restore_files
|
17
|
-
backup_exist("/etc/tor/torrc")
|
18
|
-
backup_exist("/etc/resolv.conf")
|
5
|
+
def initialize
|
6
|
+
@cp = Helpers::Exec.new("cp -a")
|
7
|
+
@files = []
|
8
|
+
search_conf_dir
|
9
|
+
config_files
|
10
|
+
list
|
19
11
|
end
|
20
12
|
|
21
|
-
def
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
end
|
13
|
+
def save
|
14
|
+
@files.each { |f|
|
15
|
+
backup = "#{f}_backup"
|
16
|
+
if ! File.exist? backup
|
17
|
+
Msg.p "#{f} saved"
|
18
|
+
@cp.run("#{f} #{backup}")
|
19
|
+
end
|
20
|
+
}
|
30
21
|
end
|
31
22
|
|
32
|
-
def
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
23
|
+
def restore
|
24
|
+
@files.each { |f|
|
25
|
+
backup = "#{f}_backup"
|
26
|
+
if File.exist? backup
|
27
|
+
Msg.p "#{f} restored"
|
28
|
+
@cp.run("#{backup} #{f}")
|
29
|
+
end
|
30
|
+
}
|
39
31
|
end
|
40
32
|
|
41
33
|
private
|
42
34
|
|
43
|
-
def
|
44
|
-
@
|
45
|
-
return if check_hash(@config_file, target)
|
46
|
-
if File.exist? target then
|
47
|
-
if ! previous_copy target
|
48
|
-
backup_file(target)
|
49
|
-
end
|
50
|
-
add_file target
|
51
|
-
else
|
52
|
-
add_file target
|
53
|
-
end
|
35
|
+
def config_files
|
36
|
+
copy_file("#{@conf_dir}/ipt_mod.conf", "/etc/modules-load.d/ipt_mod.conf")
|
54
37
|
end
|
55
38
|
|
56
|
-
def
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
end
|
39
|
+
def list
|
40
|
+
add "/etc/resolv.conf"
|
41
|
+
add "/etc/tor/torrc"
|
42
|
+
add "/etc/systemd/resolved.conf"
|
43
|
+
add "/var/lib/iptables/rules-save" # gentoo
|
44
|
+
add "/etc/iptables/iptables.rules" # arch
|
45
|
+
add "/etc/iptables/rules.v4" # debian
|
64
46
|
end
|
65
47
|
|
66
|
-
def
|
67
|
-
|
68
|
-
return false if !File.exist?(backup)
|
69
|
-
check_hash(backup, target)
|
48
|
+
def add(file)
|
49
|
+
@files << file if File.exist? file
|
70
50
|
end
|
71
51
|
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
52
|
+
def search_conf_dir
|
53
|
+
# ebuild on gentoo copy the ext dir at lib/ext
|
54
|
+
@conf_dir = File.expand_path('../..' + '/lib/ext', __dir__)
|
55
|
+
if ! Dir.exist?(@conf_dir)
|
56
|
+
@conf_dir = File.expand_path('../..' + '/ext', __dir__)
|
57
|
+
end
|
77
58
|
end
|
78
59
|
|
79
|
-
def
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
puts "Renamed file #{backup}"
|
60
|
+
def previous_copy(target)
|
61
|
+
backup=`ls #{target}.backup-* | head -1`.chomp
|
62
|
+
return false if ! File.exist? backup
|
63
|
+
check_hash(backup, target)
|
84
64
|
end
|
85
65
|
|
86
|
-
def
|
87
|
-
|
66
|
+
def add_file(target)
|
67
|
+
@cp.run("#{@config_file} #{target}")
|
88
68
|
Msg.p "File #{@config_file} has been successfully copied at #{target}"
|
89
69
|
end
|
90
70
|
|
91
|
-
def
|
92
|
-
|
93
|
-
if File.exist?
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
71
|
+
def copy_file(conf, target)
|
72
|
+
@config_file = conf
|
73
|
+
add_file target if ! File.exist? target
|
74
|
+
return if check_hash(@config_file, target)
|
75
|
+
add_file target
|
76
|
+
end
|
77
|
+
|
78
|
+
def check_hash(src, target)
|
79
|
+
return if not File.exist?(target)
|
80
|
+
sha256conf = Digest::SHA256.file src
|
81
|
+
sha256target = Digest::SHA256.file target
|
82
|
+
sha256conf === sha256target
|
101
83
|
end
|
102
84
|
end
|
103
85
|
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'tempfile'
|
3
|
+
require 'open3'
|
4
|
+
|
5
|
+
module Helpers
|
6
|
+
class Exec
|
7
|
+
def initialize(name)
|
8
|
+
@search_uid = Process::Sys.getuid
|
9
|
+
@name = name
|
10
|
+
end
|
11
|
+
|
12
|
+
def run(args)
|
13
|
+
cmd = @search_uid == '0' ? @name : "sudo #{@name}"
|
14
|
+
Open3.popen2e("#{cmd} #{args}") do |stdin, stdout_err, wait_thr|
|
15
|
+
while line = stdout_err.gets
|
16
|
+
puts line
|
17
|
+
end
|
18
|
+
|
19
|
+
exit_status = wait_thr.value
|
20
|
+
unless exit_status.success?
|
21
|
+
raise "Error, Running #{cmd} #{args}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# Class Newfile
|
28
|
+
# Create a file and move at the dest
|
29
|
+
# === Example
|
30
|
+
# string = "nameserver 127.0.0.1"
|
31
|
+
# name = "resolv.conf"
|
32
|
+
# dest = "/etc"
|
33
|
+
# new_file = Helpers::Newfile.new(string, name, dest)
|
34
|
+
# new_file.add
|
35
|
+
class NewFile
|
36
|
+
# Method #new
|
37
|
+
# === Parameters
|
38
|
+
# * _string_ = string for the whole file
|
39
|
+
# * _name_ = name of the file (e.g: resolv.conf)
|
40
|
+
# * _dest_ = path (e.g: /etc)
|
41
|
+
def initialize(string, name, dest = "/tmp")
|
42
|
+
@string = string
|
43
|
+
@name = name
|
44
|
+
@dest = dest + "/" + @name
|
45
|
+
end
|
46
|
+
|
47
|
+
# Method #add
|
48
|
+
# Add the file at @dest
|
49
|
+
def add
|
50
|
+
@mv = Helpers::Exec.new("mv")
|
51
|
+
tmp = Tempfile.new(@name)
|
52
|
+
File.open(tmp.path, 'w') do |file|
|
53
|
+
file.puts @string
|
54
|
+
end
|
55
|
+
puts "move #{tmp.path} to #{@dest}"
|
56
|
+
@mv.run("#{tmp.path} #{@dest}")
|
57
|
+
end
|
58
|
+
|
59
|
+
def perm(user, perm)
|
60
|
+
chown = Helpers::Exec.new("chown")
|
61
|
+
chmod = Helpers::Exec.new("chmod")
|
62
|
+
chown.run("#{user}:#{user} #{@dest}")
|
63
|
+
chmod.run("#{perm} #{@dest}")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# Class NewSystemd
|
68
|
+
# Used to create a systemd service
|
69
|
+
#
|
70
|
+
# === Example:
|
71
|
+
# require Helpers
|
72
|
+
# string = <<EOF
|
73
|
+
# [Description]
|
74
|
+
#
|
75
|
+
# [Service]
|
76
|
+
# Type=simple
|
77
|
+
#
|
78
|
+
# [Installation]
|
79
|
+
# WantedBy =
|
80
|
+
# EOF
|
81
|
+
# new_systemd = Helpers::NewSystemd.new(string, "tor.service")
|
82
|
+
# new_systemd.add
|
83
|
+
class NewSystemd < NewFile
|
84
|
+
# Method #new
|
85
|
+
# === Parameters:
|
86
|
+
# * _string_ = the string of for whole content file
|
87
|
+
# * _name_ = the name of the service (e.g: tor.service)
|
88
|
+
def initialize(string, name)
|
89
|
+
super
|
90
|
+
@systemd_dir = search_systemd_dir
|
91
|
+
@dest = @systemd_dir + "/" + @name
|
92
|
+
end
|
93
|
+
|
94
|
+
# Method #add
|
95
|
+
# Create a temporary file and move
|
96
|
+
# the service @name to the systemd directory
|
97
|
+
def add
|
98
|
+
@systemctl = Helpers::Exec.new("systemctl")
|
99
|
+
super
|
100
|
+
@systemctl.run("daemon-reload")
|
101
|
+
end
|
102
|
+
|
103
|
+
private
|
104
|
+
# Method search_systemd_dir
|
105
|
+
# Search the current directory for systemd services
|
106
|
+
# + Gentoo can install at /lib/systemd/system or /usr/lib/systemd/system
|
107
|
+
def search_systemd_dir
|
108
|
+
if Dir.exist? "/lib/systemd/system"
|
109
|
+
"/lib/systemd/system"
|
110
|
+
elsif Dir.exist? "/usr/lib/systemd/system"
|
111
|
+
"/usr/lib/systemd/system"
|
112
|
+
else
|
113
|
+
raise "No directory systemd found"
|
114
|
+
exit
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|