Tuesday, October 13, 2015

Python Exploits - Generate all hex chars to find badchars

While preparing for my OSCP exam, I'm reviewing the buffer overflow lessons and needed an easy way to generate all hex characters to test for bad characters in my exploit. Using "print("\\x" + format(x, 'x'))" results in a character on each line, and adding a comma after the print statement keeps it all on the same line, but the output has spaces between characters. You can generate the output you need, all on the same line and without spaces using "sys.stdout.write".

Here's a simple python snippet to do that: