-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
黑客字典生成工具 pydictor 1.0版本
- Loading branch information
LandGrey
committed
Aug 17, 2016
1 parent
189cd96
commit 39ac010
Showing
14 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/env python | ||
# coding:utf-8 | ||
# Build by LandGrey 2016-08-17 | ||
# | ||
# build a common dictionary | ||
# | ||
|
||
import os | ||
import time | ||
import string | ||
import itertools | ||
from lib.encode import * | ||
|
||
operator = {'b64': base64_encode, 'md5': md5_encode, 'sha1': sha1_encode, | ||
'url': url_encode, 'sha256': sha256_encode,'sha512': sha512_encode} | ||
|
||
|
||
# get the dictionary type | ||
def getchars(typefalg): | ||
falg = str(typefalg) | ||
chars = [] | ||
if falg == "d": | ||
chars = string.printable[:10] | ||
elif falg == "L": | ||
chars = string.printable[10:36] | ||
elif falg == "c": | ||
chars = string.printable[36:62] | ||
elif falg == "dL": | ||
chars = string.printable[:36] | ||
elif falg == "dc": | ||
chars = string.printable[:10]+string.printable[36:62] | ||
elif falg == "Lc": | ||
chars = string.printable[10:62] | ||
elif falg == "dLc": | ||
chars = string.printable[:62] | ||
return chars | ||
|
||
|
||
# create the dictionary files | ||
def get_base_dic(minlength, maxlength, objfalg, encodeflag, head, tail): | ||
count = 0 | ||
storepath=os.path.join(os.getcwd(), "results", "[len_%s_%s]_[%s]_%s.txt" % | ||
(minlength, maxlength, str(time.strftime("%Y%m%d_%H.%M.%S", time.localtime(time.time()))), encodeflag)) | ||
with open(storepath, "w") as f: | ||
for i in xrange(minlength, maxlength+1): | ||
for item in itertools.product(objfalg, repeat=i): | ||
if encodeflag == "": | ||
f.write(head+"".join(item)+tail+"\n") | ||
count += 1 | ||
else: | ||
f.write(operator.get(encodeflag)(head+"".join(item)+tail)+"\n") | ||
count += 1 | ||
print "[+] A total of %s lines" % str(count) | ||
print "[+] Store in %s " % storepath |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env python | ||
# coding:utf-8 | ||
# Build by: LandGrey 2016-08-17 | ||
# | ||
# build a chunk multiplication dictionary | ||
# | ||
|
||
import os | ||
import time | ||
import itertools | ||
from lib.encode import * | ||
|
||
operator = {'b64': base64_encode, 'md5': md5_encode, 'sha1': sha1_encode, | ||
'url': url_encode, 'sha256': sha256_encode, 'sha512': sha512_encode} | ||
|
||
|
||
# create the dictionary files | ||
def get_chunk_dic(objfalg, encodeflag, head, tail): | ||
count = 0 | ||
storepath = os.path.join(os.getcwd(), "results", "[Chunk]_[%s]_%s.txt" % | ||
(str(time.strftime("%Y%m%d_%H.%M.%S",time.localtime(time.time()))), encodeflag)) | ||
with open(storepath, "w") as f: | ||
for item in itertools.permutations(objfalg, len(objfalg)): | ||
if encodeflag == "": | ||
f.write(head+"".join(item)+tail+"\n") | ||
count += 1 | ||
else: | ||
f.write(operator.get(encodeflag)(head + "".join(item) + tail) + "\n") | ||
count += 1 | ||
print "[+] A total of %s lines" % str(count) | ||
print "[+] Store in %s " % storepath |
Binary file not shown.
Empty file.
Binary file not shown.
Empty file.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#!/usr/bin/env python | ||
# coding:utf-8 | ||
# Build by: LandGrey 2016-08-17 | ||
# | ||
# Parse command line arguments | ||
# | ||
|
||
import argparse | ||
import sys | ||
|
||
|
||
def parse_args(): | ||
parser = argparse.ArgumentParser(prog='pydictor', | ||
formatter_class=argparse.RawTextHelpFormatter, | ||
description='*[+] A useful hacker dictionary builder. [+]*\n' | ||
' [+] Build by LandGrey\n', | ||
usage='pydictor.py [-t type] [-cc customchar] ' | ||
'[-cm <str1> <str2> ...] [--len minlen maxlen] ' | ||
'[--head Prefix] [--tail Suffix] ' | ||
'[--encode <b64,md5,sha1,url,sha256,sha512>]') | ||
|
||
parser.add_argument('-t', dest='type',choices=['d', 'L', 'c', 'dL', 'dc', 'Lc', 'dLc'],metavar='Type',default='', | ||
help='Choose from [d L c dL dc Lc dLc]' | ||
'\nd digital [0 - 9]' | ||
'\nL lowercase letters [a - z]' | ||
'\nc capital letters [A - Z]' | ||
'\ndL Mix d and L [0-9 a-z]' | ||
'\ndc Mix d and c [0-9 A-Z]' | ||
'\nLc Mix L and c [a-z A-Z]' | ||
'\ndLc Mix d, L and c [0-9 a-z A-Z]') | ||
|
||
parser.add_argument('-cc', dest='customchar', metavar='Character', default='', | ||
help='Use [Custom Character] build the dictionary') | ||
|
||
parser.add_argument('-cm', dest='chunk', metavar='Str', nargs='+', type=str, default='', | ||
help='Use the string [Chunk Multiplication] build the dictionary') | ||
|
||
parser.add_argument('--len', dest='len', metavar=('Minlen','Maxlen'), nargs=2, type=int, default=(1, 4), | ||
help='Minimun Length Maximun Length (except head tail encode)\nDefault: min=1 max=4') | ||
|
||
parser.add_argument('--head', dest='head', metavar='Prefix', type=str, default='', | ||
help='Add string head for the dictionary') | ||
|
||
parser.add_argument('--tail', dest='tail', metavar='Suffix', type=str, default='', | ||
help='Add string tail for the dictionary') | ||
|
||
parser.add_argument('--encode', dest='encode', metavar='Encode', default='', | ||
choices=['b64', 'md5', 'sha1', 'url', 'sha256', 'sha512'], | ||
help='Choose the form of encrytion' | ||
'\nb64 base64 encode' | ||
'\nmd5 md5 encryption' | ||
'\nsha1 sha1 encryption' | ||
'\nurl urlencode' | ||
'\nsha256 sha256 encrytion' | ||
'\nsha512 sha512 encrytion') | ||
|
||
if len(sys.argv) == 1: | ||
sys.argv.append('-h') | ||
args = parser.parse_args() | ||
check_args(args) | ||
return args | ||
|
||
|
||
def check_args(args): | ||
if args.len[0] > args.len[1]: | ||
print '\n[+]Pydictor Build by LandGrey [+]\nMinimum length <= Maximum length' | ||
sys.exit() | ||
if len(args.chunk) > 11: | ||
print '\n[+]Pydictor Build by LandGrey [+]\nSorry, too much string chunks and space may be insufficient' | ||
sys.exit() | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#!/usr/bin/env python | ||
# coding:utf-8 | ||
# Build by LandGrey 2016-08-17 | ||
# | ||
# encode & encrypt the strings | ||
# | ||
|
||
from urllib import quote | ||
from base64 import b64encode | ||
import hashlib | ||
|
||
|
||
def base64_encode(item): | ||
return b64encode(item) | ||
|
||
|
||
def md5_encode(item): | ||
return hashlib.md5(item).hexdigest() | ||
|
||
|
||
def sha1_encode(item): | ||
return hashlib.sha1(item).hexdigest() | ||
|
||
|
||
def url_encode(item): | ||
return quote(item) | ||
|
||
|
||
def sha256_encode(item): | ||
return hashlib.sha256(item).hexdigest() | ||
|
||
|
||
def sha512_encode(item): | ||
return hashlib.sha512(item).hexdigest() | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#!/usr/bin/env python | ||
# coding:utf-8 | ||
# Build by: LandGrey 2016-08-17 | ||
# | ||
# A useful hacker dictionary builder | ||
# | ||
|
||
from core.Base import get_base_dic | ||
from core.Base import getchars | ||
from core.Chunk import get_chunk_dic | ||
from lib.command import parse_args | ||
|
||
if __name__ == '__main__': | ||
args = parse_args() | ||
if args.type: | ||
get_base_dic(args.len[0], args.len[1], getchars(args.type), args.encode, args.head, args.tail) | ||
if args.customchar: | ||
get_base_dic(args.len[0], args.len[1], args.customchar, args.encode, args.head, args.tail) | ||
if args.chunk: | ||
chunk = [] | ||
for item in args.chunk: | ||
if item != '': | ||
chunk.append(item) | ||
get_chunk_dic(chunk, args.encode, args.head, args.tail) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
abcABC123.. | ||
abcABC.123. | ||
abc123ABC.. | ||
abc123.ABC. | ||
abc.ABC123. | ||
abc.123ABC. | ||
ABCabc123.. | ||
ABCabc.123. | ||
ABC123abc.. | ||
ABC123.abc. | ||
ABC.abc123. | ||
ABC.123abc. | ||
123abcABC.. | ||
123abc.ABC. | ||
123ABCabc.. | ||
123ABC.abc. | ||
123.abcABC. | ||
123.ABCabc. | ||
.abcABC123. | ||
.abc123ABC. | ||
.ABCabc123. | ||
.ABC123abc. | ||
.123abcABC. | ||
.123ABCabc. |