Skip to content

Commit 88fc9a0

Browse files
committed
version 2.1.5.0 update
Add -pattern function
1 parent 3d2a07b commit 88fc9a0

File tree

8 files changed

+143
-49
lines changed

8 files changed

+143
-49
lines changed

README.md

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# pydictor
22

3-
[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.4.1-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg)
3+
[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.5.0-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg)
44

55

66
**README.md [中文版](README_CN.md)**
@@ -71,27 +71,28 @@ python pydictor.py
7171
#
7272
#### All of pydictor can generating wordlist
7373

74-
| type | wordlist | identifier | description | supported function |
75-
| :----: | :-------: | :--------: | :--------------------------------------- | :----------------- |
76-
| core | base | C1 | basic wordlist | F1 F2 F3 F4 |
77-
| core | char | C2 | custom character wordlist | F1 F2 F3 F4 |
78-
| core | chunk | C3 | permutation and combination wordlist | ALL |
79-
| core | conf | C4 | based on configuration file wordlist | ALL |
80-
| core | extend | C5 | extend wordlist based on rules | ALL |
81-
| core | sedb | C6 | social engineering wordlist | ALL |
82-
| tool | combiner | T1 | combine the specify directory files tool | |
83-
| tool | comparer | T2 | compare two file content difference tool | ALL |
84-
| tool | counter | T3 | word frequency count tool | ALL |
85-
| tool | handler | T4 | handle the input file tool | ALL |
86-
| tool | uniqbiner | T5 | combine and unique the directory files tool | ALL |
87-
| tool | uniqifer | T6 | unique the input file tool | ALL |
88-
| tool | hybrider | T7 | hybrid couples word list tool | F1 F2 F3 F4 |
74+
| type | wordlist | identifier | description | supported function |
75+
| :----: | :-------: | :--------: | :-------------------------------------------------- | :----------------- |
76+
| core | base | C1 | basic wordlist | F1 F2 F3 F4 |
77+
| core | char | C2 | custom character wordlist | F1 F2 F3 F4 |
78+
| core | chunk | C3 | permutation and combination wordlist | ALL |
79+
| core | conf | C4 | based on configuration file wordlist | ALL |
80+
| core | pattern | C5 | fastly generate pattern wordlist | F2 F3 F4 |
81+
| core | extend | C6 | extend wordlist based on rules | ALL |
82+
| core | sedb | C7 | social engineering wordlist | ALL |
83+
| tool | combiner | T1 | combine the specify directory files tool | |
84+
| tool | comparer | T2 | compare two file content difference tool | ALL |
85+
| tool | counter | T3 | word frequency count tool | ALL |
86+
| tool | handler | T4 | handle the input file tool | ALL |
87+
| tool | uniqbiner | T5 | combine and unique the directory files tool | ALL |
88+
| tool | uniqifer | T6 | unique the input file tool | ALL |
89+
| tool | hybrider | T7 | hybrid couples word list tool | F1 F2 F3 F4 |
8990
| plugin | birthday | P1 | birthday keyword wordlist in specify datetime scope | ALL |
90-
| plugin | ftp | P2 | against keyword generate ftp password wordlist | ALL |
91-
| plugin | pid4 | P3 | id card last 4 char wordlist | ALL |
92-
| plugin | pid6 | P4 | id card last 6 char wordlist | ALL |
93-
| plugin | pid8 | P5 | id card last 8 char wordlist | ALL |
94-
| plugin | scratch | P6 | wordlist based on web pages keywords | ALL |
91+
| plugin | ftp | P2 | against keyword generate ftp password wordlist | ALL |
92+
| plugin | pid4 | P3 | id card last 4 char wordlist | ALL |
93+
| plugin | pid6 | P4 | id card last 6 char wordlist | ALL |
94+
| plugin | pid8 | P5 | id card last 8 char wordlist | ALL |
95+
| plugin | scratch | P6 | wordlist based on web pages keywords | ALL |
9596

9697

9798
#### function code

README_CN.md

+23-22
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# pydictor
2-
[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.4.1-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg)
2+
[![build](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://www.github.com/landgrey/pydictor) [![Python 2.7&3.4](https://img.shields.io/badge/python-2.7&3.4-yellow.svg)](https://www.python.org/) ![release](https://img.shields.io/badge/version-2.1.5.0-orange.svg) ![License](https://img.shields.io/badge/license-GPLv3-red.svg)
33

44
**README.md [English](README.md)**
55

@@ -75,27 +75,28 @@ python pydictor.py
7575

7676
#### pydictor可以生成的所有字典的类型及其说明
7777

78-
| 归属 | 类别 | 标识符 | 描述 | 支持功能代号 |
79-
| :----: | :-------: | :--: | :------------- | :---------- |
80-
| core | base | C1 | 基础字典 | F1 F2 F3 F4 |
81-
| core | char | C2 | 自定义字符集字典 | F1 F2 F3 F4 |
82-
| core | chunk | C3 | 排列组合字典 | ALL |
83-
| core | conf | C4 | 配置语法生成字典 | ALL |
84-
| core | extend | C5 | 规则扩展字典 | ALL |
85-
| core | sedb | C6 | 社会工程学字典 | ALL |
86-
| tool | combiner | T1 | 字典合并工具 | |
87-
| tool | comparer | T2 | 字典比较相减工具 | ALL |
88-
| tool | counter | T3 | 词频统计工具 | ALL |
89-
| tool | handler | T4 | 筛选处理原有字典工具 | ALL |
90-
| tool | uniqbiner | T5 | 先合并后去重工具 | ALL |
91-
| tool | uniqifer | T6 | 字典去重工具 | ALL |
92-
| tool | hybrider | T7 | 多字典文件组合工具 | F1 F2 F3 F4 |
93-
| plugin | birthday | P1 | 生日日期字典插件 | ALL |
94-
| plugin | ftp | P2 | 关键词生成ftp密码字典插件 | ALL |
95-
| plugin | pid4 | P3 | 身份证后四位字典插件 | ALL |
96-
| plugin | pid6 | P4 | 身份证后六位字典插件 | ALL |
97-
| plugin | pid8 | P5 | 身份证后八位字典插件 | ALL |
98-
| plugin | scratch | P6 | 网页原始关键词字典插件 | ALL |
78+
| 归属 | 类别 | 标识符 | 描述 | 支持功能代号 |
79+
| :----: | :-------: | :----: | :------------------------ | :----------- |
80+
| core | base | C1 | 基础字典 | F1 F2 F3 F4 |
81+
| core | char | C2 | 自定义字符集字典 | F1 F2 F3 F4 |
82+
| core | chunk | C3 | 排列组合字典 | ALL |
83+
| core | conf | C4 | 配置语法生成字典 | ALL |
84+
| core | pattern | C5 | 模式字典快速生成 | F2 F3 F4 |
85+
| core | extend | C6 | 规则扩展字典 | ALL |
86+
| core | sedb | C7 | 社会工程学字典 | ALL |
87+
| tool | combiner | T1 | 字典合并工具 | |
88+
| tool | comparer | T2 | 字典比较相减工具 | ALL |
89+
| tool | counter | T3 | 词频统计工具 | ALL |
90+
| tool | handler | T4 | 筛选处理原有字典工具 | ALL |
91+
| tool | uniqbiner | T5 | 先合并后去重工具 | ALL |
92+
| tool | uniqifer | T6 | 字典去重工具 | ALL |
93+
| tool | hybrider | T7 | 多字典文件组合工具 | F1 F2 F3 F4 |
94+
| plugin | birthday | P1 | 生日日期字典插件 | ALL |
95+
| plugin | ftp | P2 | 关键词生成ftp密码字典插件 | ALL |
96+
| plugin | pid4 | P3 | 身份证后四位字典插件 | ALL |
97+
| plugin | pid6 | P4 | 身份证后六位字典插件 | ALL |
98+
| plugin | pid8 | P5 | 身份证后八位字典插件 | ALL |
99+
| plugin | scratch | P6 | 网页原始关键词字典插件 | ALL |
99100

100101
#### 字典操作功能及说明对照表
101102

core/PATTERN.py

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python
2+
# coding:utf-8
3+
#
4+
"""
5+
Copyright (c) 2016-2020 LandGrey (https://github.com/LandGrey/pydictor)
6+
License: GNU GENERAL PUBLIC LICENSE Version 3
7+
"""
8+
9+
from __future__ import unicode_literals
10+
11+
import operator
12+
import itertools
13+
import functools
14+
import traceback
15+
from core.CONF import get_conf_dic
16+
from lib.fun.filter import encode_filter
17+
from lib.data.data import pystrs, pyoptions
18+
from lib.fun.fun import finalsavepath, finishprinter, cool
19+
from lib.parse.confparse import elementparser, confmatcher
20+
21+
22+
def build_pattern_dic(source=""):
23+
buffer = []
24+
buffer_size = 512
25+
storepath = finalsavepath("pattern")
26+
pattern_set = patterncore(source)
27+
char_list = [sorted(set(i)) for i in pattern_set.values()]
28+
try:
29+
with open(storepath, "w") as f:
30+
for item in map("".join, itertools.product(*char_list)):
31+
item = pyoptions.head + item + pyoptions.tail
32+
buffer.append(item if pyoptions.encode == "none" else encode_filter(item, encode=pyoptions.encode))
33+
if len(buffer) == buffer_size:
34+
f.write(pyoptions.CRLF.join(buffer) + pyoptions.CRLF)
35+
buffer = []
36+
f.write(pyoptions.CRLF.join(buffer))
37+
finishprinter(storepath)
38+
except Exception as e:
39+
print(cool.red('[-] Exception as following:') + pyoptions.CRLF)
40+
print(traceback.print_exc())
41+
42+
43+
def patterncore(resource):
44+
pattern_set = {}
45+
46+
try:
47+
confdicts = elementparser(confmatcher(resource))
48+
except IndexError:
49+
confdicts = {}
50+
exit(cool.red("[-] parse element error, please check your parsing element"))
51+
finalen = len(confdicts[pystrs.conf_head])
52+
for x in range(0, finalen):
53+
# pattern_set_list = confdicts[pystrs.conf_char][x]
54+
# keep parsing head and tail
55+
pattern_set_list = get_conf_dic(int(confdicts[pystrs.conf_minlen][x]),
56+
int(confdicts[pystrs.conf_maxlen][x]),
57+
confdicts[pystrs.conf_char][x],
58+
confdicts[pystrs.conf_encode][x],
59+
confdicts[pystrs.conf_head][x],
60+
confdicts[pystrs.conf_tail][x])
61+
pattern_set[x] = "".join(pattern_set_list)
62+
count = functools.reduce(operator.mul, [len(i) for i in pattern_set.values()], 1)
63+
if count >= pyoptions.count_switcher:
64+
exit_msg = pyoptions.CRLF + cool.fuchsia("[!] Build items more than pyoptions.count_switcher: %s%s"
65+
"[!] Modify /lib/data/data.py count_switcher to adjust it" %
66+
(str(pyoptions.count_switcher), pyoptions.CRLF))
67+
exit(exit_msg)
68+
return pattern_set

docs/doc/usage.md

+14-2
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,25 @@ python pydictor.py --conf /my/other/awesome.conf
2525
python pydictor.py --conf "[0-9]{6,6}<none>[a-f,abc,123,!@#]{1,1}<none>" --encode md5 --output parsing.txt
2626
```
2727

28-
#### 5. 规则扩展字典
28+
#### 5. 模式字典快速生成
29+
30+
```
31+
# note that:
32+
# 1. using python3 is fast than python2
33+
# 2. one element only support single character, like: [***]{1,1}<***>
34+
35+
# generate pattern: abc[%d][%d][%l][%d][%d][%l][%d][%d]
36+
python3 pydictor.py --head abc --pattern "[0-9]{1,1}<none>[0-9]{1,1}<none>[a-z]{1,1}<none>[0-9]{1,1}<none>[0-9]{1,1}<none>[a-z]{1,1}<none>[0-9]{1,1}<none>[0-9]{1,1}<none>" -o output.txt
37+
```
38+
39+
#### 6. 规则扩展字典
40+
2941
```
3042
python pydictor.py -extend bob --level 4 --len 4 12
3143
python pydictor.py -extend liwei zwell.com --more --leet 0 1 2 11 21 --level 2 --len 6 16 --occur "<=10" ">0" "<=2" -o /possbile/wordlist.lst
3244
```
3345

34-
#### 6. 社会工程学字典
46+
#### 7. 社会工程学字典
3547
`python pydictor.py --sedb`
3648

3749
```

lib/data/data.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# coding:utf-8
33
#
44
"""
5-
Copyright (c) 2016-2019 LandGrey (https://github.com/LandGrey/pydictor)
5+
Copyright (c) 2016-2020 LandGrey (https://github.com/LandGrey/pydictor)
66
License: GNU GENERAL PUBLIC LICENSE Version 3
77
"""
88

@@ -56,7 +56,7 @@ def init_pystrs():
5656
# start time
5757
pystrs.startime = time.time()
5858

59-
pystrs.version = '2.1.4.1#dev'
59+
pystrs.version = '2.1.5.0#dev'
6060

6161
# build configuration file element description
6262
pystrs.conf_head = "head"
@@ -106,7 +106,7 @@ def init_pyoptions():
106106
pyoptions.maxlen_switcher = 20
107107

108108
# allowed maximum generated items
109-
pyoptions.count_switcher = 1000000000000
109+
pyoptions.count_switcher = 100000000000
110110

111111
# shredded file rewrite counts
112112
pyoptions.file_rewrite_count = 1

lib/parse/argsparse.py

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import os
1212
from lib.fun.fun import cool
1313
from core.CONF import build_conf_dic
14+
from core.PATTERN import build_pattern_dic
1415
from lib.data.data import paths, pyoptions
1516

1617

@@ -30,6 +31,10 @@ def conf_parser():
3031
build_conf_dic(source=paths.buildconf_path)
3132

3233

34+
def pattern_parser():
35+
build_pattern_dic(source=pyoptions.args_pattern)
36+
37+
3338
def tool_parser():
3439
if len(pyoptions.args_tool) >= 1:
3540
if pyoptions.args_tool[0] in pyoptions.tool_range:

lib/parse/command.py

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def parse_args():
2929
-extend [string_or_file]
3030
-plug [{plugin}]
3131
--conf [expression_or_file]
32+
--pattern [expression_or_file]
3233
--sedb
3334
-o,--output [directory]
3435
-tool [{tool}]
@@ -76,6 +77,9 @@ def parse_args():
7677
parser.add_argument('--conf', dest='conf', nargs='?', metavar='file_path', default='default', const='const',
7778
help=cool.yellow("Use the configuration string or file build the dictionary"))
7879

80+
parser.add_argument('--pattern', dest='pattern', nargs='?', metavar='file_path', default='default', const='const',
81+
help=cool.yellow("Use pattern string build the dictionary"))
82+
7983
parser.add_argument('--sedb', dest='sedb', default='', action="store_true",
8084
help=cool.yellow('Enter the Social Engineering Dictionary Builder'))
8185

pydictor.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from lib.data.data import paths, pyoptions
2020
from lib.data.text import pydictor_art_text
2121
from lib.fun.fun import cool
22-
from lib.parse.argsparse import plug_parser, conf_parser, tool_parser
22+
from lib.parse.argsparse import plug_parser, conf_parser, pattern_parser, tool_parser
2323
from lib.parse.command import parse_args
2424
from lib.parse.tricksparse import sedb_tricks
2525

@@ -80,6 +80,7 @@ def init():
8080
pyoptions.args_plug = args.plug
8181
pyoptions.args_sedb = args.sedb
8282
pyoptions.args_conf = args.conf
83+
pyoptions.args_pattern = args.pattern
8384
pyoptions.args_tool = args.tool
8485
pyoptions.level = args.level
8586

@@ -126,5 +127,7 @@ def init():
126127
exit(e)
127128
elif pyoptions.args_conf != 'default':
128129
conf_parser()
130+
elif pyoptions.args_pattern != 'default':
131+
pattern_parser()
129132
elif pyoptions.args_tool:
130133
tool_parser()

0 commit comments

Comments
 (0)