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