mirror of
https://github.com/Z4nzu/hackingtool
synced 2024-11-14 19:55:19 +00:00
eaa920a7e3
List of changes + Handling information about a tool has been improved a lot by providing a `HackingTool` class, which takes care of showing the options, running the selected option, executing the required commands + This class is designed with flexibililty and simplicity in mind, so adding a new tool is a lot easier, mention TITLE, DESCRIPTION, list of INSTALL_COMMANDS, RUN_COMMANDS and PROJECT_URL and there you go... + grouping all the `HackingTool`s is also made super simpler by providing a `HackingToolsCollection` class which groups the tools into their respective categories. Just add the instances of `HackingTool` classes to the TOOLS property of the `HackingToolsCollection`. + Refactored all the tools into separate files based on their categories. + Added a READM_template.md and generate_readme.py script to automatically generate Table of contents and the list of tools available automatically. + Now each tool in the README.md points to its project url if provided. This makes it easier to visit the project from the readme.
53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
# coding=utf-8
|
|
import re
|
|
|
|
from core import HackingTool
|
|
from core import HackingToolsCollection
|
|
from main import all_tools
|
|
|
|
|
|
def sanitize_anchor(s):
|
|
return re.sub(r"\W", "-", s.lower())
|
|
|
|
|
|
def get_toc(tools, indentation = ""):
|
|
md = ""
|
|
for tool in tools:
|
|
if isinstance(tool, HackingToolsCollection):
|
|
md += (indentation + "- [{}](#{})\n".format(
|
|
tool.TITLE, sanitize_anchor(tool.TITLE)))
|
|
md += get_toc(tool.TOOLS, indentation = indentation + ' ')
|
|
return md
|
|
|
|
|
|
def get_tools_toc(tools, indentation = "##"):
|
|
md = ""
|
|
for tool in tools:
|
|
if isinstance(tool, HackingToolsCollection):
|
|
md += (indentation + "# {}\n".format(tool.TITLE))
|
|
md += get_tools_toc(tool.TOOLS, indentation = indentation + '#')
|
|
elif isinstance(tool, HackingTool):
|
|
if tool.PROJECT_URL:
|
|
md += ("- [{}]({})\n".format(tool.TITLE, tool.PROJECT_URL))
|
|
else:
|
|
md += ("- {}\n".format(tool.TITLE))
|
|
return md
|
|
|
|
|
|
def generate_readme():
|
|
toc = get_toc(all_tools[:-1])
|
|
tools_desc = get_tools_toc(all_tools[:-1])
|
|
|
|
with open("README_template.md") as fh:
|
|
readme_template = fh.read()
|
|
|
|
readme_template = readme_template.replace("{{toc}}", toc)
|
|
readme_template = readme_template.replace("{{tools}}", tools_desc)
|
|
|
|
with open("README.md", "w") as fh:
|
|
fh.write(readme_template)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
generate_readme()
|