Skip to content

Instantly share code, notes, and snippets.

@drygdryg
Last active January 18, 2020 13:18
Show Gist options
  • Save drygdryg/cfcae2bc19ebf3ffabf40a7b684d33ac to your computer and use it in GitHub Desktop.
Save drygdryg/cfcae2bc19ebf3ffabf40a7b684d33ac to your computer and use it in GitHub Desktop.
WPS PIN dictionary generator
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import sys
def WPSchecksum(pin):
'''
Standard WPS checksum algorithm.
@pin — A 7 digit pin to calculate the checksum for.
Returns the checksum value.
'''
accum = 0
while pin:
accum += (3 * (pin % 10))
pin = int(pin / 10)
accum += (pin % 10)
pin = int(pin / 10)
return ((10 - accum % 10) % 10)
def genWPSPIN(n):
return (str(n) + str(WPSchecksum(n))).zfill(8)
if __name__ == '__main__':
try:
filename = sys.argv[1]
except IndexError:
print('Usage: {} file.dic'.format(sys.argv[0]))
exit(1)
dictionary = open(filename, 'w', encoding='utf-8')
for n in range(0, 10000000):
pin = genWPSPIN(n)
dictionary.write(pin + '\n')
dictionary.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment