Skip to content

Commit

Permalink
initial package
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrf45 committed Nov 30, 2024
1 parent 1905ee6 commit 3686017
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 20 deletions.
8 changes: 8 additions & 0 deletions aegis-util/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Aegis

A Python wrapper/TUI to manage Docker containers for the Aegis project.

## Installation

```bash
pip install .
1 change: 1 addition & 0 deletions aegis-util/aegis/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
__version__ = "0.1.0"
100 changes: 100 additions & 0 deletions aegis-util/aegis/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import os
from tqdm import tqdm
import questionary
import docker
import sys
from . import aegis_cli # Assuming aegis_cli is the main CLI handler


def main():
aegis_cli.run()


IMAGE_DEV = "fonalex45/aegis:dev"
IMAGE_LATEST = "dfonalex45/aegis:latest"

client = docker.from_env()


def create_project_directory(base_dir):
folders = ["recon", "exploit", "www", "privesc", "report", "loot"]
os.makedirs(base_dir, exist_ok=True)
for folder in folders:
os.makedirs(os.path.join(base_dir, folder), exist_ok=True)
print(f"Project directory created at {base_dir}")


def pull_images():
for image in [IMAGE_DEV, IMAGE_LATEST]:
print(f"Pulling {image}...")
client.images.pull(image)
print("Images pulled successfully.")


def start_container(image, use_host_network, project_dir):
volumes = {project_dir: {'bind': '/workspace', 'mode': 'rw'}}
networking = 'host' if use_host_network else None
container = client.containers.run(
image,
network_mode=networking,
volumes=volumes,
detach=True
)
print(f"Container started: {container.id}")


def stop_container(container_id):
container = client.containers.get(container_id)
container.stop()
print(f"Container {container_id} stopped.")


def destroy_container(container_id):
container = client.containers.get(container_id)
container.remove(force=True)
print(f"Container {container_id} destroyed.")


def main():
action = questionary.select(
"What do you want to do?",
choices=["Pull Images", "Start Container", "Stop Container",
"Destroy Container", "Create Project Directory", "Help"]
).ask()

if action == "Pull Images":
pull_images()
elif action == "Start Container":
image = questionary.select("Select an image", choices=[
IMAGE_DEV, IMAGE_LATEST]).ask()
use_host_network = questionary.confirm("Enable host networking?").ask()
project_dir = questionary.text(
"Enter the project directory path:").ask()
create_project_directory(project_dir)
start_container(image, use_host_network, project_dir)
elif action == "Stop Container":
container_id = questionary.text(
"Enter the container ID to stop:").ask()
stop_container(container_id)
elif action == "Destroy Container":
container_id = questionary.text(
"Enter the container ID to destroy:").ask()
destroy_container(container_id)
elif action == "Create Project Directory":
project_dir = questionary.text(
"Enter the project directory path:").ask()
create_project_directory(project_dir)
elif action == "Help":
print("""
aegis commands:
pull - Pull the latest images
start - Start a container
stop - Stop a container
destroy - Destroy a container
create-project - Create project directory
help - Show this help menu
""")


if __name__ == "__main__":
main()
7 changes: 7 additions & 0 deletions aegis-util/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
docker==7.1.0
tqdm==4.67.0
questionary==2.0.1
pycrypto==2.6.1
fabric==3.2.2
paramiko==3.5.0
paramiko-jump==0.1.3
34 changes: 34 additions & 0 deletions aegis-util/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

from setuptools import setup, find_packages

setup(
name="aegis",
version="0.1.0",
packages=find_packages(),
install_requires=[
"docker==7.1.0",
"tqdm==4.67.0",
"questionary==2.0.1",
"pycrypto==2.6.1",
"fabric==3.2.2",
"paramiko==3.5.0",
"paramiko-jump==0.1.3"
],
entry_points={
"console_scripts": [
"aegis=aegis.main:main"
]
},
author="Sean Fontaine",
author_email="[email protected]",
description="A Docker wrapper/TUI for managing aegis containers",
long_description=open("README.md").read(),
long_description_content_type="text/markdown",
url="https://github.com/alexrf45/aegis.git",
classifiers=[
"Programming Language :: Python :: 3",
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
python_requires=">=3.6",
)
20 changes: 0 additions & 20 deletions aegis-util/stats.py

This file was deleted.

6 changes: 6 additions & 0 deletions resources/zsh/functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ webserver() {
-c monokai \
-p 9443 \
--header "Cache-Control:no-cache" \
--header "Server: Server" \
--header "X-Frame-Options: DENY" \
--header "Referrer-Policy: strict-origin-when-cross-origin" \
--header "Content-Type: text/html; charset=UTF-8" \
--header "Strict-Transport-Security: max-age=63072000; includeSubDomains; preload" \
--header "Permissions-Policy: geolocation=(), camera=(), microphone=(), bluetooth=(), usb=(), payment=(), display-capture=()" \
--auth-file ./auth.txt \
--tls-cert $HOME/.local/$1-cert.pem \
--tls-key $HOME/.local/$1-key.pem \
Expand Down

0 comments on commit 3686017

Please sign in to comment.