-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathghostshell.py
More file actions
86 lines (76 loc) · 3.21 KB
/
ghostshell.py
File metadata and controls
86 lines (76 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
"""
👻 GhostShell — Operate a remote SSH tmux session invisibly via local Python.
Designed for seamless use with Amazon Q.
Author: Suren's Creations © 2025
"""
import subprocess
from pathlib import Path
from time import sleep
from rich.console import Console
from rich.panel import Panel
from rich.text import Text
from rich.align import Align
from rich import box
# === CONFIGURATION === #
SESSION_NAME = "q_0878ae1c"
MIRROR_LOG = Path("/tmp/ghostshell_output.log")
MIRROR_LOG.parent.mkdir(parents=True, exist_ok=True)
console = Console()
# === CORE === #
def ghost_send(cmd: str):
"""
Sends a command to the remote SSH session via tmux.
"""
subprocess.run(["tmux", "send-keys", "-t", SESSION_NAME, cmd, "C-m"])
timestamp = Text(f"[$] {cmd}", style="bold cyan")
console.print(timestamp)
def ghost_read(lines: int = 20):
"""
Reads the latest N lines from the mirrored tmux log.
"""
if not MIRROR_LOG.exists():
console.print("[bold red]Mirror log not found. Is mirroring enabled?")
return
with open(MIRROR_LOG, "r") as f:
output = f.readlines()[-lines:]
panel = Panel("".join(output), title="[bold green]GhostShell Output", border_style="magenta")
console.print(panel)
def enable_mirroring():
"""
Enables tmux output mirroring into a log file.
"""
subprocess.run([
"tmux", "pipe-pane", "-t", SESSION_NAME,
"-o", f"cat >> {MIRROR_LOG}"
])
console.print("[bold green]🪞 Output mirroring enabled.")
def ghost_banner():
art = Text("""
▄████████ ▄████████ ▄████████ ▄█ ▄████████
███ ███ ███ ███ ███ ███ ███ ███ ███
███ █▀ ███ █▀ ███ █▀ ███▌ ███ █▀
▄███▄▄▄ ███ ▄███▄▄▄ ███▌ ███
▀▀███▀▀▀ ▀███████████ ▀▀███▀▀▀ ███▌ ▀███████████
███ █▄ ███ ███ █▄ ███ ███
███ ███ ▄█ ███ ███ ███ ███ ▄█ ███
██████████ ▄████████▀ ██████████ █▀ ▄████████▀
""", style="bold bright_cyan")
subtitle = Text("Suren's Creations © 2025", style="bright_yellow")
panel = Panel(Align.center(art), subtitle=subtitle, border_style="bright_magenta", box=box.ROUNDED)
console.print(panel)
def ghost_loop():
ghost_banner()
console.print(Panel("[bold magenta]Welcome to GhostShell", subtitle="Type 'exit' to leave.", style="bold magenta", box=box.HEAVY))
while True:
try:
cmd = console.input("[bold bright_magenta]GHOST >> [/] ").strip()
if cmd.lower() == "exit":
break
ghost_send(cmd)
sleep(1.2)
ghost_read()
except KeyboardInterrupt:
break
if __name__ == "__main__":
enable_mirroring()
ghost_loop()