-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrute_shadow.py
More file actions
52 lines (41 loc) · 1.25 KB
/
brute_shadow.py
File metadata and controls
52 lines (41 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#! /usr/bin/env python
#-*- coding: utf-8 -*-
import os
import hashlib
import crypt
import click
def openfile(filename):
if filename == None:
print "please input all the file or --help \n"
exit(0)
if not os.path.isfile(filename):
print '[-] ' + filename + ' does not exist!'
exit(0)
if not os.access(filename,os.R_OK):
print '[-] ' + filename + ' access denied!'
exit(0)
def splitpass(passstr):
n = passstr.find('$',3)
return n+1
def crack(dic,shadow):
print "======================================= "
openfile(dic)
openfile(shadow)
for line in open(shadow):
if ('*' not in line) and ('!' not in line):
shadowline = line.split(':',2)
username = shadowline[0]
password = shadowline[1]
salt = password[0:splitpass(password)]
for dicwords in open(dic):
dicwords = dicwords.strip()
print "[-] username:" + username + " password:"+dicwords
if crypt.crypt(dicwords,salt) == password:
print "[+] username:" + username + " password:"+dicwords + " has been cracked"
@click.command()
@click.option('--path','-p', help='path of dic')
@click.option('--shadow','-s', help='path of shadow')
def GetPath(path,shadow):
crack(path,shadow)
if __name__ == '__main__':
GetPath()