bruteforcer ssh

These parts collectively implement a dictionary attack against an SSH server, attempting to gain unauthorized access by trying various username-password combinations from provided dictionaries.

Dictionary Attack

A dictionary attack is a type of brute force attack technique used to gain unauthorized access to a system or an account by systematically entering every word in a pre-existing list (dictionary) of possible passwords. Instead of trying every possible combination of characters, as in a traditional brute force attack, a dictionary attack relies on trying a set of likely passwords derived from commonly used passwords, words from dictionaries, and other sources.

Explanation of Code Parts:

  1. Reading Command Line Arguments (read_args function):

    • This part of the code reads the command-line arguments provided when executing the script. It parses the arguments to extract options like IP address, TCP port, slow down factor, paths to password and username files, and handles displaying version and help information.

  2. Checking Arguments (check_args function):

    • This section validates the provided arguments to ensure they are correct and appropriate for the dictionary attack.

    • It verifies the existence of necessary utilities like sshpass and checks the validity of IP address, TCP port, and provided file paths.

    • Additionally, it checks if SSH connection can be established using default credentials, and if password authentication is enabled for the provided usernames.

  3. Launching the Attack (launch_attack function):

    • This part initiates the dictionary attack by iterating over each username and password combination.

    • For each username, it iterates through the list of passwords, attempting to authenticate using SSH with the provided credentials.

    • It spawns parallel SSH sessions to speed up the attack, trying multiple password attempts simultaneously.

  4. Handling Signals (monitor_signal function):

    • This section sets up signal handlers to trap signals like SIGHUP, SIGTERM, SIGQUIT, SIGINT, and SIGTSTP.

    • It ensures that when the script is terminated or interrupted, it kills any ongoing SSH processes spawned during the attack.

Display:

Last updated