Exploit pattern generator

exploitPattern generates the metasploit exploit pattern string in Python. It also allows a user to search for a given substring in the pattern. Arbitrary length patterns may be generated and searched. However, beyond ‘Zz9’, uniqueness is no longer guaranteed.

Usage:

exploitPattern.py <length> | <pattern to search for>
    e.g.: exploitPattern.py 10000  (generate pattern of 10000 chars)
          exploitPattern.py Ms0    (find "Ms0" in pattern)

GitHub: https://github.com/eugeii/exploit-pattern

For those who do reversing and/or exploitation, using an exploit pattern to feed as input to your target is something common. Of course, there are a number of such generators out there, the most “famous” of which is the in-built Metasploit tool. There are also a couple of scripts on the Internet.

However, for generating what is simply a string, Metasploit is way too heavy for me. I noticed a good Perl script out there, and Perl’s in-built string support also makes it easy to build this, but I’m not much a Perl fan, and again, for something quick and dirty, I don’t feel like installing Perl on a box which doesn’t have it.

Hence, here’s a script to generate the pattern in Python. Finally, there is duplication of code in the script for the generate and search functions. It was made for quick use, so I’m not touting elegance here. Feel free to abstract the commonality if you wish.

Hope some among you find this useful.

Update: This is really, really old. There are much better ways of doing this now.