Module: Amnesie

Defined in:
lib/amnesie.rb,
lib/amnesie/mac.rb,
lib/amnesie/host.rb,
lib/amnesie/config.rb,
lib/amnesie/network.rb,
lib/amnesie/options.rb,
lib/amnesie/persist.rb,
lib/amnesie/process.rb,
lib/amnesie/version.rb,
lib/amnesie/persist/iwd.rb,
lib/amnesie/persist/systemd.rb,
lib/amnesie/persist/wpa_supplicant.rb

Defined Under Namespace

Modules: Persist Classes: Config, Host, MAC, Main, Network, Options, Process

Constant Summary collapse

OPTIONS =
{
  mac: true,
  hostname: false,
  card_match: /^en/
}.freeze
VERSION =
'0.0.9'.freeze

Class Method Summary collapse

Class Method Details

.persist_wifiObject

For wifi card, no need systemd



25
26
27
28
29
30
31
# File 'lib/amnesie.rb', line 25

def self.persist_wifi
  if TTY::Which.exist?('iwctl')
    Amnesie::Persist::Iwd.new
  elsif TTY::Which.exist?('wpa_supplicant')
    Amnesie::Persist::WpaSupplicant.new
  end
end

.random_mac(network) ⇒ Object



18
19
20
21
22
# File 'lib/amnesie.rb', line 18

def self.random_mac(network)
  mac = Amnesie::MAC.new(network)
  mac.set_addr
  puts "New MAC for " + mac.to_s
end

.random_mac_and_kill(network) ⇒ Object



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/amnesie.rb', line 48

def self.random_mac_and_kill(network)
  process = Amnesie::Process.new(network)
  mac = Amnesie::MAC.new(network)

  process.kill
  mac.down
  mac.set_addr
  puts "New MAC for " + mac.to_s
  mac.up
  process.restart

end

.services(network) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/amnesie.rb', line 33

def self.services(network)
  # For ethernet card
  if TTY::Which.exist?('systemctl') && network.match(/^en/)
    persist = Amnesie::Persist::Systemd.new(network)
    if ! persist.mac_exist?
      puts "Create service..."
      persist.services
    elsif persist.mac_exist?
      puts "service exist"
      persist.update_mac
    end
    persist.menu_mac
  end
end