Multi-Threaded SSH Credential Auditor
An automated network utility designed to stress-test SSH password policies using concurrent threading loops.
Project Overview
The Multi-Threaded SSH Credential Auditor is a command-line administration tool used to audit the robustness of system access controls. By automating SSH login handshakes, it allows administrators to parse dictionary files and evaluate whether network nodes conform to complex password policies or remain vulnerable to basic credential-guessing tactics.
By combining session-handling classes with active thread locking, the tool maintains low overhead while executing multiple network handshakes concurrently.
Technical Architecture & Concurrency
To prevent the script from dropping packets, crashing local sockets, or triggering aggressive firewalls, the software flow is strictly managed using semaphores:
Key Engineering Principles
-
Bounded Semaphore Control: To manage thread lifecycles, the program establishes a
BoundedSemaphore(value=5)lock. This acts as a rate-limiting gatekeeper, ensuring that no more than 5 parallel connection loops are active simultaneously. -
State Handling & Recurrent Retries: Network timing fluctuations often cause false authentication errors. The script scans system exceptions for read timeouts (such as
read_nonblocking) and recursively schedules a retry after pausing, rather than raising a fatal program failure. - Graceful Termination Controls: The thread pool constantly references global flags. If a correct configuration is verified or connection timeout thresholds (exceeding 5 socket failures) are met, the queue halts execution to conserve system resources.
Key Python Implementation
Below is the modular execution block showing how the tool synchronizes thread launches and manages locks while iterating through a wordlist:
# Initiating connection pools and executing locked threads
fn = open(passwdFile, 'r')
for line in fn.readlines():
if Found:
print "[*] Exiting: Password Found"
exit(0)
if Fails > 5:
print "[!] Exiting: Too Many Socket Timeouts"
exit(0)
# Acquire a semaphore token before spawning a new thread
connection_lock.acquire()
password = line.strip('\r').strip('\n')
print "[-] Testing: " + str(password)
# Spawn and start thread execution
t = Thread(target=connect, args=(host, user, password, True))
t.start()
Defensive Remediation & Hardening
This audit script highlights the inherent weaknesses of password-based SSH authentication. To secure enterprise systems against high-speed automated credential validation, the following defensive strategies should be deployed:
- Enforce Key-Based Authentication: Disable password authentication entirely in
/etc/ssh/sshd_config(settingPasswordAuthentication no) and mandate the use of secure SSH cryptographic keypairs. - Deploy Rate-Limiting Utilities: Implement tools like Fail2ban to dynamically monitor secure access logs, automatically blocking IP addresses that display repeated authentication failures.
- Configure SSH Port Knocking or Bastion Hosts: Avoid exposing standard port 22 directly to the open internet. Implement multi-factor authentication gateways or private VPN structures to shield administrative layers from direct access.