Skip to content

Commit 0fd752c

Browse files
author
Debian Live user
committed
now installable
1 parent da4ab40 commit 0fd752c

5 files changed

Lines changed: 126 additions & 14 deletions

File tree

install/usbkill

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env python
2+
3+
# _ _ _ _ _
4+
# | | | | (_) | |
5+
# _ _ ___| |__ | | _ _| | |
6+
# | | | |/___) _ \| |_/ ) | | |
7+
# | |_| |___ | |_) ) _ (| | | |
8+
# |____/(___/|____/|_| \_)_|\_)_)
9+
#
10+
#
11+
# Hephaestos <hephaestos@riseup.net> - 8764 EF6F D5C1 7838 8D10 E061 CF84 9CE5 42D0 B12B
12+
# <https://github.com/hephaest0s/usbkill>
13+
#
14+
# This program is free software: you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation, either version 3 of the License, or
17+
# (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
27+
28+
import os
29+
30+
# Check if program is run as root, else exit.
31+
# Root is needed to power off the computer.
32+
if not os.geteuid() == 0:
33+
import sys
34+
sys.exit("\n[ERROR] This program needs to run as root.\n")
35+
36+
import usbkill
37+
usbkill.go()

settings.ini renamed to install/usbkill.ini

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1-
# Default config for version 1.0-rc.1
2-
# https://github.com/hephaest0s/usbkill
1+
# _ _ _ _ _
2+
# | | | | (_) | |
3+
# _ _ ___| |__ | | _ _| | |
4+
# | | | |/___) _ \| |_/ ) | | |
5+
# | |_| |___ | |_) ) _ (| | | |
6+
# |____/(___/|____/|_| \_)_|\_)_)
7+
#
8+
#
9+
# Hephaestos <hephaestos@riseup.net> - 8764 EF6F D5C1 7838 8D10 E061 CF84 9CE5 42D0 B12B
10+
# <https://github.com/hephaest0s/usbkill>
11+
#
12+
# This program is free software: you can redistribute it and/or modify
13+
# it under the terms of the GNU General Public License as published by
14+
# the Free Software Foundation, either version 3 of the License, or
15+
# (at your option) any later version.
16+
#
17+
# This program is distributed in the hope that it will be useful,
18+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
# GNU General Public License for more details.
21+
#
22+
# You should have received a copy of the GNU General Public License
23+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
324

425
[config]
526

@@ -129,3 +150,4 @@ wipe_ram_cmd = sdmem -fll
129150
do_wipe_swap = False
130151
# Check sswap --help for available options
131152
wipe_swap_cmd = sswap -l
153+

setup.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python
2+
3+
# _ _ _ _ _
4+
# | | | | (_) | |
5+
# _ _ ___| |__ | | _ _| | |
6+
# | | | |/___) _ \| |_/ ) | | |
7+
# | |_| |___ | |_) ) _ (| | | |
8+
# |____/(___/|____/|_| \_)_|\_)_)
9+
#
10+
#
11+
# Hephaestos <hephaestos@riseup.net> - 8764 EF6F D5C1 7838 8D10 E061 CF84 9CE5 42D0 B12B
12+
# <https://github.com/hephaest0s/usbkill>
13+
#
14+
# This program is free software: you can redistribute it and/or modify
15+
# it under the terms of the GNU General Public License as published by
16+
# the Free Software Foundation, either version 3 of the License, or
17+
# (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
26+
27+
28+
from distutils.core import setup
29+
from os import path
30+
31+
DIRNAME = path.dirname(path.realpath(__file__))
32+
33+
name = lambda x : path.join(DIRNAME, x)
34+
35+
setup(name='usbkill',
36+
version='1.0-rc.4',
37+
description='usbkill is an anti-forensic kill-switch that waits for a change on your USB ports and then immediately shuts down your computer.',
38+
author='Hephaestos',
39+
author_email='hephaestos@riseup.net',
40+
license='GPLv3',
41+
url='https://github.com/hephaest0s/usbkill',
42+
43+
packages=[name('usbkill')],
44+
scripts=[name('install/usbkill')],
45+
data_files=[ ('/etc/', [ name('install/usbkill.ini') ]) ]
46+
)
47+

usbkill/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
from usbkill import go

usbkill.py renamed to usbkill/usbkill.py

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#!/usr/bin/env python
2+
13
# _ _ _ _ _
24
# | | | | (_) | |
35
# _ _ ___| |__ | | _ _| | |
@@ -55,8 +57,8 @@
5557
Options:
5658
-h --help: Show this help
5759
--version: Print usbkill version and exit
58-
--cs: Copy program folder settings.ini to /etc/usbkill/settings.ini
59-
--no-shut-down: Execute all the (destructive) commands you defined in settings.ini,
60+
--cs: Copy program folder usbkill.ini to /etc/usbkill/usbkill.ini
61+
--no-shut-down: Execute all the (destructive) commands you defined in usbkill.ini,
6062
but don't turn off the computer
6163
"""
6264

@@ -111,7 +113,7 @@ def shred(settings):
111113
settings['folders_to_remove'].append(usbkill_folder)
112114
else:
113115
settings['files_to_remove'].append(os.path.realpath(__file__))
114-
settings['files_to_remove'].append(usbkill_folder + "/settings.ini")
116+
settings['files_to_remove'].append(usbkill_folder + "/usbkill.ini")
115117

116118
# Remove files and folders
117119
for _file in settings['files_to_remove'] + settings['folders_to_remove']:
@@ -381,16 +383,14 @@ def startup_checks():
381383
except subprocess.CalledProcessError:
382384
print("[NOTICE] FileVault is disabled. Sensitive data SHOULD be encrypted.")
383385

384-
# On first time use copy settings.ini to /etc/usebkill.ini
386+
# On first time use copy usbkill.ini to /etc/usebkill.ini
385387
# If dev-mode, always copy and don't remove old settings
386388
if not os.path.isfile(SETTINGS_FILE) or copy_settings:
387389
sources_path = os.path.dirname(os.path.realpath(__file__)) + '/'
388-
if not os.path.isfile(sources_path + "settings.ini"):
389-
sys.exit("\n[ERROR] You have lost your settings file. Get a new copy of the settings.ini and place it in /etc/ or in " + sources_path + "/\n")
390-
print("[NOTICE] Copying setting.ini to " + SETTINGS_FILE )
391-
os.system("cp " + sources_path + "settings.ini " + SETTINGS_FILE)
392-
if not copy_settings:
393-
os.remove(sources_path + "settings.ini")
390+
if not os.path.isfile(sources_path + "install/usbkill.ini"):
391+
sys.exit("\n[ERROR] You have lost your settings file. Get a new copy of the usbkill.ini and place it in /etc/ or in " + sources_path + "/\n")
392+
print("[NOTICE] Copying install/setting.ini to " + SETTINGS_FILE )
393+
os.system("cp " + sources_path + "install/usbkill.ini " + SETTINGS_FILE)
394394

395395
# Load settings
396396
settings = load_settings(SETTINGS_FILE)
@@ -399,7 +399,7 @@ def startup_checks():
399399
# Make sure no spaces a present in paths to be wiped.
400400
for name in settings['folders_to_remove'] + settings['files_to_remove']:
401401
if ' ' in name:
402-
msg += "[ERROR][WARNING] '" + name + "'as specified in your settings.ini contains a space.\n"
402+
msg += "[ERROR][WARNING] '" + name + "'as specified in your usbkill.ini contains a space.\n"
403403
sys.exit(msg)
404404

405405
# Make sure srm is present if it will be used.
@@ -428,7 +428,7 @@ def startup_checks():
428428

429429
return settings
430430

431-
if __name__=="__main__":
431+
def go():
432432
# Run startup checks and load settings
433433
settings = startup_checks()
434434

@@ -444,3 +444,8 @@ def exit_handler(signum, frame):
444444

445445
# Start main loop
446446
loop(settings)
447+
448+
if __name__=="__main__":
449+
go()
450+
451+

0 commit comments

Comments
 (0)