diff --git a/.gitignore b/.gitignore index 70f7a4b4..11e5ea18 100644 --- a/.gitignore +++ b/.gitignore @@ -40,3 +40,6 @@ pupy/config pupy/crypto pupy/data pupy/proxy/proxy + +build +pupy.egg-info diff --git a/pupy/pupylib/PupyConfig.py b/pupy/pupylib/PupyConfig.py index 7ebf3f6b..701a14ba 100644 --- a/pupy/pupylib/PupyConfig.py +++ b/pupy/pupylib/PupyConfig.py @@ -103,10 +103,11 @@ class Tags(object): class PupyConfig(RawConfigParser): def __init__(self, config='pupy.conf'): - self.root = path.abspath(os.path.join(ROOT, "..")) + self.root = path.abspath(ROOT) self.user_root = path.expanduser(path.join('~', '.config', 'pupy')) - self.default_file = path.join(self.root, config+'.default') + self.default_file = path.join(self.root, "conf", config+'.default') self.user_path = path.join(self.user_root, config) + if not os.path.exists(self.user_path): shutil.copyfile(self.default_file, self.user_path) logger.info("No default pupy config file, creating one in {}".format(self.user_path)) diff --git a/pupy/pupylib/PupyServer.py b/pupy/pupylib/PupyServer.py index f1df1893..bf08aedf 100644 --- a/pupy/pupylib/PupyServer.py +++ b/pupy/pupylib/PupyServer.py @@ -81,7 +81,7 @@ from pupy.pupylib.PupyOffload import PupyOffloadManager, OffloadProxyCommonError from pupy.pupylib import PupyService from pupy.pupylib import PupyClient from pupy.pupylib import Credentials -from pupy.pupylib import PUPYLIB_DIR +from pupy.pupylib import ROOT from .utils.rpyc_utils import obtain from .utils.listener import get_listener_ip_with_local @@ -658,7 +658,8 @@ class PupyServer(object): reprb( pupycompile( path.join( - PUPYLIB_DIR, + ROOT, + "pupylib", 'PupyClientInitializer.py' ), path=True, raw=True, @@ -900,7 +901,7 @@ class PupyServer(object): paths = set([ path.abspath(x) for x in [ - self.config.root, '.', path.join(PUPYLIB_DIR, '..') + self.config.root, '.', ROOT ] ]) diff --git a/pupy/pupylib/__init__.py b/pupy/pupylib/__init__.py index 0e9236b0..0c9f3ed4 100644 --- a/pupy/pupylib/__init__.py +++ b/pupy/pupylib/__init__.py @@ -4,7 +4,7 @@ __all__ = [ 'getLogger', 'PupyCmdLoop', 'PupyService', 'PupyConfig', 'PupyServer', 'PupyModule', 'Credentials', 'PupyClient', - 'ROOT', 'PUPYLIB_DIR', + 'ROOT', 'HOST_SYSTEM', 'HOST_CPU_ARCH', 'HOST_OS_ARCH' ] @@ -14,18 +14,10 @@ import platform import re ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..')) -PUPYLIB_DIR = os.path.abspath(os.path.join(os.path.dirname(__file__))) HOST_SYSTEM = platform.system() HOST_CPU_ARCH = platform.architecture()[0] HOST_OS_ARCH = platform.machine() -USE_PIPX = False -# hotpatch for pipx installs. TODO: do this a cleaner way -if "/pipx/venv" in ROOT: - res = re.findall("(.*/pipx/venvs/[^/]+)", ROOT) - if len(res) == 1: - ROOT = os.path.join(res[0], "data", "pupy") - USE_PIPX = True DEPS = [ os.path.abspath(os.path.join(ROOT, 'library_patches_py3')), diff --git a/setup.py b/setup.py index 999b3544..a6d1d44c 100644 --- a/setup.py +++ b/setup.py @@ -8,24 +8,11 @@ import sys requirements = [x.strip() for x in open("requirements.txt", "r").readlines()] #requirements = [f"{line.split('#egg=')[-1]} @ {line}" if "#egg=" in line else line for line in requirements] -def generate_data_files(): - data_files = [("data", ["pupy/pupy.conf.default"])] - data_dirs = ('pupy/library_patches_py3', 'pupy/library_patches_py2', 'pupy/packages') - for data_dir in data_dirs: - for path, dirs, files in os.walk(data_dir): - if "__pycache__" in path: - continue - install_dir = os.path.join("data", path) - list_entry = (install_dir, [os.path.join(path, f) for f in files if not f.startswith('.')]) - data_files.append(list_entry) - return data_files - setup( name='pupy', version='3.0.0', - packages=find_packages(where='pupy', include=['pupy*', 'pupylib*', 'network*', 'commands*', 'modules*', 'scriptlets*', 'triggers*']), - package_dir={"": "pupy"}, - data_files=generate_data_files(), + packages=find_packages(where='.', include=['pupy*']), + package_data={'pupy': ['conf/**', 'external/**', 'packages/**', 'library_patches_py3/**', 'library_patches_py2/**']}, license_files = ('LICENSE'), author='n1nj4sec', author_email='contact@n1nj4.eu', @@ -36,7 +23,7 @@ setup( keywords=["python", "pentest", "cybersecurity", "redteam", "C2", "command and control", "post-exploitation"], entry_points={ 'console_scripts': [ - 'pupysh = pupylib.cli.pupysh:main' + 'pupysh = pupy.cli.pupysh:main' ] }, install_requires=requirements