Quickly convert URL to push instructions with python

Comments Off on Quickly convert URL to push instructions with python

March 1, 2013 by globz

While working on a remote file downloader in Assembly I had to convert a url to push instructions so here’s a little bit of python magic :


In the above screenshot you can see that only 4 commands are needed to create push instructions.

After reversing and encoding a url, simply use the following command to create your push instructions :

for item in map(,,.join, zip(*[iter(rev_hex)]*8)) :
print "push 0x" +item

zip([iterable, …])
This function returns a list of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables. The returned list is truncated in length to the length of the shortest argument sequence. When there are multiple arguments which are all of the same length, zip() is similar to map() with an initial argument of None. With a single sequence argument, it returns a list of 1-tuples. With no arguments, it returns an empty list.

The left-to-right evaluation order of the iterables is guaranteed. This makes possible an idiom for clustering a data series into n-length groups using zip(*[iter(s)]*n).

Now its time to print the items and append “push 0x” at the start of each tuples which will return our push instructions!

push 0x67706a2e
push 0x37343731
push 0x36323631
push 0x36333739
push 0x36363735
push 0x3763362f
push 0x706d642f
push 0x746c7561
push 0x562f6d6f
push 0x632e7265
push 0x626d6f62
push 0x79747469
push 0x6b2e7777
push 0x772f2f3a
push 0x70747468

Comments Off on Quickly convert URL to push instructions with python

Sorry, comments are closed.