amnesie 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 24c5ed35c6b6c48f88f800ccc0fb6476a5cb6ab7b3ab258c781728b9e685cdc3
4
+ data.tar.gz: a773adb326beda6e5e2bfb88b4c7b30b5cfe539ca950bef89d07d05192f5fc75
5
+ SHA512:
6
+ metadata.gz: 779e92ef3926faebf111ca666ebad3e6d42626515740f6c4493a361733f9e13ae7f1d2598a1e2cd47fdc74fe5b7c8aaafef91268cedfede273d88de5dc4e88e0
7
+ data.tar.gz: b4390629f5b670825a46a671a82e5a0c22aa0fc7e492dcca5cd8af7defdec367e15b8e2e3981c02df3694136c7194ec9a137dd09372210f99bc1293f102fcb24
checksums.yaml.gz.sig ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,56 @@
1
+ *.gem
2
+ *.rbc
3
+ /.config
4
+ /coverage/
5
+ /InstalledFiles
6
+ /pkg/
7
+ /spec/reports/
8
+ /spec/examples.txt
9
+ /test/tmp/
10
+ /test/version_tmp/
11
+ /tmp/
12
+
13
+ # Used by dotenv library to load environment variables.
14
+ # .env
15
+
16
+ # Ignore Byebug command history file.
17
+ .byebug_history
18
+
19
+ ## Specific to RubyMotion:
20
+ .dat*
21
+ .repl_history
22
+ build/
23
+ *.bridgesupport
24
+ build-iPhoneOS/
25
+ build-iPhoneSimulator/
26
+
27
+ ## Specific to RubyMotion (use of CocoaPods):
28
+ #
29
+ # We recommend against adding the Pods directory to your .gitignore. However
30
+ # you should judge for yourself, the pros and cons are mentioned at:
31
+ # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
32
+ #
33
+ # vendor/Pods/
34
+
35
+ ## Documentation cache and generated files:
36
+ /.yardoc/
37
+ /_yardoc/
38
+ /doc/
39
+ /rdoc/
40
+
41
+ ## Environment normalization:
42
+ /.bundle/
43
+ /vendor/bundle
44
+ /lib/bundler/man/
45
+
46
+ # for a library or gem, you might want to ignore these files since the code is
47
+ # intended to run in multiple environments; otherwise, check them in:
48
+ # Gemfile.lock
49
+ # .ruby-version
50
+ # .ruby-gemset
51
+
52
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
53
+ .rvmrc
54
+
55
+ # Used by RuboCop. Remote config files pulled in from inherit_from directive.
56
+ # .rubocop-https?--*
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ ## 0.0.1, release 2020-05-13
2
+ * Can randomize a mac address
3
+ * Restart services (tor|dhcpcd)
4
+ * Kill dhcpcd
5
+ * Add -h|--help
6
+ * Base project
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2020 szorfein
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # amnesie
2
+ A tool to make your computer amnesic.
3
+
4
+ Inpiration come from a post found on [Qubes-OS](https://www.qubes-os.org/doc/anonymizing-your-mac-address/) and the [Whonix](https://www.whonix.org/) project.
5
+ + Anonymizing your MAC Address
6
+ + Randomize all Ethernet and Wifi connections
7
+ + Randomize your hostname
8
+ + [Book Clock Randomization](https://www.whonix.org/wiki/Boot_Clock_Randomization)
data/amnesie.gemspec ADDED
@@ -0,0 +1,35 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = "amnesie"
3
+ s.version = "0.0.1"
4
+ s.summary = "A tool to make your computer amnesic"
5
+ s.description = <<-EOF
6
+ A tool to make your computer amnesic"
7
+ EOF
8
+ s.metadata = {
9
+ "changelog_uri" => "https://github.com/szorfein/amnesie/blob/master/CHANGELOG.md",
10
+ "bug_tracker_uri" => "https://github.com/szorfein/amnesie/issues",
11
+ "wiki_uri" => "https://github.com/szorfein/amnesie"
12
+ }
13
+ s.author = ['szorfein']
14
+
15
+ s.licenses = ['MIT']
16
+ s.email = 'szorfein@protonmail.com'
17
+ s.homepage = 'https://github.com/szorfein/amnesie'
18
+
19
+ s.files = `git ls-files`.split(" ")
20
+ s.files.reject! { |fn| fn.include? "certs" }
21
+ s.files.reject! { |fn| fn.include? "Makefile" }
22
+ s.executables = [ 'amnesie' ]
23
+
24
+ s.extra_rdoc_files = Dir["README.md", "CHANGELOG.md", "LICENSE"]
25
+
26
+ s.test_files = Dir["test/test_*.rb"]
27
+ s.cert_chain = ['certs/szorfein.pem']
28
+ s.signing_key = File.expand_path("~/.ssh/gem-private_key.pem") if $0 =~ /gem\z/
29
+
30
+ s.required_ruby_version = '>=2.4'
31
+ s.add_runtime_dependency('rainbow', '3.0.0')
32
+ s.add_runtime_dependency('interfacez', '1.0.3')
33
+ s.add_runtime_dependency('nomansland', '0.0.2')
34
+ s.add_runtime_dependency('tty-which', '0.4.2')
35
+ end
data/bin/amnesie ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'amnesie/runner'
4
+
5
+ runner = Amnesie::Runner.new(ARGV)
6
+ runner.run
@@ -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 "sudo #{@name} #{args}"
15
+ system("sudo " + @name + " " + args)
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,47 @@
1
+ require_relative 'helpers'
2
+
3
+ module Amnesie
4
+ class MAC
5
+ def initialize(card)
6
+ @card = card
7
+ @ip = Helpers::Exec.new("ip")
8
+ end
9
+
10
+ # TODO yep...
11
+ def rand
12
+ first=`printf ""; dd bs=1 count=1 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 "%02X"'`
13
+ last=`printf ""; dd bs=1 count=5 if=/dev/urandom 2>/dev/null | hexdump -v -e '/1 ":%02X"'`
14
+ mac="#{first}#{last}"
15
+ lastfive=`echo #{mac} | cut -d: -f 2-6`.chomp
16
+ firstbyte=`echo #{mac} | cut -d: -f 1`.chomp
17
+ firstbyte=`printf '%02X' $(( 0x#{firstbyte} & 254 | 2))`
18
+ @mac="#{firstbyte}:#{lastfive}"
19
+ end
20
+
21
+ def to_s
22
+ rand
23
+ @card + " " + @mac
24
+ end
25
+
26
+ def search_curr_mac
27
+ @curr = `ip addr show dev #{@card} | grep -i ether | awk '{print $2}'`
28
+ end
29
+
30
+ def save_origin
31
+ search_curr_mac
32
+ txt="/tmp/mac_#{@card}"
33
+ if not File.exist?(txt)
34
+ file = File.open(txt, 'a+')
35
+ file.puts(@curr)
36
+ file.close
37
+ puts "Origin saved"
38
+ end
39
+ end
40
+
41
+ def apply
42
+ @ip.run("link set dev #{@card} down")
43
+ @ip.run("link set dev #{@card} address #{@mac}")
44
+ @ip.run("link set dev #{@card} up")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,45 @@
1
+ require 'interfacez'
2
+
3
+ module Amnesie
4
+ class Network
5
+ attr_accessor :card
6
+
7
+ def initialize(name = false)
8
+ @name = name
9
+ @check = false
10
+ end
11
+
12
+ def card
13
+ verify_card
14
+ if @check == false then
15
+ ask_for_card
16
+ end
17
+ @name
18
+ end
19
+
20
+ private
21
+
22
+ def verify_card
23
+ return if @check or not @name
24
+ Interfacez.all do |interface|
25
+ if interface == @name then
26
+ @check = true
27
+ end
28
+ end
29
+ if not @check then
30
+ puts "Your interface #{@name} is no found"
31
+ end
32
+ end
33
+
34
+ def ask_for_card
35
+ until @check == true
36
+ Interfacez.all do |interface|
37
+ print interface + " "
38
+ end
39
+ printf "\nWhat is the name of the card to be used? "
40
+ @name = gets.chomp
41
+ verify_card
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,37 @@
1
+ require 'optparse'
2
+
3
+ module Amnesie
4
+ class Options
5
+ attr_reader :mac, :netcard
6
+
7
+ def initialize(argv)
8
+ parse(argv)
9
+ end
10
+
11
+ def parse(argv)
12
+ OptionParser.new do |opts|
13
+
14
+ opts.on("-m", "--mac", "What is my MAC address?") do
15
+ @mac = true
16
+ end
17
+
18
+ opts.on("-n", "--net-card NAME", "The name of the card to use") do |net|
19
+ @netcard = net
20
+ end
21
+
22
+ opts.on("-h", "--help", "Show this message") do
23
+ puts opts
24
+ exit
25
+ end
26
+
27
+ begin
28
+ argv = ["-h"] if argv.empty?
29
+ opts.parse!(argv)
30
+ rescue OptionParser::ParseError => e
31
+ STDERR.puts e.message, "\n", opts
32
+ exit(-1)
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,23 @@
1
+ require_relative 'helpers'
2
+
3
+ module Amnesie
4
+ class Process
5
+ def initialize
6
+ @procs = [ "dhcpcd", "tor" ]
7
+ @systemctl = Helpers::Exec.new("systemctl")
8
+ @pkill = Helpers::Exec.new("pkill")
9
+ end
10
+
11
+ def kill
12
+ @pkill.run("dhcpcd")
13
+ puts "Killed dhcpcd"
14
+ end
15
+
16
+ def restart
17
+ @procs.each do |p|
18
+ @systemctl.run("restart #{p}")
19
+ puts "Restarted #{p}"
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,31 @@
1
+ require_relative 'options'
2
+ require_relative 'mac'
3
+ require_relative 'process'
4
+ require_relative 'network'
5
+
6
+ module Amnesie
7
+ class Runner
8
+
9
+ def initialize(argv)
10
+ @options = Options.new(argv)
11
+ @network = false
12
+ end
13
+ def run
14
+ if @options.mac then
15
+ if not @network
16
+ @network = Amnesie::Network.new(@options.netcard)
17
+ end
18
+ puts @network.card
19
+ process = Amnesie::Process.new
20
+ card = Amnesie::MAC.new(@network.card)
21
+
22
+ process.kill
23
+ card.save_origin
24
+ card.rand
25
+ card.apply
26
+ puts card.to_s
27
+ process.restart
28
+ end
29
+ end
30
+ end
31
+ end
data/test/test_mac.rb ADDED
@@ -0,0 +1,14 @@
1
+ require 'minitest/autorun'
2
+ require_relative '../lib/amnesie/mac'
3
+
4
+ class TestMAC
5
+ describe 'to_s' do
6
+ it 'should return card name nolife with a random MAC' do
7
+ card = 'nolife'
8
+ mac = /#{card} [0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}:[0-9A-F]{2}/
9
+
10
+ amn = Amnesie::MAC.new(card).to_s
11
+ _(amn).must_match mac
12
+ end
13
+ end
14
+ end
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ��`�Hce0�������5��F�ab=� E$<�2���\��v�5��X��(Ƀ�r�m<�y~u�W�9/T��|
2
+ 1�xQ)I�����W+��;k�#���]z�!�s&�&��/Ƀ�g>S:i��E��].x_�MXGnS��'��j@AD4�x�j *�1
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: amnesie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - szorfein
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12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1ZJdzcVABSnVuD83z5ne9eBlrYscHHSXev5FX32jFdKxl19FQ+eorjSOTsNq
29
+ SIgKneQOKdsWIlv8M6NDiUDcc1s504fOpIVtMbP+6n47hBGz4bzGlAdtvTO1PewK
30
+ tW6ii8TOCOJ3Pv6bTzQlsaQrADi2MHuVHTb14H7uoSFJNzfU4sYJn1C3PRMC3G7n
31
+ Qe/zVOdMf0bkwBnfQNojbwx3Vy1jr2JSQWjK25NYimpuKV0skanU0iBiqru6VCbK
32
+ zhDNufCgCnWLwXXET3onVQMZsiLTUFf30BXX7PY1O0Km15MQn1HzOecJ3ZIDBWtS
33
+ d/lg1MHB7+/FQAY5FujZqvVv5i2M9wLx+7N4ONRA7MsWD86hLiYN68QeRsHI+LNf
34
+ AnVdw7i28f3GhZldcdllblGeTOjSfwl9wL4yBb1UwVjvcwMR5SDed0yPmHPXBiAC
35
+ J/zT/q2Ac7BWpSLbv6p9lChBiEnD9j24x463LR5QQjDNS5SsjzRQfFuprsa9Nqf2
36
+ Tw==
37
+ -----END CERTIFICATE-----
38
+ date: 2020-05-13 00:00:00.000000000 Z
39
+ dependencies:
40
+ - !ruby/object:Gem::Dependency
41
+ name: rainbow
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 3.0.0
47
+ type: :runtime
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 3.0.0
54
+ - !ruby/object:Gem::Dependency
55
+ name: interfacez
56
+ requirement: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '='
59
+ - !ruby/object:Gem::Version
60
+ version: 1.0.3
61
+ type: :runtime
62
+ prerelease: false
63
+ version_requirements: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - '='
66
+ - !ruby/object:Gem::Version
67
+ version: 1.0.3
68
+ - !ruby/object:Gem::Dependency
69
+ name: nomansland
70
+ requirement: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - '='
73
+ - !ruby/object:Gem::Version
74
+ version: 0.0.2
75
+ type: :runtime
76
+ prerelease: false
77
+ version_requirements: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - '='
80
+ - !ruby/object:Gem::Version
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
96
+ description: ' A tool to make your computer amnesic"
97
+
98
+ '
99
+ email: szorfein@protonmail.com
100
+ executables:
101
+ - amnesie
102
+ extensions: []
103
+ extra_rdoc_files:
104
+ - README.md
105
+ - CHANGELOG.md
106
+ - LICENSE
107
+ files:
108
+ - ".gitignore"
109
+ - CHANGELOG.md
110
+ - LICENSE
111
+ - README.md
112
+ - amnesie.gemspec
113
+ - bin/amnesie
114
+ - lib/amnesie/helpers.rb
115
+ - lib/amnesie/mac.rb
116
+ - lib/amnesie/network.rb
117
+ - lib/amnesie/options.rb
118
+ - lib/amnesie/process.rb
119
+ - lib/amnesie/runner.rb
120
+ - test/test_mac.rb
121
+ homepage: https://github.com/szorfein/amnesie
122
+ licenses:
123
+ - MIT
124
+ metadata:
125
+ changelog_uri: https://github.com/szorfein/amnesie/blob/master/CHANGELOG.md
126
+ bug_tracker_uri: https://github.com/szorfein/amnesie/issues
127
+ wiki_uri: https://github.com/szorfein/amnesie
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ">="
135
+ - !ruby/object:Gem::Version
136
+ version: '2.4'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubygems_version: 3.1.2
144
+ signing_key:
145
+ specification_version: 4
146
+ summary: A tool to make your computer amnesic
147
+ test_files:
148
+ - test/test_mac.rb
metadata.gz.sig ADDED
Binary file