Commit 2ad55875 authored by Hardik Zinzuvadiya's avatar Hardik Zinzuvadiya
Browse files

Phase 4+5: Core architecture + shared console across all tool files

Phase 4 (core.py — largely done in Phase 1, completed here):
- HackingTool: add ARCHIVED, ARCHIVED_REASON, SUPPORTED_OS, REQUIRES_* fields
- HackingTool: remove INSTALLATION_DIR (unused)
- HackingToolsCollection: add _active_tools(), _archived_tools(), _incompatible_tools()
- HackingToolsCollection: add _show_archived_tools() (option 98 sub-menu)
- HackingToolsCollection.show_options(): filter by OS and ARCHIVED flag
- OS-incompatible tools show count but are hidden from menu
- Archived tools accessible via option 98 with reason displayed

Phase 5 (all 22 remaining tool files):
- Remove local console = Console() and _theme = Theme() from all 22 files
- Remove P_COLOR and PURPLE_STYLE local constants
- Add `from core import HackingTool, HackingToolsCollection, console` everywhere
- Remove show_options() overrides from all collection classes (500+ lines deleted)
- Remove pretty_print() overrides from all collection classes
- Remove _get_attr() / _get_attr_fallback() helpers from all collection classes
- Replace super(ClassName, self).__init__() → super().__init__() in all files
- Remove # coding=utf-8 headers from all files
- Fix remaining PURPLE_STYLE usages → "bold magenta" literal

All 28 tool modules import cleanly. Zero local console instances remain.
parent 08f1e3e0
Loading
Loading
Loading
Loading
+1 −92
Original line number Diff line number Diff line
# coding=utf-8
from core import HackingTool
from core import HackingToolsCollection
from core import HackingTool, HackingToolsCollection, console
from tools.webattack import Web2Attack

from rich.console import Console
from rich.table import Table
from rich.panel import Panel
from rich.text import Text
from rich.prompt import Prompt

console = Console()
PURPLE_STYLE = "bold magenta"


class RouterSploit(HackingTool):
    TITLE = "RouterSploit"
@@ -66,90 +59,6 @@ class ExploitFrameworkTools(HackingToolsCollection):
        Web2Attack()
    ]

    def _get_attr(self, obj, *names, default=""):
        for n in names:
            if hasattr(obj, n):
                return getattr(obj, n)
        return default

    def pretty_print(self):
        table = Table(title="Exploit framework", show_lines=True, expand=True)
        table.add_column("Title", style="magenta", no_wrap=True)
        table.add_column("Description", style="magenta")
        table.add_column("Project URL", style="magenta", no_wrap=True)

        for t in self.TOOLS:
            title = self._get_attr(t, "TITLE", "Title", "title", default=t.__class__.__name__)
            desc = self._get_attr(t, "DESCRIPTION", "Description", "description", default="")
            url = self._get_attr(t, "PROJECT_URL", "PROJECT_URL", "PROJECT", "project_url", "projectUrl", default="")
            table.add_row(str(title), str(desc).strip().replace("\n", " "), str(url))

        panel = Panel(table, title=f"[magenta]Available Tools[/magenta]", border_style=PURPLE_STYLE)
        console.print(panel)

    def show_options(self, parent=None):
        console.print("\n")
        console.print(Panel.fit(
            "[bold magenta]Exploit Framework Collection[/bold magenta]\n"
            "Select a tool to view options or run it.",
            border_style=PURPLE_STYLE
        ))

        table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
        table.add_column("Index", justify="center", style="bold yellow")
        table.add_column("Tool Name", justify="left", style="bold green")
        table.add_column("Description", justify="left", style="white")

        for i, tool in enumerate(self.TOOLS):
            title = self._get_attr(tool, "TITLE", "Title", "title", default=tool.__class__.__name__)
            desc = self._get_attr(tool, "DESCRIPTION", "Description", "description", default="")
            table.add_row(str(i + 1), title, desc or "")

        table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
        console.print(table)

        try:
            choice = Prompt.ask("[bold cyan]Select a tool to run[/bold cyan]", default="99")
            choice = int(choice)
            if 1 <= choice <= len(self.TOOLS):
                selected = self.TOOLS[choice - 1]
                # If tool exposes show_options (collection-style), delegate to it
                if hasattr(selected, "show_options"):
                    selected.show_options(parent=self)
                # Otherwise, if runnable, call its run method
                elif hasattr(selected, "run"):
                    selected.run()
                else:
                    console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
            elif choice == 99:
                return 99
        except Exception:
            console.print("[bold red]Invalid choice. Try again.[/bold red]")
        return self.show_options(parent=parent)


# --- Optional helper: pretty-print the tools list into a magenta-styled table.
# This helper is non-invasive and does not change tool logic.
def render_tools_table(tools, title: str | None = None):
    """
    Render a list of HackingTool instances (or objects with TITLE/DESCRIPTION/PROJECT_URL)
    as a rich table in magenta style.
    """
    tbl = Table(title=title or "Tools", show_lines=False, header_style=PURPLE_STYLE)
    tbl.add_column("Name", style=PURPLE_STYLE, no_wrap=True)
    tbl.add_column("Description")
    tbl.add_column("Project URL", overflow="fold")

    for t in tools:
        name = getattr(t, "TITLE", "<unknown>")
        desc = getattr(t, "DESCRIPTION", "")
        url = getattr(t, "PROJECT_URL", "")
        tbl.add_row(name, desc, url)

    console.print(Panel(tbl, border_style=PURPLE_STYLE, title=Text(title or "Toolset", style=PURPLE_STYLE)))


if __name__ == "__main__":
    tools = ExploitFrameworkTools()
    tools.pretty_print()
    tools.show_options()
+8 −80
Original line number Diff line number Diff line
# coding=utf-8
import os
import sys

@@ -7,18 +6,12 @@ current_dir = os.path.dirname(__file__)
parent_dir = os.path.dirname(current_dir)
sys.path.append(parent_dir)

from core import HackingTool
from core import HackingToolsCollection
from core import HackingTool, HackingToolsCollection, console

from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from rich.table import Table
from rich.prompt import Prompt

console = Console()
PURPLE_STYLE = "bold magenta"


class Autopsy(HackingTool):
    TITLE = "Autopsy"
@@ -29,7 +22,7 @@ class Autopsy(HackingTool):
    RUN_COMMANDS = ["sudo autopsy"]

    def __init__(self):
        super(Autopsy, self).__init__(installable=False)
        super().__init__(installable=False)


class Wireshark(HackingTool):
@@ -40,7 +33,7 @@ class Wireshark(HackingTool):
    RUN_COMMANDS = ["sudo wireshark"]

    def __init__(self):
        super(Wireshark, self).__init__(installable=False)
        super().__init__(installable=False)


class BulkExtractor(HackingTool):
@@ -49,13 +42,13 @@ class BulkExtractor(HackingTool):
    PROJECT_URL = "https://github.com/simsong/bulk_extractor"

    def __init__(self):
        super(BulkExtractor, self).__init__([
        super().__init__([
            ('GUI Mode (Download required)', self.gui_mode),
            ('CLI Mode', self.cli_mode)
        ], installable=False, runnable=False)

    def gui_mode(self):
        console.print(Panel(Text(self.TITLE, justify="center"), style=PURPLE_STYLE))
        console.print(Panel(Text(self.TITLE, justify="center"), style="bold magenta"))
        console.print("[bold magenta]Cloning repository and attempting to run GUI...[/]")
        os.system("sudo git clone https://github.com/simsong/bulk_extractor.git")
        os.system("ls src/ && cd .. && cd java_gui && ./BEViewer")
@@ -65,7 +58,7 @@ class BulkExtractor(HackingTool):
            "[magenta]Please visit for more details about installation: https://github.com/simsong/bulk_extractor[/]")

    def cli_mode(self):
        console.print(Panel(Text(self.TITLE + " - CLI Mode", justify="center"), style=PURPLE_STYLE))
        console.print(Panel(Text(self.TITLE + " - CLI Mode", justify="center"), style="bold magenta"))
        os.system("sudo apt install bulk-extractor")
        console.print("[magenta]Showing bulk_extractor help and options:[/]")
        os.system("bulk_extractor -h")
@@ -80,7 +73,7 @@ class Guymager(HackingTool):
    PROJECT_URL = "https://guymager.sourceforge.io/"

    def __init__(self):
        super(Guymager, self).__init__(installable=False)
        super().__init__(installable=False)


class Toolsley(HackingTool):
@@ -96,7 +89,7 @@ class Toolsley(HackingTool):
    PROJECT_URL = "https://www.toolsley.com/"

    def __init__(self):
        super(Toolsley, self).__init__(installable=False, runnable=False)
        super().__init__(installable=False, runnable=False)


class ForensicTools(HackingToolsCollection):
@@ -109,71 +102,6 @@ class ForensicTools(HackingToolsCollection):
        Toolsley()
    ]

    def _get_attr(self, obj, *names, default=""):
        for n in names:
            if hasattr(obj, n):
                return getattr(obj, n)
        return default

    def pretty_print(self):
        table = Table(title="Forensic Tools", show_lines=True, expand=True)
        table.add_column("Title", style=PURPLE_STYLE, no_wrap=True)
        table.add_column("Description", style=PURPLE_STYLE)
        table.add_column("Project URL", style=PURPLE_STYLE, no_wrap=True)

        for t in self.TOOLS:
            title = self._get_attr(t, "TITLE", "Title", "title", default=t.__class__.__name__)
            desc = self._get_attr(t, "DESCRIPTION", "Description", "description", default="")
            url = self._get_attr(t, "PROJECT_URL", "PROJECT_URL", "PROJECT", "project_url", "projectUrl", default="")
            table.add_row(str(title), str(desc).replace("\n", " "), str(url))

        console.print(Panel(table, title=f"[magenta]Available Tools[/magenta]", border_style=PURPLE_STYLE))

    def show_options(self, parent=None):
        console.print("\n")
        console.print(Panel.fit(
            "[bold magenta]Forensic Tools Collection[/bold magenta]\n"
            "Select a tool to run or view options.",
            border_style=PURPLE_STYLE
        ))

        table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True)
        table.add_column("Index", justify="center", style="bold yellow")
        table.add_column("Tool Name", justify="left", style="bold green")
        table.add_column("Description", justify="left", style="white")

        for i, tool in enumerate(self.TOOLS):
            title = self._get_attr(tool, "TITLE", "Title", "title", default=tool.__class__.__name__)
            desc = self._get_attr(tool, "DESCRIPTION", "Description", "description", default="")
            table.add_row(str(i + 1), title, desc or "")

        table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
        console.print(table)

        try:
            choice = Prompt.ask("[bold cyan]Select a tool to run[/bold cyan]", default="99")
            choice = int(choice)
            if 1 <= choice <= len(self.TOOLS):
                selected = self.TOOLS[choice - 1]
                # delegate to collection-like tools if available
                if hasattr(selected, "show_options"):
                    selected.show_options(parent=self)
                # if tool exposes actions (like BulkExtractor) and has a menu, try to show it
                elif hasattr(selected, "show_actions"):
                    selected.show_actions(parent=self)
                # otherwise try to call run if present
                elif hasattr(selected, "run"):
                    selected.run()
                else:
                    console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
            elif choice == 99:
                return 99
        except Exception:
            console.print("[bold red]Invalid choice. Try again.[/bold red]")
        return self.show_options(parent=parent)


if __name__ == "__main__":
    tools = ForensicTools()
    tools.pretty_print()
    tools.show_options()
+12 −84
Original line number Diff line number Diff line
# coding=utf-8
import os
import socket
import subprocess
import webbrowser
import sys

from core import HackingTool
from core import HackingToolsCollection
from core import HackingTool, HackingToolsCollection, console
from core import clear_screen

from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from rich.prompt import Prompt
from rich.table import Table

console = Console()
PURPLE_STYLE = "bold magenta"


class NMAP(HackingTool):
@@ -29,7 +22,7 @@ class NMAP(HackingTool):
    PROJECT_URL = "https://github.com/nmap/nmap"

    def __init__(self):
        super(NMAP, self).__init__(runnable=False)
        super().__init__(runnable=False)


class Dracnmap(HackingTool):
@@ -48,12 +41,12 @@ class PortScan(HackingTool):
    TITLE = "Port scanning"

    def __init__(self):
        super(PortScan, self).__init__(installable=False)
        super().__init__(installable=False)

    def run(self):
        clear_screen()
        console.print(Panel(Text(self.TITLE, justify="center"), style=PURPLE_STYLE))
        target = Prompt.ask("[bold]Select a Target IP[/]", default="", show_default=False)
        console.print(Panel(Text(self.TITLE, justify="center"), style="bold magenta"))
        target = Prompt.ask("[bold]Select a Target IP[/bold magenta]", default="", show_default=False)
        subprocess.run(["sudo", "nmap", "-O", "-Pn", target])


@@ -61,14 +54,14 @@ class Host2IP(HackingTool):
    TITLE = "Host to IP "

    def __init__(self):
        super(Host2IP, self).__init__(installable=False)
        super().__init__(installable=False)

    def run(self):
        clear_screen()
        console.print(Panel(Text(self.TITLE, justify="center"), style=PURPLE_STYLE))
        console.print(Panel(Text(self.TITLE, justify="center"), style="bold magenta"))
        host = Prompt.ask("Enter host name (e.g. www.google.com):-  ")
        ips = socket.gethostbyname(host)
        console.print(f"[{PURPLE_STYLE}]{host} -> {ips}[/]")
        console.print("[bold magenta]{host} -> {ips}[/bold magenta]")


class XeroSploit(HackingTool):
@@ -111,11 +104,11 @@ class IsItDown(HackingTool):
    DESCRIPTION = "Check Website Is Online or Not"

    def __init__(self):
        super(IsItDown, self).__init__(
        super().__init__(
            [('Open', self.open)], installable=False, runnable=False)

    def open(self):
        console.print(Panel("Opening isitdownrightnow.com", style=PURPLE_STYLE))
        console.print(Panel("Opening isitdownrightnow.com", style="bold magenta"))
        webbrowser.open_new_tab("https://www.isitdownrightnow.com/")


@@ -171,7 +164,7 @@ class SecretFinder(HackingTool):
    PROJECT_URL = "https://github.com/m4ll0k/SecretFinder"

    def __init__(self):
        super(SecretFinder, self).__init__(runnable=False)
        super().__init__(runnable=False)


class Shodan(HackingTool):
@@ -183,7 +176,7 @@ class Shodan(HackingTool):
    PROJECT_URL = "https://github.com/m4ll0k/Shodanfy.py"

    def __init__(self):
        super(Shodan, self).__init__(runnable=False)
        super().__init__(runnable=False)


class PortScannerRanger(HackingTool):
@@ -241,71 +234,6 @@ class InformationGatheringTools(HackingToolsCollection):
        Breacher()
    ]

    def _get_attr(self, obj, *names, default=""):
        for n in names:
            if hasattr(obj, n):
                return getattr(obj, n)
        return default

    def pretty_print(self):
        table = Table(title="Information Gathering Tools", show_lines=True, expand=True)
        table.add_column("Title", style=PURPLE_STYLE, no_wrap=True)
        table.add_column("Description", style=PURPLE_STYLE)
        table.add_column("Project URL", style=PURPLE_STYLE, no_wrap=True)

        for t in self.TOOLS:
            title = self._get_attr(t, "TITLE", "Title", "title", default=t.__class__.__name__)
            desc = self._get_attr(t, "DESCRIPTION", "Description", "description", default="")
            url = self._get_attr(t, "PROJECT_URL", "PROJECT_URL", "PROJECT", "project_url", "projectUrl", default="")
            table.add_row(str(title), str(desc).replace("\n", " "), str(url))

        console.print(Panel(table, title=f"[magenta]Available Tools[/magenta]", border_style=PURPLE_STYLE))

    def show_options(self, parent=None):
        console.print("\n")
        console.print(Panel.fit(
            "[bold magenta]Information Gathering Collection[/bold magenta]\n"
            "Select a tool to view/run it or return to the previous menu.",
            border_style=PURPLE_STYLE
        ))

        table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
        table.add_column("Index", justify="center", style="bold yellow")
        table.add_column("Tool Name", justify="left", style="bold green")
        table.add_column("Description", justify="left", style="white")

        for i, tool in enumerate(self.TOOLS):
            title = self._get_attr(tool, "TITLE", "Title", "title", default=tool.__class__.__name__)
            desc = self._get_attr(tool, "DESCRIPTION", "Description", "description", default="")
            table.add_row(str(i + 1), title, desc or "")

        table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
        console.print(table)

        try:
            choice = Prompt.ask("[bold cyan]Select a tool to run[/bold cyan]", default="99")
            choice = int(choice)
            if 1 <= choice <= len(self.TOOLS):
                selected = self.TOOLS[choice - 1]
                # delegate to collection-style tools if available
                if hasattr(selected, "show_options"):
                    selected.show_options(parent=self)
                # if tool exposes actions/menu, try to call it
                elif hasattr(selected, "show_actions"):
                    selected.show_actions(parent=self)
                # otherwise try to call run if present
                elif hasattr(selected, "run"):
                    selected.run()
                else:
                    console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
            elif choice == 99:
                return 99
        except Exception:
            console.print("[bold red]Invalid choice. Try again.[/bold red]")
        return self.show_options(parent=parent)


if __name__ == "__main__":
    tools = InformationGatheringTools()
    tools.pretty_print()
    tools.show_options()
+1 −71
Original line number Diff line number Diff line
# coding=utf-8
import os
import subprocess

from core import HackingTool
from core import HackingToolsCollection
from core import HackingTool, HackingToolsCollection, console
from tools.others.android_attack import AndroidAttackTools
from tools.others.email_verifier import EmailVerifyTools
from tools.others.hash_crack import HashCrackingTools
@@ -15,15 +13,9 @@ from tools.others.socialmedia_finder import SocialMediaFinderTools
from tools.others.web_crawling import WebCrawlingTools
from tools.others.wifi_jamming import WifiJammingTools

from rich.console import Console
from rich.theme import Theme
from rich.table import Table
from rich.panel import Panel
from rich.prompt import Prompt

_theme = Theme({"purple": "#7B61FF"})
console = Console(theme=_theme)


class HatCloud(HackingTool):
    TITLE = "HatCloud(Bypass CloudFlare for IP)"
@@ -59,68 +51,6 @@ class OtherTools(HackingToolsCollection):
        MixTools()
    ]

    def _get_attr(self, obj, *names, default=""):
        for n in names:
            if hasattr(obj, n):
                return getattr(obj, n)
        return default

    def pretty_print(self):
        table = Table(title="Other Tools", show_lines=True, expand=True)
        table.add_column("Title", style="purple", no_wrap=True)
        table.add_column("Description", style="purple")
        table.add_column("Project URL", style="purple", no_wrap=True)

        for t in self.TOOLS:
            title = self._get_attr(t, "TITLE", "Title", "title", default=t.__class__.__name__)
            desc = self._get_attr(t, "DESCRIPTION", "Description", "description", default="")
            url = self._get_attr(t, "PROJECT_URL", "PROJECT_URL", "PROJECT", "project_url", "projectUrl", default="")
            table.add_row(str(title), str(desc).strip().replace("\n", " "), str(url))

        panel = Panel(table, title="[purple]Available Tools[/purple]", border_style="purple")
        console.print(panel)

    def show_options(self, parent=None):
        console.print("\n")
        panel = Panel.fit("[bold magenta]Other Tools Collection[/bold magenta]\n"
                          "Select a tool to view options or run it.",
                          border_style="purple")
        console.print(panel)

        table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
        table.add_column("Index", justify="center", style="bold yellow")
        table.add_column("Tool Name", justify="left", style="bold green")
        table.add_column("Description", justify="left", style="white")

        for i, tool in enumerate(self.TOOLS):
            title = self._get_attr(tool, "TITLE", "Title", "title", default=tool.__class__.__name__)
            desc = self._get_attr(tool, "DESCRIPTION", "Description", "description", default="")
            table.add_row(str(i + 1), title, desc or "")

        table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
        console.print(table)

        try:
            choice = Prompt.ask("[bold cyan]Select a tool to run[/bold cyan]", default="99")
            choice = int(choice)
            if 1 <= choice <= len(self.TOOLS):
                selected = self.TOOLS[choice - 1]
                # If tool exposes show_options (collection-style), delegate to it
                if hasattr(selected, "show_options"):
                    selected.show_options(parent=self)
                # Otherwise, if runnable, call its run method
                elif hasattr(selected, "run"):
                    selected.run()
                else:
                    console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
            elif choice == 99:
                return 99
        except Exception:
            console.print("[bold red]Invalid choice. Try again.[/bold red]")
        return self.show_options(parent=parent)


if __name__ == "__main__":
    tools = OtherTools()
    tools.pretty_print()
    tools.show_options()
+2 −65
Original line number Diff line number Diff line
# coding=utf-8
from core import HackingTool
from core import HackingToolsCollection
from core import HackingTool, HackingToolsCollection, console

from rich.console import Console
from rich.theme import Theme
from rich.table import Table
from rich.panel import Panel
from rich.prompt import Prompt
from rich import box

_theme = Theme({"purple": "#7B61FF"})
console = Console(theme=_theme)


class Keydroid(HackingTool):
    TITLE = "Keydroid"
@@ -77,61 +69,6 @@ class AndroidAttackTools(HackingToolsCollection):
        EvilApp()
    ]

    def pretty_print(self):
        table = Table(title="Android Attack Tools", show_lines=True, expand=True)
        table.add_column("Title", style="purple", no_wrap=True)
        table.add_column("Description", style="purple")
        table.add_column("Project URL", style="purple", no_wrap=True)

        for t in self.TOOLS:
            desc = getattr(t, "DESCRIPTION", "") or ""
            url = getattr(t, "PROJECT_URL", "") or ""
            table.add_row(t.TITLE, desc.strip().replace("\n", " "), url)

        panel = Panel(table, title="[purple]Available Tools[/purple]", border_style="purple")
        console.print(panel)

    def show_options(self, parent=None):
        console.print("\n")
        panel = Panel.fit("[bold magenta]Android Attack Tools Collection[/bold magenta]\n"
                          "Select a tool to view details or run it.",
                          border_style="purple")
        console.print(panel)

        table = Table(title="[bold cyan]Available Tools[/bold cyan]", show_lines=True, expand=True)
        table.add_column("Index", justify="center", style="bold yellow")
        table.add_column("Tool Name", justify="left", style="bold green")
        table.add_column("Description", justify="left", style="white")

        for i, tool in enumerate(self.TOOLS):
            title = getattr(tool, "TITLE", tool.__class__.__name__)
            desc = getattr(tool, "DESCRIPTION", "")
            table.add_row(str(i + 1), title, desc or "")

        table.add_row("[red]99[/red]", "[bold red]Exit[/bold red]", "Return to previous menu")
        console.print(table)

        try:
            choice = Prompt.ask("[bold cyan]Select a tool to view/run[/bold cyan]", default="99")
            choice = int(choice)
            if 1 <= choice <= len(self.TOOLS):
                selected = self.TOOLS[choice - 1]
                if hasattr(selected, "show_options"):
                    selected.show_options(parent=self)
                elif hasattr(selected, "run"):
                    selected.run()
                elif hasattr(selected, "show_info"):
                    selected.show_info()
                else:
                    console.print("[bold yellow]Selected tool has no runnable interface.[/bold yellow]")
            elif choice == 99:
                return 99
        except Exception:
            console.print("[bold red]Invalid choice. Try again.[/bold red]")
        return self.show_options(parent=parent)


if __name__ == "__main__":
    tools = AndroidAttackTools()
    tools.pretty_print()
    tools.show_options()
Loading