From 29cf5a0b421933f16a5a9ebe8e8e10c7e7b78b72 Mon Sep 17 00:00:00 2001 From: alexrf45 Date: Sat, 30 Nov 2024 13:51:00 -0500 Subject: [PATCH] new --- wrapper/aegis/__init__.py => test/README.md | 0 .../aegis/main.py => test/aegis/__init__.py | 0 test/aegis/cli.py | 37 ++++++++++++++++++ test/aegis/constants.py | 6 +++ test/aegis/docker_manager.py | 32 ++++++++++++++++ test/aegis/utils.py | 0 test/requirements.txt | 0 test/setup.py | 19 ++++++++++ wrapper/README.md | 8 ---- wrapper/aegis/config.py | 6 --- wrapper/aegis/docker_utils.py | 38 ------------------- wrapper/aegis/profiles.yaml | 15 -------- wrapper/requirements.txt | 7 ---- wrapper/setup.py | 23 ----------- 14 files changed, 94 insertions(+), 97 deletions(-) rename wrapper/aegis/__init__.py => test/README.md (100%) rename wrapper/aegis/main.py => test/aegis/__init__.py (100%) create mode 100644 test/aegis/cli.py create mode 100644 test/aegis/constants.py create mode 100644 test/aegis/docker_manager.py create mode 100644 test/aegis/utils.py create mode 100644 test/requirements.txt create mode 100644 test/setup.py delete mode 100644 wrapper/README.md delete mode 100644 wrapper/aegis/config.py delete mode 100644 wrapper/aegis/docker_utils.py delete mode 100644 wrapper/aegis/profiles.yaml delete mode 100644 wrapper/requirements.txt delete mode 100644 wrapper/setup.py diff --git a/wrapper/aegis/__init__.py b/test/README.md similarity index 100% rename from wrapper/aegis/__init__.py rename to test/README.md diff --git a/wrapper/aegis/main.py b/test/aegis/__init__.py similarity index 100% rename from wrapper/aegis/main.py rename to test/aegis/__init__.py diff --git a/test/aegis/cli.py b/test/aegis/cli.py new file mode 100644 index 0000000..1c2a0a6 --- /dev/null +++ b/test/aegis/cli.py @@ -0,0 +1,37 @@ + +import questionary +from .docker_manager import pull_image, create_project_dir, run_container + + +def main(): + client = docker.from_env() + + action = questionary.select( + "What would you like to do?", + choices=[ + "Pull Image", "Create Project", "Run Container", "Stop Container", + "Destroy Container", "Exit" + ] + ).ask() + + if action == "Pull Image": + image_choice = questionary.select( + "Select the image to pull:", + choices=list(IMAGE_TAGS.values()) + ).ask() + pull_image(client, image_choice) + + elif action == "Create Project": + project_name = questionary.text("Enter project name:").ask() + create_project_dir(project_name) + + elif action == "Run Container": + image_choice = questionary.select( + "Select image to run:", choices=list(IMAGE_TAGS.values())).ask() + project_dir = questionary.text("Enter project directory:").ask() + host_network = questionary.confirm("Enable host networking?").ask() + run_container(client, image_choice, project_dir, host_network) + + +if __name__ == '__main__': + main() diff --git a/test/aegis/constants.py b/test/aegis/constants.py new file mode 100644 index 0000000..7732cae --- /dev/null +++ b/test/aegis/constants.py @@ -0,0 +1,6 @@ +IMAGE_TAGS = { + 'dev': 'fonalex45/aegis:dev', + 'latest': 'dfonalex45/aegis:latest', +} + +DEFAULT_DIRECTORIES = ['recon', 'exploit', 'www', 'privesc', 'report', 'loot'] diff --git a/test/aegis/docker_manager.py b/test/aegis/docker_manager.py new file mode 100644 index 0000000..ca5a842 --- /dev/null +++ b/test/aegis/docker_manager.py @@ -0,0 +1,32 @@ +import docker +import os +from tqdm import tqdm + + +def pull_image(client, image_tag): + print(f"Pulling image: {image_tag}") + for line in client.api.pull(image_tag, stream=True, decode=True): + if 'status' in line: + print(line['status']) + + +def create_project_dir(project_name): + os.makedirs(project_name, exist_ok=True) + for folder in DEFAULT_DIRECTORIES: + os.makedirs(os.path.join(project_name, folder), exist_ok=True) + print(f"Project directories created under {project_name}.") + + +def run_container(client, image, project_dir, host_network): + container = client.containers.run( + image, + command='/bin/zsh', + volumes={os.path.abspath(project_dir): { + 'bind': '/workspace', 'mode': 'rw'}}, + network_mode='host' if host_network else None, + detach=True, + stdin_open=True, + tty=True + ) + print(f"Container {container.short_id} started.") + return container diff --git a/test/aegis/utils.py b/test/aegis/utils.py new file mode 100644 index 0000000..e69de29 diff --git a/test/requirements.txt b/test/requirements.txt new file mode 100644 index 0000000..e69de29 diff --git a/test/setup.py b/test/setup.py new file mode 100644 index 0000000..6362fad --- /dev/null +++ b/test/setup.py @@ -0,0 +1,19 @@ + +from setuptools import setup, find_packages + +setup( + name='aegis', + version='0.1.0', + packages=find_packages(), + install_requires=[ + 'docker==7.1.0', + 'questionary==2.0.1', + 'pycryptodome==3.21.0', + 'fabric==3.2.2', + ], + entry_points={ + 'console_scripts': [ + 'aegis = aegis.cli:main', + ], + }, +) diff --git a/wrapper/README.md b/wrapper/README.md deleted file mode 100644 index b994746..0000000 --- a/wrapper/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Aegis - -A Python wrapper/TUI to manage Docker containers for the Aegis project. - -## Installation - -```bash -pip install . diff --git a/wrapper/aegis/config.py b/wrapper/aegis/config.py deleted file mode 100644 index 4e155bb..0000000 --- a/wrapper/aegis/config.py +++ /dev/null @@ -1,6 +0,0 @@ -import yaml - - -def load_profiles(): - with open("aegis/profiles.yaml", "r") as file: - return yaml.safe_load(file)["profiles"] diff --git a/wrapper/aegis/docker_utils.py b/wrapper/aegis/docker_utils.py deleted file mode 100644 index 91ec146..0000000 --- a/wrapper/aegis/docker_utils.py +++ /dev/null @@ -1,38 +0,0 @@ -import docker -from questionary import confirm -import os - -client = docker.from_env() - - -def pull_image(image_name): - print(f"Pulling image: {image_name}") - client.images.pull(image_name) - - -def start_container(profile, mount_path=None): - print(f"Starting container: {profile['name']}") - host_network = profile['options'].get('host_networking', False) - default_mount = profile['options'].get('default_mount', '') - - if not mount_path and default_mount: - mount_path = default_mount - - mounts = {} - if mount_path: - src, target = mount_path.split(":") - mounts[src] = {'bind': target, 'mode': 'rw'} - - client.containers.run( - profile['image'], - detach=True, - network_mode="host" if host_network else None, - volumes=mounts, - tty=True, - ) - - -def stop_container(container_id): - container = client.containers.get(container_id) - container.stop() - container.remove() diff --git a/wrapper/aegis/profiles.yaml b/wrapper/aegis/profiles.yaml deleted file mode 100644 index 9e4d852..0000000 --- a/wrapper/aegis/profiles.yaml +++ /dev/null @@ -1,15 +0,0 @@ -profiles: - - name: "Dev" - image: "fonalex45/aegis:dev" - description: "Container for offensive security tools." - options: - host_networking: false - default_mount: "./projects:/workspace" - - name: "Main" - image: "fonalex45/aegis:latest" - description: "Container for offensive security tools." - options: - host_networking: true - default_mount: "./projects:/workspace" - - diff --git a/wrapper/requirements.txt b/wrapper/requirements.txt deleted file mode 100644 index 04aae31..0000000 --- a/wrapper/requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -docker==7.1.0 -tqdm==4.67.0 -questionary==2.0.1 -pycryptodome==3.21.0 -fabric==3.2.2 -paramiko==3.5.0 -paramiko-jump==0.1.3 diff --git a/wrapper/setup.py b/wrapper/setup.py deleted file mode 100644 index 7f498bb..0000000 --- a/wrapper/setup.py +++ /dev/null @@ -1,23 +0,0 @@ -from setuptools import setup, find_packages - -setup( - name="aegis", - version="0.2.0", - packages=find_packages(), - install_requires=[ - "docker==7.1.0", - "tqdm==4.67.0", - "questionary==2.0.1", - "pycryptodome==3.18.0", - "fabric==3.2.2", - "paramiko==3.5.0", - "paramiko-jump==0.1.3", - "pyyaml==6.0", - ], - entry_points={ - "console_scripts": [ - "aegis=aegis.main:main" - ] - }, - python_requires=">=3.6", -)