-
Notifications
You must be signed in to change notification settings - Fork 0
/
pswg.py
53 lines (41 loc) · 1.36 KB
/
pswg.py
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
# Gabe Clark
import sys
### GLOBALS ###
subChars = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!@#$%^&*()')
### FUNCTIONS ###
def genMultiSubstitutionWordlist(masterList, numSubs):
if numSubs <= 0:
return list()
singleSubList = genSingleSubstitutionListFromList(masterList)
masterList = union(masterList, singleSubList)
multiSubList = genMultiSubstitutionWordlist(masterList, numSubs - 1)
masterList = union(masterList, multiSubList)
return masterList
def genSingleSubstitutionListFromList(oldList):
newList = list()
for i in oldList:
newList += genSingleSubtitutionListFromPass(i)
return newList
def genSingleSubtitutionListFromPass(oldPass):
passList = list()
for i in range(0, len(oldPass)):
for j in range(0, len(subChars)):
newPass = list(oldPass)
newPass[i] = subChars[j]
newPass = toString(newPass)
passList.append(newPass)
return passList
def union(list1, list2):
set1 = set(list1)
set2 = set(list2)
intersection = set1 | set2
return list(intersection)
def toString(charArr):
return ''.join(charArr)
def printList(passList):
for i in passList:
print(i)
### MAIN ###
wordlist = genMultiSubstitutionWordlist( [ sys.argv[1] ], int(sys.argv[2]) )
printList( sorted(wordlist) )