PaGen – Python Brute-Force Password Generator

python ftp brute-force
PaGen - a brute-force generator for creating password lists.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
usage: pagen.py [-h] [-l [LENGTH]] [-m [MINLENGTH]] [-r PREFIX] [-o POSTFIX]
            charset

positional arguments:
  charset               Characters Set

optional arguments:
  -h, --help            show this help message and exit
  -l [LENGTH], --length [LENGTH]
                        Password Length
  -m [MINLENGTH], --minlength [MINLENGTH]
                        Minimum password length
  -r PREFIX, --prefix PREFIX
                        Prefix each password
  -o POSTFIX, --postfix POSTFIX
                        Postfix each password
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
################################################################################
#    tool: PaGen - Brute-Force Password Generator
# version: 0.2
#   email: mrh@hackhappy.org
#     www: hackhappy.org/pagen/
################################################################################
# MIT License

# Copyright (c) 2017 Phillip Aaron

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal#
# in the Software without restriction, including without limitation the rights#
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell#
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:

# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.

# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

import argparse, sys
from itertools import chain, product

# Iterable Method for brute-forcing a character set and length
def bruteforce(charset, maxlength, minlength):
    return (''.join(candidate)
        for candidate in chain.from_iterable(product(charset, repeat=i)
        for i in range(minlength, maxlength + 1)))
       
def main(args):
    for pwd in bruteforce(args.charset, int(args.length),int(args.minlength)):
        if args.prefix:
            pwd = str(args.prefix) + pwd
        if args.postfix:
            pwd += str(args.postfix)
        print pwd
   
if __name__ == "__main__":
    # Declare an argparse variable to handle application command line arguments
    parser = argparse.ArgumentParser()
    parser.add_argument("charset", action="store", help="Characters Set")
    parser.add_argument("-l", "--length", action="store",
        nargs='?', default=8, const=8, help="Password Length")
    parser.add_argument("-m","--minlength", action="store",
        nargs='?', default=1, const=1, help="Minimum password length")
    parser.add_argument("-r","--prefix", action="store", help="Prefix each password")
    parser.add_argument("-o","--postfix", action="store", help="Postfix each password")
    # Show help if required arg not included
    if len(sys.argv[1:])==0:
        parser.print_help()        
        parser.exit()
    args = parser.parse_args()
    if args.minlength > args.length:
        print "\n** Argument Logic Error **"
        print "Minimum password length [-m "+str(args.minlength)+"] is greater than Password length [-l "+str(args.length)+"]\n"
        parser.print_help()        
        parser.exit()
    main(args)

Subscribe For Latest News

TorGuard VPN 50% Off: hackhappy

TorGuard VPN Discount Code: hackhappy
Discount Code: hackhappy

Members

%d bloggers like this: