Skip to content

Commit 39ac010

Browse files
author
LandGrey
committed
pydictor v 1.0
黑客字典生成工具 pydictor 1.0版本
1 parent 189cd96 commit 39ac010

14 files changed

+242
-0
lines changed

core/Base.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
# Build by LandGrey 2016-08-17
4+
#
5+
# build a common dictionary
6+
#
7+
8+
import os
9+
import time
10+
import string
11+
import itertools
12+
from lib.encode import *
13+
14+
operator = {'b64': base64_encode, 'md5': md5_encode, 'sha1': sha1_encode,
15+
'url': url_encode, 'sha256': sha256_encode,'sha512': sha512_encode}
16+
17+
18+
# get the dictionary type
19+
def getchars(typefalg):
20+
falg = str(typefalg)
21+
chars = []
22+
if falg == "d":
23+
chars = string.printable[:10]
24+
elif falg == "L":
25+
chars = string.printable[10:36]
26+
elif falg == "c":
27+
chars = string.printable[36:62]
28+
elif falg == "dL":
29+
chars = string.printable[:36]
30+
elif falg == "dc":
31+
chars = string.printable[:10]+string.printable[36:62]
32+
elif falg == "Lc":
33+
chars = string.printable[10:62]
34+
elif falg == "dLc":
35+
chars = string.printable[:62]
36+
return chars
37+
38+
39+
# create the dictionary files
40+
def get_base_dic(minlength, maxlength, objfalg, encodeflag, head, tail):
41+
count = 0
42+
storepath=os.path.join(os.getcwd(), "results", "[len_%s_%s]_[%s]_%s.txt" %
43+
(minlength, maxlength, str(time.strftime("%Y%m%d_%H.%M.%S", time.localtime(time.time()))), encodeflag))
44+
with open(storepath, "w") as f:
45+
for i in xrange(minlength, maxlength+1):
46+
for item in itertools.product(objfalg, repeat=i):
47+
if encodeflag == "":
48+
f.write(head+"".join(item)+tail+"\n")
49+
count += 1
50+
else:
51+
f.write(operator.get(encodeflag)(head+"".join(item)+tail)+"\n")
52+
count += 1
53+
print "[+] A total of %s lines" % str(count)
54+
print "[+] Store in %s " % storepath

core/Base.pyc

1.82 KB
Binary file not shown.

core/Chunk.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
# Build by: LandGrey 2016-08-17
4+
#
5+
# build a chunk multiplication dictionary
6+
#
7+
8+
import os
9+
import time
10+
import itertools
11+
from lib.encode import *
12+
13+
operator = {'b64': base64_encode, 'md5': md5_encode, 'sha1': sha1_encode,
14+
'url': url_encode, 'sha256': sha256_encode, 'sha512': sha512_encode}
15+
16+
17+
# create the dictionary files
18+
def get_chunk_dic(objfalg, encodeflag, head, tail):
19+
count = 0
20+
storepath = os.path.join(os.getcwd(), "results", "[Chunk]_[%s]_%s.txt" %
21+
(str(time.strftime("%Y%m%d_%H.%M.%S",time.localtime(time.time()))), encodeflag))
22+
with open(storepath, "w") as f:
23+
for item in itertools.permutations(objfalg, len(objfalg)):
24+
if encodeflag == "":
25+
f.write(head+"".join(item)+tail+"\n")
26+
count += 1
27+
else:
28+
f.write(operator.get(encodeflag)(head + "".join(item) + tail) + "\n")
29+
count += 1
30+
print "[+] A total of %s lines" % str(count)
31+
print "[+] Store in %s " % storepath

core/Chunk.pyc

1.21 KB
Binary file not shown.

core/__init__.py

Whitespace-only changes.

core/__init__.pyc

124 Bytes
Binary file not shown.

lib/__init__.py

Whitespace-only changes.

lib/__init__.pyc

123 Bytes
Binary file not shown.

lib/command.py

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
# Build by: LandGrey 2016-08-17
4+
#
5+
# Parse command line arguments
6+
#
7+
8+
import argparse
9+
import sys
10+
11+
12+
def parse_args():
13+
parser = argparse.ArgumentParser(prog='pydictor',
14+
formatter_class=argparse.RawTextHelpFormatter,
15+
description='*[+] A useful hacker dictionary builder. [+]*\n'
16+
' [+] Build by LandGrey\n',
17+
usage='pydictor.py [-t type] [-cc customchar] '
18+
'[-cm <str1> <str2> ...] [--len minlen maxlen] '
19+
'[--head Prefix] [--tail Suffix] '
20+
'[--encode <b64,md5,sha1,url,sha256,sha512>]')
21+
22+
parser.add_argument('-t', dest='type',choices=['d', 'L', 'c', 'dL', 'dc', 'Lc', 'dLc'],metavar='Type',default='',
23+
help='Choose from [d L c dL dc Lc dLc]'
24+
'\nd digital [0 - 9]'
25+
'\nL lowercase letters [a - z]'
26+
'\nc capital letters [A - Z]'
27+
'\ndL Mix d and L [0-9 a-z]'
28+
'\ndc Mix d and c [0-9 A-Z]'
29+
'\nLc Mix L and c [a-z A-Z]'
30+
'\ndLc Mix d, L and c [0-9 a-z A-Z]')
31+
32+
parser.add_argument('-cc', dest='customchar', metavar='Character', default='',
33+
help='Use [Custom Character] build the dictionary')
34+
35+
parser.add_argument('-cm', dest='chunk', metavar='Str', nargs='+', type=str, default='',
36+
help='Use the string [Chunk Multiplication] build the dictionary')
37+
38+
parser.add_argument('--len', dest='len', metavar=('Minlen','Maxlen'), nargs=2, type=int, default=(1, 4),
39+
help='Minimun Length Maximun Length (except head tail encode)\nDefault: min=1 max=4')
40+
41+
parser.add_argument('--head', dest='head', metavar='Prefix', type=str, default='',
42+
help='Add string head for the dictionary')
43+
44+
parser.add_argument('--tail', dest='tail', metavar='Suffix', type=str, default='',
45+
help='Add string tail for the dictionary')
46+
47+
parser.add_argument('--encode', dest='encode', metavar='Encode', default='',
48+
choices=['b64', 'md5', 'sha1', 'url', 'sha256', 'sha512'],
49+
help='Choose the form of encrytion'
50+
'\nb64 base64 encode'
51+
'\nmd5 md5 encryption'
52+
'\nsha1 sha1 encryption'
53+
'\nurl urlencode'
54+
'\nsha256 sha256 encrytion'
55+
'\nsha512 sha512 encrytion')
56+
57+
if len(sys.argv) == 1:
58+
sys.argv.append('-h')
59+
args = parser.parse_args()
60+
check_args(args)
61+
return args
62+
63+
64+
def check_args(args):
65+
if args.len[0] > args.len[1]:
66+
print '\n[+]Pydictor Build by LandGrey [+]\nMinimum length <= Maximum length'
67+
sys.exit()
68+
if len(args.chunk) > 11:
69+
print '\n[+]Pydictor Build by LandGrey [+]\nSorry, too much string chunks and space may be insufficient'
70+
sys.exit()
71+

lib/command.pyc

2.82 KB
Binary file not shown.

lib/encode.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
# Build by LandGrey 2016-08-17
4+
#
5+
# encode & encrypt the strings
6+
#
7+
8+
from urllib import quote
9+
from base64 import b64encode
10+
import hashlib
11+
12+
13+
def base64_encode(item):
14+
return b64encode(item)
15+
16+
17+
def md5_encode(item):
18+
return hashlib.md5(item).hexdigest()
19+
20+
21+
def sha1_encode(item):
22+
return hashlib.sha1(item).hexdigest()
23+
24+
25+
def url_encode(item):
26+
return quote(item)
27+
28+
29+
def sha256_encode(item):
30+
return hashlib.sha256(item).hexdigest()
31+
32+
33+
def sha512_encode(item):
34+
return hashlib.sha512(item).hexdigest()
35+

lib/encode.pyc

1.23 KB
Binary file not shown.

pydictor.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
# Build by: LandGrey 2016-08-17
4+
#
5+
# A useful hacker dictionary builder
6+
#
7+
8+
from core.Base import get_base_dic
9+
from core.Base import getchars
10+
from core.Chunk import get_chunk_dic
11+
from lib.command import parse_args
12+
13+
if __name__ == '__main__':
14+
args = parse_args()
15+
if args.type:
16+
get_base_dic(args.len[0], args.len[1], getchars(args.type), args.encode, args.head, args.tail)
17+
if args.customchar:
18+
get_base_dic(args.len[0], args.len[1], args.customchar, args.encode, args.head, args.tail)
19+
if args.chunk:
20+
chunk = []
21+
for item in args.chunk:
22+
if item != '':
23+
chunk.append(item)
24+
get_chunk_dic(chunk, args.encode, args.head, args.tail)
25+
26+
27+
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
abcABC123..
2+
abcABC.123.
3+
abc123ABC..
4+
abc123.ABC.
5+
abc.ABC123.
6+
abc.123ABC.
7+
ABCabc123..
8+
ABCabc.123.
9+
ABC123abc..
10+
ABC123.abc.
11+
ABC.abc123.
12+
ABC.123abc.
13+
123abcABC..
14+
123abc.ABC.
15+
123ABCabc..
16+
123ABC.abc.
17+
123.abcABC.
18+
123.ABCabc.
19+
.abcABC123.
20+
.abc123ABC.
21+
.ABCabc123.
22+
.ABC123abc.
23+
.123abcABC.
24+
.123ABCabc.

0 commit comments

Comments
 (0)