Skip to content

Commit

Permalink
another one
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrf45 committed Nov 30, 2024
1 parent bc1ee68 commit 36a255a
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 2 deletions.
2 changes: 1 addition & 1 deletion aegis-util/aegis/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def run_cli():
pull_images()
elif action == "Start Container":
image = questionary.select("Select an image", choices=[
"fonalex45/aegis:dev", "dfonalex45/aegis:latest"]).ask()
"fonalex45/aegis:dev", "fonalex45/aegis:latest"]).ask()
use_host_network = questionary.confirm("Enable host networking?").ask()
project_dir = questionary.text(
"Enter the project directory path:").ask()
Expand Down
2 changes: 1 addition & 1 deletion aegis-util/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"docker==7.1.0",
"tqdm==4.67.0",
"questionary==2.0.1",
"pycrypto==2.6.1",
"pycryptodome==3.21.0",
"fabric==3.2.2",
"paramiko==3.5.0",
"paramiko-jump==0.1.3"
Expand Down
8 changes: 8 additions & 0 deletions wrapper/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 .
Empty file added wrapper/aegis/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions wrapper/aegis/config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import yaml


def load_profiles():
with open("aegis/profiles.yaml", "r") as file:
return yaml.safe_load(file)["profiles"]
38 changes: 38 additions & 0 deletions wrapper/aegis/docker_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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()
Empty file added wrapper/aegis/main.py
Empty file.
15 changes: 15 additions & 0 deletions wrapper/aegis/profiles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
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"


7 changes: 7 additions & 0 deletions wrapper/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
pycryptodome==3.21.0
fabric==3.2.2
paramiko==3.5.0
paramiko-jump==0.1.3
23 changes: 23 additions & 0 deletions wrapper/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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",
)

0 comments on commit 36a255a

Please sign in to comment.