Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
优化
  • Loading branch information
LandGrey committed Nov 30, 2016
1 parent ba1b74f commit 6e81ede
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 56 deletions.
37 changes: 22 additions & 15 deletions core/Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,50 @@
# This is a part of pydictor


import os
import time
import string
import itertools
from lib.encode import *
from lib.data import *

operator = {'b64': base64_encode, 'md5': md5_encode, 'md516': md5_16_encode, 'sha1': sha1_encode,
'url': url_encode, 'sha256': sha256_encode, 'sha512': sha512_encode}

# dictionary type
description = " "

# get the dictionary type

# get the dictionary list
def getchars(typeflag):
global description
falg = str(typeflag)
chars = []
if falg == "d":
chars = string.printable[:10]
chars = string.digits
description = 'digits'
elif falg == "L":
chars = string.printable[10:36]
chars = string.lowercase
description = 'lowercase'
elif falg == "c":
chars = string.printable[36:62]
chars = string.uppercase
description = 'uppercase'
elif falg == "dL":
chars = string.printable[:36]
description = 'digits_lowercase'
elif falg == "dc":
chars = string.printable[:10]+string.printable[36:62]
chars = string.digits + string.uppercase
description = 'digits_uppercase'
elif falg == "Lc":
chars = string.printable[10:62]
chars = string.letters
description = 'letters'
elif falg == "dLc":
chars = string.printable[:62]
description = 'digits_letters'
return chars


# create the dictionary files
def get_base_dic(minlength, maxlength, objflag, encodeflag, head, tail):
global description
count = 0
storepath=os.path.join(os.getcwd(), "results", "%s_%s_%s_%s.txt" %
(minlength, maxlength, str(time.strftime("%Y%m%d_%H.%M.%S", time.localtime(time.time()))), encodeflag))
storepath=os.path.join(resultstorepath, "%s_%s_%s_%s_%s.txt" %
(minlength, maxlength, description, buildtime, encodeflag))
with open(storepath, "w") as f:
for i in xrange(minlength, maxlength+1):
for item in itertools.product(objflag, repeat=i):
Expand All @@ -52,5 +60,4 @@ def get_base_dic(minlength, maxlength, objflag, encodeflag, head, tail):
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
finishprint(count, storepath)
14 changes: 4 additions & 10 deletions core/Chunk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,15 @@
# This is a part of pydictor


import os
import time
import itertools
from lib.encode import *

operator = {'b64': base64_encode, 'md5': md5_encode, 'md516': md5_16_encode, 'sha1': sha1_encode,
'url': url_encode, 'sha256': sha256_encode, 'sha512': sha512_encode}
from lib.data import *


# create the dictionary files
def get_chunk_dic(objflag, 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))
storepath = os.path.join(resultstorepath, "Chunk_%s_%s.txt" %
(buildtime, encodeflag))
with open(storepath, "w") as f:
for item in itertools.permutations(objflag, len(objflag)):
if encodeflag == "":
Expand All @@ -29,5 +24,4 @@ def get_chunk_dic(objflag, encodeflag, head, tail):
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
finishprint(count, storepath)
10 changes: 4 additions & 6 deletions core/SEDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@
# This is a part of pydictor


import os
import sys
import cmd
import time
sys.path.append('..')
from lib.text import *
from lib.data import *
from rules.CBrule import CBrule
from rules.EBrule import EBrule
from rules.SBrule import SBrule
Expand All @@ -35,7 +34,7 @@ def do_EOF(self):
def do_help(self, key):
if key in help_dict.keys():
print help_dict[key]
elif key == 'all':
elif key == 'desc':
for k in help_dict.keys():
print help_dict[k]
else:
Expand Down Expand Up @@ -134,7 +133,7 @@ def do_show(self, key):

def do_run(self, args):
count = 0
storepath = os.path.join(os.getcwd(), "results", 'SEDB_%s.txt' % str(time.strftime("%Y%m%d_%H.%M.%S", time.localtime(time.time()))))
storepath = os.path.join(resultstorepath, 'SEDB_%s.txt' % buildtime)
with open(storepath, 'w') as f:
# SingleRule
for single in SingleRule(settings_dict['cname'], settings_dict['ename'], settings_dict['sname'],
Expand All @@ -160,8 +159,7 @@ def do_run(self, args):
for weakpwd in weak_pass_set:
f.write(weakpwd + '\n')
count += 1
print "[+] A total of %s lines" % str(count)
print "[+] Store in %s " % storepath
finishprint(count, storepath)



Expand Down
8 changes: 4 additions & 4 deletions lib/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ def parse_args():
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='',
parser.add_argument('-cm', dest='chunk', metavar='Chunk', nargs='+', type=str, default='',
help='Use the string [Chunk Multiplication] build the dictionary')

parser.add_argument('-p', dest='plugins', choices=['pid6', 'pid8'],
metavar='plug', type=str, default='',
metavar='Plug', type=str, default='',
help='Choose from [pid6 pid8]'
'\npid6 [Id Card post 6 num] sex[m:male f:female] default:all'
'\npid8 [Id Card post 8 num] sex[m:male f:female] default:all')
Expand All @@ -70,8 +70,8 @@ def parse_args():
choices=['b64', 'md5', 'md516', 'sha1', 'url', 'sha256', 'sha512'],
help='Choose the form of encrytion'
'\nb64 base64 encode'
'\nmd5 md5 encryption (32 bit)'
'\nmd516 md5 encryption (16 bit)'
'\nmd5 md5 encryption (32)'
'\nmd516 md5 encryption (16)'
'\nsha1 sha1 encryption'
'\nurl urlencode'
'\nsha256 sha256 encrytion'
Expand Down
28 changes: 28 additions & 0 deletions lib/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/usr/bin/env python
# coding:utf-8
# Build by: LandGrey 2016-11-30
#
# store some common public data or simple function for others import
#
# This is a part of pydictor

import os
import sys
import time
from lib.encode import *

# results store path
resultstorepath = os. path.join(os.path.abspath(os.path.dirname(sys.argv[0])), "results")

# format the time of build the dictionary
buildtime = str(time.strftime("%Y%m%d_%H.%M.%S", time.localtime(time.time())))

# encode operator
operator = {'b64': base64_encode, 'md5': md5_encode, 'md516': md5_16_encode, 'sha1': sha1_encode,
'url': url_encode, 'sha256': sha256_encode, 'sha512': sha512_encode}


# finish print
def finishprint(count, storepath):
print "[+] A total of %s lines" % str(count) + "\n" +\
"[+] Store in %s " % storepath
16 changes: 9 additions & 7 deletions lib/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,27 @@
# coding:utf-8
# Build by: LandGrey 2016-08-25
#
# store text for others import
# store text for SEDB import
#
# This is a part of pydictor


from collections import OrderedDict

helpmsg = " Social Engineering Dictionary Builder\n" \
helpmsg = " Social Engineering Dictionary Builder\n" \
" Build by LandGrey\n"\
"----------------------------------[ command ]------------------------------------\n"\
"[+]help [all] (View help message) | [+]show [setting](Show current settings)\n"\
"[+]help desc (View the description) | [+]show setting (Show current settings)\n"\
"[+]cls/clear (Clean the screen) | [+]quit/exit (Quit the progress)\n"\
"[+]run (Build the dictionary) |\n"\
"Usage Exp :show (Show all of settings) | help settings (View all of setings help)\n"\
"----------------------------------[ settings ]------------------------------------\n"\
" | \n"\
"Usage Exp :show (Show all of settings) | help [setting] (Show selected setting)\n\n\n"\
"-------------------------------[ setting options ]--------------------------------\n"\
"[+]cname [+]ename [+]sname | [+]birth [+]usedpwd [+]phone \n"\
"[+]uphone [+]hphone [+]email | [+]postcode [+]nickname [+]idcard \n"\
"[+]jobnum [+]otherdate [+]usedchar | \n"\
"Usage Exp :nickname zwell zhangs zsan | *Each setting supports multiple values"
"[+]jobnum [+]otherdate [+]usedchar | \n" \
" |\n"\
"Usage Exp :nickname zwell zhangs zsan | * Each setting supports multiple values\n"

settings_dict = OrderedDict([
('cname', []), ('ename', []), ('sname', []), ('birth', []),
Expand Down
18 changes: 5 additions & 13 deletions plugins/IdCardPost.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,17 @@
# coding:utf-8
# Build by: LandGrey 2016-11-27
#
# Chinese identity card post 6 numbers build plugins
# Chinese identity card post 6/8 numbers build plugins base on sex
#
# format: 2:[birthday] 2:[random]
# This is a part of pydictor

import os
import time
from lib.encode import *

operator = {'b64': base64_encode, 'md5': md5_encode, 'md516': md5_16_encode, 'sha1': sha1_encode,
'url': url_encode, 'sha256': sha256_encode, 'sha512': sha512_encode}
from lib.data import *


def getIDCardPost(posflag, encodeflag, head, tail, sex):
count = 0
storepath = os.path.join(os.getcwd(), "results", "IdCardPost%s_%s_%s.txt" %
(str(posflag)[-1:], str(time.strftime("%Y%m%d_%H.%M.%S", time.localtime(time.time()))), encodeflag))
storepath = os.path.join(resultstorepath, "IdCardPost%s_%s_%s.txt" %
(str(posflag)[-1:], buildtime, encodeflag))
posrule = lambda _: str(_) if _ >= 10 else "0" + str(_)
# month
value1112 = " ".join(posrule(x) for x in xrange(1, 13))
Expand Down Expand Up @@ -66,7 +60,5 @@ def getIDCardPost(posflag, encodeflag, head, tail, sex):
else:
f.write(operator.get(encodeflag)(head + v1314 + v1516 + v1718 + tail) + "\n")
count += 1

print "[+] A total of %s lines" % str(count)
print "[+] Store in %s " % storepath
finishprint(count, storepath)

2 changes: 1 addition & 1 deletion rules/WeakPass.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

# other specail passwords
special_pass = [
'3.1415926', '3_1415926', 'p3.1415926', 'p_3.1415926'
'3.1415926', '3_1415926'
]

joinall = top_20_kb + other_char_kb + usual_weak_pass + worst_25_pass + ITpass + special_pass
Expand Down

0 comments on commit 6e81ede

Please sign in to comment.