import os

from core import HackingTool, HackingToolsCollection, console

from rich.panel import Panel
from rich.prompt import Prompt


class Vegile(HackingTool):
    TITLE = "Vegile - Ghost In The Shell"
    SUPPORTED_OS = ["linux"]
    DESCRIPTION = "This tool will set up your backdoor/rootkits when " \
                  "backdoor is already setup it will be \n" \
                  "hidden your specific process,unlimited your session in " \
                  "metasploit and transparent."
    INSTALL_COMMANDS = [
        "git clone https://github.com/Screetsec/Vegile.git",
        "cd Vegile && sudo chmod +x Vegile"
    ]
    RUN_COMMANDS = ["cd Vegile && sudo bash Vegile"]
    PROJECT_URL = "https://github.com/Screetsec/Vegile"

    def before_run(self):
        console.print(
            "[bold magenta]Vegile commands:[/]\n"
            "  Vegile -i / --inject [backdoor/rootkit]\n"
            "  Vegile -u / --unlimited [backdoor/rootkit]\n"
            "  Vegile -h / --help"
        )


class ChromeKeyLogger(HackingTool):
    TITLE = "Chrome Keylogger"
    SUPPORTED_OS = ["linux"]
    DESCRIPTION = "Hera Chrome Keylogger"
    INSTALL_COMMANDS = [
        "git clone https://github.com/UndeadSec/HeraKeylogger.git",
        "cd HeraKeylogger && sudo apt-get install python3-pip -y && sudo pip3 install -r requirements.txt"
    ]
    RUN_COMMANDS = ["cd HeraKeylogger && sudo python3 hera.py"]
    PROJECT_URL = "https://github.com/UndeadSec/HeraKeylogger"


class PwncatCS(HackingTool):
    TITLE = "pwncat-cs (Reverse Shell Handler)"
    DESCRIPTION = (
        "Post-exploitation platform — manages reverse/bind shells with automation.\n"
        "Handles file upload/download, persistence, privilege escalation.\n"
        "Usage: pwncat-cs -lp 4444"
    )
    SUPPORTED_OS = ["linux", "macos"]
    INSTALL_COMMANDS = ["pip install --user pwncat-cs"]
    RUN_COMMANDS = ["pwncat-cs --help"]
    PROJECT_URL = "https://github.com/calebstewart/pwncat"


class Sliver(HackingTool):
    TITLE = "Sliver (C2 Framework)"
    DESCRIPTION = "Cross-platform adversary emulation/red team C2 framework — mTLS, HTTP(S), DNS, WireGuard."
    INSTALL_COMMANDS = [
        "curl -sSf https://sliver.sh/install -o /tmp/sliver-install.sh",
        "sudo bash /tmp/sliver-install.sh",
    ]
    RUN_COMMANDS = ["sliver --help"]
    PROJECT_URL = "https://github.com/BishopFox/sliver"
    SUPPORTED_OS = ["linux", "macos"]


class Havoc(HackingTool):
    TITLE = "Havoc (C2 Framework)"
    DESCRIPTION = "Modern post-exploitation C2 framework with EDR evasion. Cobalt Strike alternative."
    SUPPORTED_OS = ["linux"]
    INSTALL_COMMANDS = [
        "git clone https://github.com/HavocFramework/Havoc.git",
        "cd Havoc && make",
    ]
    RUN_COMMANDS = ["cd Havoc && ./havoc --help"]
    PROJECT_URL = "https://github.com/HavocFramework/Havoc"
    SUPPORTED_OS = ["linux"]


class PEASSng(HackingTool):
    TITLE = "PEASS-ng — LinPEAS/WinPEAS (Priv Esc)"
    DESCRIPTION = "Privilege escalation enumeration scripts for Linux and Windows."
    INSTALL_COMMANDS = [
        "curl -sSL https://github.com/peass-ng/PEASS-ng/releases/latest/download/linpeas.sh -o linpeas.sh",
        "chmod +x linpeas.sh",
    ]
    RUN_COMMANDS = ["./linpeas.sh --help"]
    PROJECT_URL = "https://github.com/peass-ng/PEASS-ng"


class LigoloNg(HackingTool):
    TITLE = "Ligolo-ng (Tunneling/Pivoting)"
    DESCRIPTION = "Advanced tunneling/pivoting tool using TUN interfaces — no SOCKS needed."
    REQUIRES_GO = True
    INSTALL_COMMANDS = [
        "go install github.com/nicocha30/ligolo-ng@latest",
    ]
    RUN_COMMANDS = ["ligolo-ng --help"]
    PROJECT_URL = "https://github.com/nicocha30/ligolo-ng"
    SUPPORTED_OS = ["linux", "macos"]


class ChiselTunnel(HackingTool):
    TITLE = "Chisel (HTTP Tunnel)"
    DESCRIPTION = "Fast TCP/UDP tunnel over HTTP, secured via SSH — pivoting and port forwarding."
    REQUIRES_GO = True
    INSTALL_COMMANDS = [
        "go install github.com/jpillora/chisel@latest",
    ]
    RUN_COMMANDS = ["chisel --help"]
    PROJECT_URL = "https://github.com/jpillora/chisel"


class EvilWinRM(HackingTool):
    TITLE = "Evil-WinRM (Windows Remote Shell)"
    DESCRIPTION = "Ultimate WinRM shell for hacking/pentesting Windows machines."
    REQUIRES_RUBY = True
    INSTALL_COMMANDS = ["gem install evil-winrm"]
    RUN_COMMANDS = ["evil-winrm --help"]
    PROJECT_URL = "https://github.com/Hackplayers/evil-winrm"
    SUPPORTED_OS = ["linux"]


class Mythic(HackingTool):
    TITLE = "Mythic (C2 Platform)"
    DESCRIPTION = "Collaborative, multi-payload C2 platform designed for red team operations."
    REQUIRES_DOCKER = True
    INSTALL_COMMANDS = [
        "git clone https://github.com/its-a-feature/Mythic.git",
        "cd Mythic && sudo make",
    ]
    RUN_COMMANDS = ["cd Mythic && sudo ./mythic-cli start"]
    PROJECT_URL = "https://github.com/its-a-feature/Mythic"
    SUPPORTED_OS = ["linux"]


class PostExploitationTools(HackingToolsCollection):
    TITLE = "Post exploitation tools"
    TOOLS = [
        Vegile(),
        ChromeKeyLogger(),
        PwncatCS(),
        Sliver(),
        Havoc(),
        PEASSng(),
        LigoloNg(),
        ChiselTunnel(),
        EvilWinRM(),
        Mythic(),
    ]

if __name__ == "__main__":
    tools = PostExploitationTools()
    tools.show_options()
