Removed and refactored the database to import data directly from Arsenal.
This commit is contained in:
43
data/arsenal_parser.py
Executable file
43
data/arsenal_parser.py
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
if len(sys.argv) < 2:
|
||||
script = sys.argv[0]
|
||||
print(f"Usage: {script} <arsenal_data_file>")
|
||||
exit(1)
|
||||
|
||||
commands = []
|
||||
cmd = ""
|
||||
tags = "pentest"
|
||||
lang = ""
|
||||
desc = ""
|
||||
with open(sys.argv[1], "r") as f:
|
||||
in_code_block = False
|
||||
for line in f.readlines():
|
||||
if line.startswith("% "):
|
||||
tags = line[2:].strip()
|
||||
elif line.startswith("## "):
|
||||
desc = line[3:].strip()
|
||||
elif line.startswith("#plateform/"):
|
||||
plateform = "".join(line[11:].strip().split(" ")[0])
|
||||
if plateform == "linux":
|
||||
lang = "sh"
|
||||
elif plateform == "windows":
|
||||
lang = "powershell"
|
||||
elif line.startswith("```"):
|
||||
in_code_block = not in_code_block
|
||||
elif in_code_block:
|
||||
if "arsenal" not in tags and "internal" not in tags:
|
||||
cmd = line.strip().replace("\n","")
|
||||
if len(cmd) > 0 and len(desc) > 0 and len(lang) > 0:
|
||||
entry = {}
|
||||
entry["cmd"] = cmd
|
||||
entry["tags"] = tags
|
||||
entry["lang"] = lang
|
||||
entry["desc"] = desc
|
||||
commands.append(entry)
|
||||
if len(commands) > 0:
|
||||
print(yaml.safe_dump(commands,width=1000))
|
||||
16
data/generate_arsenal_commands.sh
Executable file
16
data/generate_arsenal_commands.sh
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
SCRIPT=$(readlink -f "$0")
|
||||
SCRIPTPATH=$(dirname "$SCRIPT")
|
||||
for c in python git; do
|
||||
if ! command -v ${c} &>/dev/null; then
|
||||
echo "$command ${c} could not be found"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
cd /tmp
|
||||
git clone --depth 1 https://github.com/Orange-Cyberdefense/arsenal
|
||||
echo -e "title: Commands for Fast Memo Shell from Arsenal\ncommands:" >"${SCRIPTPATH}/commands.yaml"
|
||||
find arsenal/arsenal/data/cheats/ -iname '*.md' ! -name 'README.md' -exec ${SCRIPTPATH}/arsenal_parser.py {} \; >>"${SCRIPTPATH}/commands.yaml"
|
||||
rm -rf /tmp/arsenal
|
||||
Reference in New Issue
Block a user