RhinoSecurityLabs / pacu

The AWS exploitation framework, designed for testing the security of Amazon Web Services environments.

Home Page:https://rhinosecuritylabs.com/aws/pacu-open-source-aws-exploitation-framework/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Action to update the modules Wiki

DaveYesland opened this issue · comments

When a new module is added or changed it would be nice to just run a GitHub Action that updates the module details section of the Pacu Wiki. Code is below on how this might be done.

import os
import importlib
from pathlib import Path
​
cat_set = set()
text_list = []
current_directory = os.getcwd()
for root, directories, files in os.walk(Path(__file__).parent/'pacu/modules'):
    modules_directory_path = os.path.realpath(Path(__file__).parent/'pacu/modules')
    specific_module_directory = os.path.realpath(root)
​
    # Skip any directories inside module directories.
    if os.path.dirname(specific_module_directory) != modules_directory_path:
        continue
    # Skip the root directory.
    elif modules_directory_path == specific_module_directory:
        continue
​
    module_name = os.path.basename(root)
​
    for file in files:
        if file == 'main.py':
            # Make sure the format is correct
            module_path = str(Path('pacu/modules')/module_name/'main').replace('/', '.').replace('\\', '.')
            # Import the help function from the module
            module = __import__(module_path, globals(), locals(), ['module_info'], 0)
            importlib.reload(module)
            cat_set.add(module.module_info['category'])
            text_list += [{"cat":module.module_info['category'],"text":f"### {module.module_info['name']}\n> **{module.module_info['one_liner']}**\n\n{module.module_info['description']}\n\n"}]
for cat in cat_set:
    print(f"## {cat}")
    for text in text_list:
        if text["cat"] == cat:
            print(text["text"])

This just prints out the MD formatted text with all the modules and descriptions to match the current wiki format.

Note to self: One thing to look into though is if the token included during runs has the ability to make changes to the wiki.