Scrawls from Preston...

Powered by Pelican.

Thu 03 September 2009

simple weak password generator

There are times I need to create some easy to remember weak initial passwords for students - here is a quick script

Note that these are not strong passwords as they are the definition of "dictionary" passwords...

import sys
import os
import random

dfile = '/usr/share/dict/web2'

def main():
    for x in range(130):
        winner = False
        MAX = 234936
        suffix = random.randint (10,100)
        while not winner:
            choice = random.randint(1,MAX)
            f = open(dfile)
            for i,l in enumerate(f):
                l = l.strip()
                length = len(l)
                if i < choice:
                    continue
                if length > 3 and length < 7:
                    winner = '%s%d' % (l,suffix)
                    break
        f.close()
        print winner.lower()


if __name__ == '__main__':
    main()

https://ptone.com/dablog