Wordlist with all Possible ASCII Elements

After a bit of thinking I believe I have a better way to create all possible ASCII pass phrases, rather than create a recursive function that calls itself as I did in the previous post.

This method takes a slightly different approach, but I believe it to return the same results.

First off let’s create a list of all lower case ASCII character numbers:

>>> chars = range(97, 123)
>>> chars
[97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 120, 121, 122]
>>> map(chr, chars)
['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p',
'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

Next we can set our max word width and current word width variables:

import itertools
maxwidth = 3
currentwidth = 1

At this point we are ready to run with a while loop:

while int(currentwidth) <= int(maxwidth):
    for i in itertools.product(chars, repeat=currentwidth):
        print ''.join(['%c' % c for c in list(i)])
    currentwidth += 1

The loop above will run until currentwidth is greater than maxwidth (makes sense right), at that point we use itertools’s product method to create all possible orderings for our characters.

Then using list comprehension I print out the %c which returns the alphabetical character.

And lastly we increase the currentwidth by 1

What itertools.product does is creates all possible combinations (including repeated chars):

>>> [i for i in itertools.product(chars, repeat=2)]
[(97, 97), (97, 98), (97, 99), (97, 100), (97, 101), (97, 102), (97,
 103), (97, 104), (97, 105), (97, 106), (97, 107), (97, 108), (97, 109),
 (97, 110), (97, 111), (97, 112), (97, 113), (97, 114), (97, 115), (97,
 116), (97, 117), (97, 118), (97, 119), (97, 120), (97, 121), (97, 122),
 (98, 97), (98, 98), (98, 99), (98, 100), (98, 101), (98, 102), (98,
103), (98, 104), (98, 105), (98, 106), (98, 107), (98, 108), (98, 109),
 (98, 110), (98, 111), (98, 112), (98, 113), (98, 114), (98, 115), (98,
 116), (98, 117), (98, 118), (98, 119), (98, 120), (98, 121), (98, 122),
 (99, 97), (99, 98), (99, 99), (99, 100), (99, 101), (99, 102), (99,
......
.....
...

Of course you probably want to see those tuples of characters as letters right:

>>> for i in itertools.product(chars, repeat=2):
...   ''.join(['%c' % c for c in i])
...
'aa'
'ab'
'ac'
'ad'
'ae'
'af'
'ag'
'ah'
'ai'
'aj'
'ak'
'al'
'am'
'an'
'ao'
'ap'
'aq'
'ar'
'as'
'at'
'au'
'av'
'aw'
'ax'
..
..
..

Diablo III API

So I was doing a bit of research on a Diablo III API, and stumbled across this article:

http://us.battle.net/d3/en/forum/topic/4877377752

It seems they are still in the early stages, but there is a Character Calculator API, and it is in JSON.

First off we need to load in our Python libraries:

>>> from urllib2 import urlopen
>>> from json import loads

We can make our request using common URL methods:

>>> res = urlopen('http://us.battle.net/d3/en/data/calculator/monk').read()
>>> monk = loads(res)

Now we are given a simple Python dictionary:

>>> monk.keys()
[u'skills', u'traits']

And like most APIs these keys contain a list of objects:

>>> type(monk['skills'])
<type 'list'>
>>> type(monk['skills'][0])
<type 'dict'>

>>> monk['skills'][0].keys()
[u'tooltipParams', u'name', u'runes', u'simpleDescription', u'description', u'primary', u'slug',
u'requiredLevel', u'categoryName', u'categorySlug', u'icon']

So far so good, lets go ahead and itter over all our skills and get their names:

>>> for skill in sorted(monk['skills']):
...   print skill['name']
...
Blinding Flash
Serenity
Breath of Heaven
Inner Sanctuary
Mystic Ally
Cyclone Strike
Seven-Sided Strike
Mantra of Conviction
Mantra of Healing
Mantra of Retribution
Mantra of Evasion
Deadly Reach
Way of the Hundred Fists
Fists of Thunder
Crippling Wave
Tempest Rush
Lashing Tail Kick
Wave of Light
Dashing Strike
Exploding Palm
Sweeping Wind

So there you have it, using one of the new Diablo III APIs to get class information.