1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""LICENSE
Copyright (C) 2020 Sam Freeside
This file is part of usbrip.
usbrip is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
usbrip is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with usbrip. If not, see <http://www.gnu.org/licenses/>.
"""
__author__ = 'Sam Freeside (@snovvcrash)'
__email__ = 'snovvcrash@protonmail.ch'
__license__ = 'GPL-3.0'
__site__ = 'https://github.com/snovvcrash/usbrip'
__brief__ = 'USB device artifacts tracker'
import glob
import shutil
import sys
import os
import subprocess
from setuptools import setup, find_packages, Command
from setuptools.command.install import install
from usbrip import __version__
class LocalInstallCommand(install):
"""Custom install command to install local Python dependencies."""
def run(self):
install.run(self)
class CleanCommand(Command):
"""Custom clean command to tidy up the project root."""
CLEAN_FILES = './build ./dist ./*.pyc ./*.tgz ./*.egg-info'.split(' ')
user_options = []
def initialize_options(self):
self.all = False
def finalize_options(self):
pass
def run(self):
here = os.path.abspath(os.path.dirname(__file__))
for path_spec in self.CLEAN_FILES:
abs_paths = glob.glob(os.path.normpath(os.path.join(here, path_spec)))
for path in abs_paths:
if not path.startswith(here):
# Die if path in CLEAN_FILES is absolute + outside this directory
raise ValueError(f'{path} is not a path inside {here}')
print(f'[*] Removing {os.path.relpath(path)}')
shutil.rmtree(path)
def resolve(dep, path=None):
pip = os.path.join(sys.executable.rsplit('/', 1)[0], 'pip')
if path:
args = [pip, 'install', os.path.join(path, dep)]
dep_type = 'local'
else:
args = [pip, 'install', dep]
dep_type = 'remote'
try:
output = subprocess.check_output(args).decode('utf-8')
if 'Successfully installed' in output:
print(f'[*] Resolved ({dep_type}) dependency: {dep}')
except subprocess.CalledProcessError as e:
print(f'Error installing dependency: {dep}')
print(e)
def parse_requirements(file):
required = []
with open(file, 'r') as f:
for req in f:
if not req.strip().startswith('#'):
required.append(req)
return required
long_description = '''\
Simple CLI forensics tool for tracking \
USB device artifacts (history of USB events) \
on GNU/Linux.\
'''.replace('\t', '')
keywords = 'forensics cybersecurity infosec usb-history usb-devices'
#resolve('wheel')
setup(
name='usbrip',
version=__version__,
url=__site__,
author=__author__,
author_email=__email__,
license=__license__,
description=__brief__,
long_description=long_description,
long_description_content_type='text/markdown',
keywords=keywords,
packages=find_packages(),
zip_safe=False,
python_requires='>=3.6',
install_requires=parse_requirements('requirements.txt'),
cmdclass={
'install': LocalInstallCommand,
'clean': CleanCommand
},
entry_points={
'console_scripts': [
'usbrip=usbrip.__main__:main'
]
}
)
|