Skip to content

Commit

Permalink
support installed by pip
Browse files Browse the repository at this point in the history
  • Loading branch information
tp7309 committed Jun 1, 2017
1 parent 80c3ca8 commit af55dad
Show file tree
Hide file tree
Showing 10 changed files with 213 additions and 18 deletions.
File renamed without changes.
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
include README.rst
include LICENSE
recursive-include tests *
80 changes: 78 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,78 @@
# TTPassGen
A highly flexiable and scriptable password dictionary generator that can support brute-force、combination、complex rule mode etc...
#TTPassGen
TTPassGen is a highly flexiable and scriptable password dictionary generator base on Python, you can easily use various rules to generate the desired combination of words.

#Features
- generate password use combination、permulation、conditional rules and so on.
- support all characters or words(from wordlist file) that can make up a password, some built-in charset has been provided, such as alphabetical lists and numeric lists.
- you can specify the order and frequency of each element in the word.
- simple rule format, and easy to use, rule could be defined similar some regex's style.
- time-consuming estimates, output size estimates, and real-time progress reports.
- unicode word support by using wordlist file as input.
- Generation of large amounts of passwords at once, no size limit.
- it can breakup output by file size.

#Install
`TTPassGen` can be easily installed using pip:
```
pip install ttpassgen
```

#Requirements
Python 2 (version 2.7 or later), or Python 3 (version 3.2 or later).

#Quick Start
> Switch to the project's `src` directory if you downloaded the source code.
Example: Generate word list output to file, the word format is prefix three digits, range 123, appear 2 to 3 times, followed by letter a or b.
```
ttpassgen -r [123]{2:3}[ab] out.dict
```
Done.

#Options
```
C:\Users\tp730>ttpassgen --help
Usage: ttpassgen [OPTIONS] OUTPUT
Options:
-m, --mode INTEGER generation mode:
0 = combination rule mode
[default: 0]
-d, --dictlist TEXT read wordlist from the file, multi files
should by seperated by comma.
-r, --rule TEXT define word format, {0} means refer first
file in wordlist, some built-in charsets:
?l
= abcdefghijklmnopqrstuvwxyz
?u =
ABCDEFGHIJKLMNOPQRSTUVWXYZ
?d = 0123456789
?s
= !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
?a =
?l?u?d?s
?q = ]
example: [?dA]{1:2}{0}
view
documentation for more information.
[default: ]
-c, --dict_cache INTEGER each element in 'dictlist' option represents
a dict file path, this option define the
maximum amount of memory(MB) that can be used
when reading their contents.increasing the
cache may speed up the build when input dict
files is huge. [default: 500]
-g, --global_repeat_mode TEXT whether the character is allowd to repeat:
?
= 0 or 1 repetitions
* = 0 or more
repetitions [default: ?]
-p, --part_size INTEGER when result data is huge, split package
size(MB) will be applied, 0 is unlimited.
[default: 0]
--help Show this message and exit.
```


100 changes: 100 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
TTPassGen
=========

TTPassGen is a highly flexiable and scriptable password dictionary
generator base on Python, you can easily use various rules to generate
the desired combination of words.

Features
========

- generate password use combination、permulation、conditional rules and
so on.
- support all characters or words(from wordlist file) that can make up
a password, some built-in charset has been provided, such as
alphabetical lists and numeric lists.
- you can specify the order and frequency of each element in the word.
- simple rule format, and easy to use, rule could be defined similar
some regex's style.
- time-consuming estimates, output size estimates, and real-time
progress reports.
- unicode word support by using wordlist file as input.
- Generation of large amounts of passwords at once, no size limit.
- it can breakup output by file size.

Install
=======

``TTPassGen`` can be easily installed using pip:

::

pip install ttpassgen

Requirements
============

Python 2 (version 2.7 or later), or Python 3 (version 3.2 or later).

Quick Start
===========

Switch to the project's ``src`` directory if you downloaded the
source code. Example: Generate word list output to file, the word
format is prefix three digits, range 123, appear 2 to 3 times,
followed by letter a or b.

::

ttpassgen -r [123]{2:3}[ab] out.dict

Done.

Options
=======

::

C:\Users\tp730>ttpassgen --help
Usage: ttpassgen [OPTIONS] OUTPUT
Options:
-m, --mode INTEGER generation mode:

0 = combination rule mode
[default: 0]
-d, --dictlist TEXT read wordlist from the file, multi files
should by seperated by comma.
-r, --rule TEXT define word format, {0} means refer first
file in wordlist, some built-in charsets:

?l
= abcdefghijklmnopqrstuvwxyz
?u =
ABCDEFGHIJKLMNOPQRSTUVWXYZ
?d = 0123456789
?s
= !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
?a =
?l?u?d?s
?q = ]

example: [?dA]{1:2}{0}
view
documentation for more information.
[default: ]
-c, --dict_cache INTEGER each element in 'dictlist' option represents
a dict file path, this option define the
maximum amount of memory(MB) that can be used
when reading their contents.increasing the
cache may speed up the build when input dict
files is huge. [default: 500]
-g, --global_repeat_mode TEXT whether the character is allowd to repeat:

?
= 0 or 1 repetitions
* = 0 or more
repetitions [default: ?]
-p, --part_size INTEGER when result data is huge, split package
size(MB) will be applied, 0 is unlimited.
[default: 0]
--help Show this message and exit.
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
25 changes: 19 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
from setuptools import setup, find_packages

setup(
name='TTPassGen',
version='1.0',
name='ttpassgen',
version='0.0.4',
description='Highly flexiable and scriptable password dictionary generator',
author='tp7309',
author_email='[email protected]',
url='https://github.com/tp7309/TTPassGen',
license='LICENSE',
keywords='python ttpassgen password-generator wordlist password-dict password-dict-generator',
packages=find_packages(),
include_package_data=True,
entry_points='''
[console_scripts]
TTPassGen=TTPassGen:cli
''',
install_requires=[
'click', 'tqdm'
],
entry_points={
'console_scripts':[
'ttpassgen = ttpassgen.ttpassgen:cli',
],
},
)


#pandoc --from=markdown --to=rst --output=README.rst README.md
File renamed without changes.
16 changes: 8 additions & 8 deletions tests/test_TTPassGen.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@

from __future__ import print_function
import unittest, os
import TTPassGen
from ttpassgen import ttpassgen

#in.dict generate by: TTPassGen.py -r [123]{3:3} in.dict
class TestTTPassGen(unittest.TestCase):
#in.dict generate by: ttpassgen.py -r [123]{3:3} in.dict
class Test_ttpassgen(unittest.TestCase):
@classmethod
def setUpClass(cls):
super(TestTTPassGen, cls).setUpClass()
super(Test_ttpassgen, cls).setUpClass()
def lc_func():
if not os.path.exists('testout.dict'): return 0
with open('testout.dict', 'r') as f:
return len(f.readlines())
global lc
lc = lc_func

def go_func(rule, dictlist='in.dict', partSize=0, diskCache=500, repeatMode='?'):
def go_func(rule, dictlist='tests/in.dict', partSize=0, diskCache=500, repeatMode='?'):
try:
TTPassGen.cli.main(['-m', 0, '-d', dictlist, '-r', rule, '-g', repeatMode, '-c', diskCache, '-p', partSize, 'testout.dict'])
ttpassgen.cli.main(['-m', 0, '-d', dictlist, '-r', rule, '-g', repeatMode, '-c', diskCache, '-p', partSize, 'testout.dict'])
except(SystemExit):
pass
return lc()
Expand All @@ -29,7 +29,7 @@ def go_func(rule, dictlist='in.dict', partSize=0, diskCache=500, repeatMode='?')

@classmethod
def tearDownClass(cls):
super(TestTTPassGen, cls).tearDownClass()
super(Test_ttpassgen, cls).tearDownClass()
lc = None
go = None
os.remove('testout.dict') if os.path.exists('testout.dict') else None
Expand Down Expand Up @@ -72,7 +72,7 @@ def test_multi_dict_mark_charset_rule(self):
with open('in2.dict', 'wb') as f:
content = ['q00', 'q01']
f.write('\n'.join(content))
self.assertEquals(go('{1}{0}[abc]?', dictlist='in.dict,in2.dict'), 48)
self.assertEquals(go('{1}{0}[abc]?', dictlist='tests/in.dict,in2.dict'), 48)
os.remove('in2.dict') if os.path.exists('in2.dict') else None


Expand Down
Empty file added ttpassgen/__init__.py
Empty file.
5 changes: 3 additions & 2 deletions TTPassGen.py → ttpassgen/ttpassgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def generateCombinationDict(mode, dictList, rule, dictCache, globalRepeatMode, p


def extractRules(dictList, rule, globalRepeatMode):
splitedDict = re.split(r'[\s\,]+', dictList) if dictList else []
splitedDict = re.split(r',\s*', dictList) if dictList else []
reCharset = r"(\[([^\]]+?)\](\?|(\{\d+:\d+(:[\?\*])?\}))?)"
reDict = r"(\{(\d+)\})"
reRule = r"%s|%s"%(reCharset, reDict)
Expand Down Expand Up @@ -327,7 +327,8 @@ def progressMonitor():

@click.command()
@click.option("--mode", "-m", show_default=True, default=0, type=click.INT, help="generation mode:\n\n" + formatDict(_modes))
@click.option("--dictlist", "-d", type=click.STRING, help="read wordlist from the file")
@click.option("--dictlist", "-d", type=click.STRING,
help="read wordlist from the file, multi files should by seperated by comma.")
@click.option("--rule", "-r", type=click.STRING, show_default=True, default="",
help="define word format, {0} means refer first file in wordlist, some built-in charsets:\n\n"
+ formatDict(_built_in_charset) + "\n\nexample: [?dA]{1:2}{0}\nview documentation for more information.")
Expand Down

0 comments on commit af55dad

Please sign in to comment.