spior 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90c671028fd720819222b9ef6e9b68801900077b10eb449bd97bf2780ae139df
4
- data.tar.gz: 39036dd8a1671de7861d5af14f0506802c059764953b3ba9c77a3c0b7bd27f63
3
+ metadata.gz: 8d390bbd0a1fa448b101166b42ee255f3c1f0c27f65e188892ad2727f2dfabf8
4
+ data.tar.gz: dfeab1802b567bafd759636739f7c0717de2112fd098020434cd5393acdafb95
5
5
  SHA512:
6
- metadata.gz: 9e6003b20ae3ca7267233b01f2ad00d7fac0035869121aaffed0ea8d53de6c4abfe4f665ded35e6fa14c69121514cd56e3d9310f6d5fc3fb7a938377aa1f0292
7
- data.tar.gz: 42e2674b7cb4439d120b93fb7f2b865dd3e9579be3dc62978e684f4eb33faf2ad8cc2bb9adf6c9f3c25f94b79a5d7e1e95b80cbc9347ba489753bed279d99772
6
+ metadata.gz: aa1aa9c06607c26ec58db34ff6b6915ae5b0a57d9292ca563f4ef31dca2fd7e87b3c6d34139aec1dea727aca619acf2ddf23258f88d5c3994e578a5d1d880137
7
+ data.tar.gz: b0a896265a665ce3c8cb35485ee05195cac56f15668d638f1fe411a6d94e42bcbb88b210afa81d2546634aa502d933deeaffff7154f7c88eb19c4845a1bf2424
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,14 @@
1
+ ## 0.0.7, release 2020-05-05
2
+ * Execute the option -t|--tor verify if config files are present.
3
+ * Correct --copy, does not make more than one backup of the same file.
4
+ * Correct --install, do not check for reinstall package if they exist.
5
+ * --clear restore config files
6
+ * --clear tries to restore the old rules if he finds them.
7
+ * New option -c|--clear
8
+ * Remove option --copy, it is start with --install
9
+ * Change option --card with -n|--net-card
10
+ * Add the Gem tty-which as dependencies
11
+
1
12
  ## 0.0.6, release 2020-05-04
2
13
  * README, Add examples
3
14
  * lib/spior/iptables - rename var input incoming
data/README.md CHANGED
@@ -24,12 +24,12 @@ Please, post an issue if your distro linux fail.
24
24
  ### Examples
25
25
  To change the MAC address for eth0
26
26
 
27
- $ spior -c eth0 -m
27
+ $ spior -n eth0 -m
28
28
 
29
29
  Redirect traffic through TOR
30
30
 
31
31
  $ spior -t
32
- $ spior -t -c eth0
32
+ $ spior -t -n eth0
33
33
 
34
34
  Look informations about your current ip address
35
35
 
@@ -0,0 +1,40 @@
1
+ require 'tty-which'
2
+ require 'nomansland'
3
+ require_relative 'msg'
4
+
5
+ module Spior
6
+ module Clear
7
+ extend self
8
+
9
+ def all
10
+ iptables
11
+ rez_configs
12
+ end
13
+
14
+ private
15
+
16
+ def iptables
17
+ puts "Clearing rules.."
18
+ Spior::Iptables::flush_rules
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.report "Do not known where search you previous iptables rules"
27
+ end
28
+ end
29
+
30
+ def ipt_restore(path)
31
+ puts "Restoring rules #{path}..."
32
+ system("sudo iptables-restore #{path}")
33
+ end
34
+
35
+ def rez_configs
36
+ system("sudo cp -a /etc/resolv.conf.backup-* /etc/resolv.conf")
37
+ #system("sudo cp -a /etc/tor/torrc.backup-* /etc/tor/torrc")
38
+ end
39
+ end
40
+ end
data/lib/spior/copy.rb CHANGED
@@ -16,12 +16,16 @@ module Spior
16
16
 
17
17
  def self.copy_file(conf, target)
18
18
  @config_file = "conf/#{conf}"
19
- return if check_hash(target)
19
+ return if check_hash(@config_file, target)
20
20
  if File.exist? target then
21
- print "Target #{target} exist, backup and replace? [N/y] "
22
- choice = gets.chomp
23
- if choice =~ /y|Y/ then
24
- backup_file(target)
21
+ if not backup_exist target
22
+ print "Target #{target} exist, backup and replace? [N/y] "
23
+ choice = gets.chomp
24
+ if choice =~ /y|Y/ then
25
+ backup_file(target)
26
+ add_file target
27
+ end
28
+ else
25
29
  add_file target
26
30
  end
27
31
  else
@@ -29,18 +33,19 @@ module Spior
29
33
  end
30
34
  end
31
35
 
32
- def self.check_hash(target)
36
+ def self.check_hash(src, target)
33
37
  return unless File.exist? target
34
- sha256conf = Digest::SHA256.file @config_file
38
+ sha256conf = Digest::SHA256.file src
35
39
  sha256target = Digest::SHA256.file target
36
40
  if sha256conf === sha256target then
37
- Msg.p "File #{target} alrealy exist, skip"
41
+ Msg.p "File #{src} alrealy exist, skip"
38
42
  return true
39
43
  end
40
44
  return false
41
45
  end
42
46
 
43
47
  def self.backup_file(target)
48
+ return if check_hash(target, target + ".backup-*")
44
49
  d = DateTime.now
45
50
  backup = target + ".backup-" + d.strftime('%b-%d_%I-%M')
46
51
  system("sudo cp -a #{target} #{backup}")
@@ -51,5 +56,10 @@ module Spior
51
56
  system("sudo cp -a #{@config_file} #{target}")
52
57
  Msg.p "File #{@config_file} has been successfully copied at #{target}"
53
58
  end
59
+
60
+ def self.backup_exist(target)
61
+ backup=`ls #{target}.backup-* | head -n 1`.chomp
62
+ check_hash(target, backup)
63
+ end
54
64
  end
55
65
  end
data/lib/spior/install.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'nomansland'
2
+ require 'tty-which'
2
3
  require_relative 'msg'
3
4
 
4
5
  module Spior
@@ -12,21 +13,23 @@ module Spior
12
13
  private
13
14
 
14
15
  def self.base_packages
15
- case Nomansland::installer?
16
- when :emerge
17
- system('sudo emerge -av --changed-use tor iptables')
18
- when :pacman
19
- system('sudo pacman -S --needed tor iptables')
20
- when :yum
21
- system('sudo yum install tor iptables')
22
- else
23
- system('sudo apt-get tor iptables')
16
+ if not TTY::Which.exist?('iptables') or not TTY::Which.exist?('tor')
17
+ case Nomansland::installer?
18
+ when :emerge
19
+ system('sudo emerge -av --changed-use tor iptables')
20
+ when :pacman
21
+ system('sudo pacman -S --needed tor iptables')
22
+ when :yum
23
+ system('sudo yum install tor iptables')
24
+ else
25
+ system('sudo apt-get tor iptables')
26
+ end
24
27
  end
25
28
  end
26
29
 
27
30
  def self.pkg_mac
28
31
  pkg_name="deceitmac"
29
- if File.exist?("/usr/local/bin/#{pkg_name}")
32
+ if TTY::Which.exist?(pkg_name)
30
33
  print "Target #{pkg_name} exist, update? [N/y] "
31
34
  choice = gets.chomp
32
35
  if choice =~ /y|Y/ then
@@ -1,5 +1,6 @@
1
1
  require 'interfacez'
2
2
  require_relative 'tor'
3
+ require_relative 'copy'
3
4
  require_relative 'msg'
4
5
 
5
6
  module Spior
@@ -21,9 +22,20 @@ module Spior
21
22
  drop_all
22
23
  end
23
24
 
25
+ def self.flush_rules
26
+ select_cmd
27
+ ipt "-F"
28
+ ipt "-X"
29
+ ipt "-t nat -F"
30
+ ipt "-t nat -X"
31
+ ipt "-t mangle -F"
32
+ ipt "-t mangle -X"
33
+ end
34
+
24
35
  private
25
36
 
26
37
  def self.initialize(interface)
38
+ check_dep
27
39
  @lo = Interfacez.loopback
28
40
  @lo_addr = Interfacez.ipv4_address_of(@lo)
29
41
  @tor = Spior::Tor.new
@@ -32,6 +44,10 @@ module Spior
32
44
  @incoming_addr = Interfacez.ipv4_address_of(@incoming)
33
45
  end
34
46
 
47
+ def self.check_dep
48
+ Spior::Copy::config_files
49
+ end
50
+
35
51
  def self.select_cmd
36
52
  id=`id -u`
37
53
  if id == 0 then
@@ -46,16 +62,6 @@ module Spior
46
62
  #puts "added - #{@i} #{line}"
47
63
  end
48
64
 
49
- def self.flush_rules
50
- puts "flush"
51
- ipt "-F"
52
- ipt "-X"
53
- ipt "-t nat -F"
54
- ipt "-t nat -X"
55
- ipt "-t mangle -F"
56
- ipt "-t mangle -X"
57
- end
58
-
59
65
  def self.drop_all
60
66
  ipt "-P INPUT DROP"
61
67
  ipt "-P FORWARD DROP"
data/lib/spior/msg.rb CHANGED
@@ -12,4 +12,10 @@ module Msg
12
12
  def self.err(text)
13
13
  puts Rainbow("[").red + Rainbow("-").white + Rainbow("]").red + " " + text
14
14
  end
15
+
16
+ def self.report(text)
17
+ puts ""
18
+ self.err text
19
+ puts "Please, report this issue at https://github.com/szorfein/spior/issues"
20
+ end
15
21
  end
data/lib/spior/options.rb CHANGED
@@ -1,13 +1,13 @@
1
1
  require 'optparse'
2
2
  require_relative 'status'
3
+ require_relative 'clear'
3
4
 
4
5
  module Spior
5
6
  class Options
6
- attr_reader :install , :copy, :mac , :interface , :tor
7
+ attr_reader :install , :mac , :interface , :tor
7
8
 
8
9
  def initialize(argv)
9
10
  @install = false
10
- @copy = false
11
11
  @mac = false
12
12
  @tor = false
13
13
  parse(argv)
@@ -17,16 +17,11 @@ module Spior
17
17
 
18
18
  def parse(argv)
19
19
  OptionParser.new do |opts|
20
-
21
20
  opts.on("-i", "--install", "Install dependencies") do
22
21
  @install = true
23
22
  end
24
23
 
25
- opts.on("-c", "--copy", "Copy config files") do
26
- @copy = true
27
- end
28
-
29
- opts.on("-c", "--card NAME", "The name of the target network card") do |net|
24
+ opts.on("-n", "--net-card NAME", "The name of the target network card") do |net|
30
25
  @interface = net
31
26
  end
32
27
 
@@ -38,6 +33,10 @@ module Spior
38
33
  @tor = true
39
34
  end
40
35
 
36
+ opts.on("-c", "--clear", "Clear iptables rules and restore files") do
37
+ Spior::Clear::all
38
+ end
39
+
41
40
  opts.on("-s", "--status", "Look infos about your current ip") do
42
41
  Spior::Status::info
43
42
  end
data/lib/spior/runner.rb CHANGED
@@ -17,9 +17,6 @@ module Spior
17
17
  if @options.install then
18
18
  Msg.head
19
19
  Spior::Install::dependencies
20
- end
21
- if @options.copy then
22
- Msg.head
23
20
  Spior::Copy::config_files
24
21
  end
25
22
  if @options.mac then
data/spior.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  "wiki_uri" => "https://github.com/szorfein/spior"
13
13
  }
14
14
 
15
- s.version = "0.0.6"
15
+ s.version = "0.0.7"
16
16
  s.requirements << 'tor'
17
17
  s.requirements << 'sudo'
18
18
  s.requirements << 'iptables'
@@ -33,4 +33,5 @@ Gem::Specification.new do |s|
33
33
  s.add_runtime_dependency('rainbow', '3.0.0')
34
34
  s.add_runtime_dependency('interfacez', '1.0.3')
35
35
  s.add_runtime_dependency('nomansland', '0.0.2')
36
+ s.add_runtime_dependency('tty-which', '0.4.2')
36
37
  end
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.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - szorfein
@@ -79,6 +79,20 @@ dependencies:
79
79
  - - '='
80
80
  - !ruby/object:Gem::Version
81
81
  version: 0.0.2
82
+ - !ruby/object:Gem::Dependency
83
+ name: tty-which
84
+ requirement: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - '='
87
+ - !ruby/object:Gem::Version
88
+ version: 0.4.2
89
+ type: :runtime
90
+ prerelease: false
91
+ version_requirements: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - '='
94
+ - !ruby/object:Gem::Version
95
+ version: 0.4.2
82
96
  description: " A tool to make TOR your default gateway and randomize your hardware.\n"
83
97
  email: szorfein@protonmail.com
84
98
  executables:
@@ -98,6 +112,7 @@ files:
98
112
  - conf/sshd.conf
99
113
  - conf/sshuttle.service
100
114
  - conf/torrc
115
+ - lib/spior/clear.rb
101
116
  - lib/spior/copy.rb
102
117
  - lib/spior/install.rb
103
118
  - lib/spior/iptables.rb
metadata.gz.sig CHANGED
Binary file