mirror of
https://github.com/calebstewart/pwncat.git
synced 2024-11-24 09:35:39 +01:00
Merge branch 'framework' of github.com:calebstewart/pwncat into framework
This commit is contained in:
commit
4067122ba9
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,3 +2,5 @@ env/
|
|||||||
**/*.pyc
|
**/*.pyc
|
||||||
**/__pycache__/
|
**/__pycache__/
|
||||||
**/*.egg-info/
|
**/*.egg-info/
|
||||||
|
build/
|
||||||
|
dist/
|
||||||
|
BIN
dist/pwncat-0.1-py2.7.egg
vendored
Normal file
BIN
dist/pwncat-0.1-py2.7.egg
vendored
Normal file
Binary file not shown.
@ -29,8 +29,8 @@ class PtyHandler:
|
|||||||
on the local end """
|
on the local end """
|
||||||
|
|
||||||
OPEN_METHODS = {
|
OPEN_METHODS = {
|
||||||
"script": "exec {} -qc /bin/sh /dev/null",
|
"script": "exec {} -qc /bin/bash /dev/null",
|
||||||
"python": "exec {} -c \"import pty; pty.spawn('/bin/sh')\"",
|
"python": "exec {} -c \"import pty; pty.spawn('/bin/bash')\"",
|
||||||
}
|
}
|
||||||
|
|
||||||
INTERESTING_BINARIES = [
|
INTERESTING_BINARIES = [
|
||||||
@ -115,9 +115,15 @@ class PtyHandler:
|
|||||||
raise RuntimeError("no available methods to spawn a pty!")
|
raise RuntimeError("no available methods to spawn a pty!")
|
||||||
|
|
||||||
# Open the PTY
|
# Open the PTY
|
||||||
|
|
||||||
util.info(f"opening pseudoterminal via {method}", overlay=True)
|
util.info(f"opening pseudoterminal via {method}", overlay=True)
|
||||||
client.sendall(method_cmd.encode("utf-8") + b"\n")
|
client.sendall(method_cmd.encode("utf-8") + b"\n")
|
||||||
|
|
||||||
|
util.info("setting terminal prompt", overlay=True)
|
||||||
|
client.sendall(b'export PS1="(remote) \\u@\\h\\$ "\r')
|
||||||
|
self.recvuntil(b"\r\n")
|
||||||
|
self.recvuntil(b"\r\n")
|
||||||
|
|
||||||
# Make sure HISTFILE is unset in this PTY (it resets when a pty is
|
# Make sure HISTFILE is unset in this PTY (it resets when a pty is
|
||||||
# opened)
|
# opened)
|
||||||
self.run("unset HISTFILE")
|
self.run("unset HISTFILE")
|
||||||
|
@ -3,7 +3,7 @@ from typing import Tuple, BinaryIO, Callable
|
|||||||
from http.server import BaseHTTPRequestHandler, HTTPServer
|
from http.server import BaseHTTPRequestHandler, HTTPServer
|
||||||
from socketserver import TCPServer, BaseRequestHandler
|
from socketserver import TCPServer, BaseRequestHandler
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from colorama import Fore
|
from colorama import Fore, Style
|
||||||
from io import TextIOWrapper
|
from io import TextIOWrapper
|
||||||
import socket
|
import socket
|
||||||
import threading
|
import threading
|
||||||
@ -121,7 +121,8 @@ def enter_raw_mode():
|
|||||||
returns: the old state of the terminal
|
returns: the old state of the terminal
|
||||||
"""
|
"""
|
||||||
|
|
||||||
info("setting terminal to raw mode and disabling echo")
|
info("setting terminal to raw mode and disabling echo", overlay=True)
|
||||||
|
success("pwncat is ready\n", overlay=True)
|
||||||
|
|
||||||
# Ensure we don't have any weird buffering issues
|
# Ensure we don't have any weird buffering issues
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
@ -162,7 +163,7 @@ def enter_raw_mode():
|
|||||||
def restore_terminal(state):
|
def restore_terminal(state):
|
||||||
""" restore the stdio state from the result of "enter_raw_mode" """
|
""" restore the stdio state from the result of "enter_raw_mode" """
|
||||||
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, state[0])
|
termios.tcsetattr(sys.stdin.fileno(), termios.TCSADRAIN, state[0])
|
||||||
tty.setcbreak(sys.stdin)
|
# tty.setcbreak(sys.stdin)
|
||||||
fcntl.fcntl(sys.stdin, fcntl.F_SETFL, state[1])
|
fcntl.fcntl(sys.stdin, fcntl.F_SETFL, state[1])
|
||||||
sys.stdout.write("\n")
|
sys.stdout.write("\n")
|
||||||
info("local terminal restored")
|
info("local terminal restored")
|
||||||
@ -268,10 +269,11 @@ def log(level, message, overlay=False):
|
|||||||
global LAST_PROG_ANIM
|
global LAST_PROG_ANIM
|
||||||
|
|
||||||
prefix = {
|
prefix = {
|
||||||
"info": f"[{Fore.BLUE}+{Fore.RESET}] ",
|
"info": f"[{Fore.BLUE}+{Fore.RESET}]",
|
||||||
"warn": f"[{Fore.YELLOW}?{Fore.RESET}] ",
|
"success": f"[{Fore.GREEN}+{Fore.RESET}]",
|
||||||
"error": f"[{Fore.RED}!{Fore.RESET}] ",
|
"warn": f"[{Fore.YELLOW}?{Fore.RESET}]",
|
||||||
"prog": f"[{Fore.CYAN}+{Fore.RESET}] ",
|
"error": f"[{Fore.RED}!{Fore.RESET}]",
|
||||||
|
"prog": f"[{Fore.CYAN}+{Fore.RESET}]",
|
||||||
}
|
}
|
||||||
|
|
||||||
if overlay:
|
if overlay:
|
||||||
@ -283,7 +285,10 @@ def log(level, message, overlay=False):
|
|||||||
LAST_PROG_ANIM = (LAST_PROG_ANIM + 1) % len(PROG_ANIMATION)
|
LAST_PROG_ANIM = (LAST_PROG_ANIM + 1) % len(PROG_ANIMATION)
|
||||||
prefix["prog"] = prefix["prog"].replace("+", PROG_ANIMATION[LAST_PROG_ANIM])
|
prefix["prog"] = prefix["prog"].replace("+", PROG_ANIMATION[LAST_PROG_ANIM])
|
||||||
|
|
||||||
LAST_LOG_MESSAGE = (f"{prefix[level]} {message}", overlay)
|
LAST_LOG_MESSAGE = (
|
||||||
|
f"{prefix[level]} {Style.DIM}{message}{Style.RESET_ALL}",
|
||||||
|
overlay,
|
||||||
|
)
|
||||||
sys.stdout.write(LAST_LOG_MESSAGE[0])
|
sys.stdout.write(LAST_LOG_MESSAGE[0])
|
||||||
|
|
||||||
if not overlay:
|
if not overlay:
|
||||||
@ -304,5 +309,9 @@ def error(message, overlay=False):
|
|||||||
log("error", message, overlay)
|
log("error", message, overlay)
|
||||||
|
|
||||||
|
|
||||||
|
def success(message, overlay=False):
|
||||||
|
log("success", message, overlay)
|
||||||
|
|
||||||
|
|
||||||
# def progress(message, overlay=False):
|
# def progress(message, overlay=False):
|
||||||
# log("prog", message, overlay)
|
# log("prog", message, overlay)
|
||||||
|
Loading…
Reference in New Issue
Block a user