spior 0.0.7 → 0.0.8

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d390bbd0a1fa448b101166b42ee255f3c1f0c27f65e188892ad2727f2dfabf8
4
- data.tar.gz: dfeab1802b567bafd759636739f7c0717de2112fd098020434cd5393acdafb95
3
+ metadata.gz: e9da29ea66a46968397265faf097f4fcdb111849af6563ca1157b7a1ca0606da
4
+ data.tar.gz: 8406d29cdd50d1bbe4c0048f1c6030f8159c7156a0f63066465a6b0624a19c76
5
5
  SHA512:
6
- metadata.gz: aa1aa9c06607c26ec58db34ff6b6915ae5b0a57d9292ca563f4ef31dca2fd7e87b3c6d34139aec1dea727aca619acf2ddf23258f88d5c3994e578a5d1d880137
7
- data.tar.gz: b0a896265a665ce3c8cb35485ee05195cac56f15668d638f1fe411a6d94e42bcbb88b210afa81d2546634aa502d933deeaffff7154f7c88eb19c4845a1bf2424
6
+ metadata.gz: 47ce8c96a9aab4f5c3f156445cd114f522e4b66c5d7b614b6fb19c0697a41670dd4b6cbba905558d2ca27d509cbfd0160dceb8ad3ddb48d5d9c9ebff16ff0d99
7
+ data.tar.gz: d4c5cf050ad3cb485a9e9f09c80d634ea837b6bd0d8b5a648c29a3518126b56da0c0ddbc9a85e66f6e9c4d00219b2f95116e38300e95969cd4a8b3d1c2b53744
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.0.8, release 2020-05-06
2
+ * Always make a copy and replace original file, do not ask, the program is dependent of his config file for now.
3
+ * Correct install where Dir.chdir don't back to the previous location.
4
+ * --install also place the deceitmac.service if your system use systemd.
5
+ * Simplify lib/spior/copy check\_hash.
6
+ * The use of the option -i|--install is optionnal, deps are checked during the execution.
7
+
1
8
  ## 0.0.7, release 2020-05-05
2
9
  * Execute the option -t|--tor verify if config files are present.
3
10
  * Correct --copy, does not make more than one backup of the same file.
data/README.md CHANGED
@@ -10,13 +10,6 @@ And install the gem
10
10
 
11
11
  $ gem install spior -P MediumSecurity
12
12
 
13
- ## Dependencies
14
- You can install all the dependencies with:
15
-
16
- $ spior --install
17
-
18
- Please, post an issue if your distro linux fail.
19
-
20
13
  ## Usage
21
14
 
22
15
  $ spior -h
data/lib/spior/clear.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'tty-which'
2
2
  require 'nomansland'
3
+ require_relative 'copy'
3
4
  require_relative 'msg'
4
5
 
5
6
  module Spior
@@ -33,8 +34,7 @@ module Spior
33
34
  end
34
35
 
35
36
  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")
37
+ Spior::Copy::restore_files
38
38
  end
39
39
  end
40
40
  end
data/lib/spior/copy.rb CHANGED
@@ -12,19 +12,19 @@ module Spior
12
12
  copy_file("ipt_mod.conf", "/etc/modules-load.d/ipt_mod.conf")
13
13
  end
14
14
 
15
+ def self.restore_files
16
+ backup_exist("/etc/tor/torrc")
17
+ backup_exist("/etc/resolv.conf")
18
+ end
19
+
15
20
  private
16
21
 
17
22
  def self.copy_file(conf, target)
18
23
  @config_file = "conf/#{conf}"
19
24
  return if check_hash(@config_file, target)
20
25
  if File.exist? target then
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
26
+ if ! previous_copy target
27
+ backup_file(target)
28
28
  else
29
29
  add_file target
30
30
  end
@@ -33,19 +33,19 @@ module Spior
33
33
  end
34
34
  end
35
35
 
36
+ def self.previous_copy(target)
37
+ backup=`ls #{target}.backup-* | head -n 1`.chomp
38
+ return false if !File.exist?(backup)
39
+ check_hash(backup, target)
40
+ end
41
+
36
42
  def self.check_hash(src, target)
37
- return unless File.exist? target
38
43
  sha256conf = Digest::SHA256.file src
39
44
  sha256target = Digest::SHA256.file target
40
- if sha256conf === sha256target then
41
- Msg.p "File #{src} alrealy exist, skip"
42
- return true
43
- end
44
- return false
45
+ sha256conf === sha256target
45
46
  end
46
47
 
47
48
  def self.backup_file(target)
48
- return if check_hash(target, target + ".backup-*")
49
49
  d = DateTime.now
50
50
  backup = target + ".backup-" + d.strftime('%b-%d_%I-%M')
51
51
  system("sudo cp -a #{target} #{backup}")
@@ -59,7 +59,14 @@ module Spior
59
59
 
60
60
  def self.backup_exist(target)
61
61
  backup=`ls #{target}.backup-* | head -n 1`.chomp
62
- check_hash(target, backup)
62
+ if File.exist? backup
63
+ if ! check_hash(target, backup)
64
+ system("sudo cp -a #{backup} #{target}")
65
+ Msg.p "Restored #{backup}"
66
+ end
67
+ else
68
+ puts "No found previous backup for #{target}"
69
+ end
63
70
  end
64
71
  end
65
72
  end
data/lib/spior/install.rb CHANGED
@@ -7,6 +7,14 @@ module Spior
7
7
 
8
8
  def self.dependencies
9
9
  base_packages
10
+ mac_update
11
+ end
12
+
13
+ def self.check_base
14
+ base_packages
15
+ end
16
+
17
+ def self.check_mac
10
18
  pkg_mac
11
19
  end
12
20
 
@@ -28,6 +36,13 @@ module Spior
28
36
  end
29
37
 
30
38
  def self.pkg_mac
39
+ pkg_name="deceitmac"
40
+ if not TTY::Which.exist?(pkg_name)
41
+ build_pkg(pkg_name)
42
+ end
43
+ end
44
+
45
+ def self.mac_update
31
46
  pkg_name="deceitmac"
32
47
  if TTY::Which.exist?(pkg_name)
33
48
  print "Target #{pkg_name} exist, update? [N/y] "
@@ -43,13 +58,24 @@ module Spior
43
58
  end
44
59
 
45
60
  def self.build_pkg(name)
61
+ old_path = Dir.pwd
46
62
  system("rm -rf /tmp/#{name}*")
47
63
  system("curl -L -o /tmp/#{name}.tar.gz https://github.com/szorfein/#{name}/archive/master.tar.gz")
48
64
  Dir.chdir("/tmp")
49
65
  system("tar xvf #{name}.tar.gz")
50
66
  Dir.chdir("#{name}-master")
51
67
  system("sudo make install")
68
+ if TTY::Which.exist?('systemctl')
69
+ if Dir.exist?("/lib/systemd/system")
70
+ puts "lib/systemd"
71
+ system("sudo cp deceitmac@.service /lib/systemd/system/")
72
+ else
73
+ puts "/usr/lib/systemd"
74
+ system("sudo cp deceitmac@.service /usr/lib/systemd/system/")
75
+ end
76
+ end
52
77
  Msg.p "pkg #{name} installed"
78
+ Dir.chdir(old_path)
53
79
  rescue => e
54
80
  Msg.err e
55
81
  end
@@ -1,6 +1,5 @@
1
1
  require 'interfacez'
2
2
  require_relative 'tor'
3
- require_relative 'copy'
4
3
  require_relative 'msg'
5
4
 
6
5
  module Spior
@@ -35,7 +34,6 @@ module Spior
35
34
  private
36
35
 
37
36
  def self.initialize(interface)
38
- check_dep
39
37
  @lo = Interfacez.loopback
40
38
  @lo_addr = Interfacez.ipv4_address_of(@lo)
41
39
  @tor = Spior::Tor.new
data/lib/spior/runner.rb CHANGED
@@ -21,6 +21,7 @@ module Spior
21
21
  end
22
22
  if @options.mac then
23
23
  Msg.head
24
+ Spior::Install::check_mac
24
25
  if not @network
25
26
  @network = Spior::Network.new(@options.interface)
26
27
  end
@@ -28,6 +29,8 @@ module Spior
28
29
  end
29
30
  if @options.tor then
30
31
  Msg.head
32
+ Spior::Install::check_base
33
+ Spior::Copy::config_files
31
34
  if not @network
32
35
  @network = Spior::Network.new(@options.interface)
33
36
  end
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.7"
15
+ s.version = "0.0.8"
16
16
  s.requirements << 'tor'
17
17
  s.requirements << 'sudo'
18
18
  s.requirements << 'iptables'
data.tar.gz.sig CHANGED
Binary file
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.7
4
+ version: 0.0.8
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-05 00:00:00.000000000 Z
38
+ date: 2020-05-06 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rainbow
metadata.gz.sig CHANGED
Binary file