We need to be warry of bad characters and pick them out so that our payload doesn't contain any characters that might cause our exploit to fail.
Possible Bad Characters
Here's a list of all the characters that could possibly be bad characters. You might notice that \x00 is not in the list below. That's because it's considered to be a bad character most of the time.
We will again be modifying our initial code to include an array of bad characters in the buffer. By sending a buffer with bad characters. We would be able to determine the bad characters that are associated with the application via analysis on Immunity Debugger with the help of Mona.
Once the bad chars are sent in, following the ESP location in dump reveals to us where our chars are. With this, we would be able to do further analysis with mona and locate the actual bad characters.
Setting working directory for Mona
!mona config -set workingfolder c:\Temp
Creating Bytearray with Mona
!mona bytearray -b "\x00"
Locating Bad Characters
!mona compare -f C:\Temp\bytearray.bin -a <ESP Address>
!mona compare -f C:\Temp\bytearray.bin -a 0122FA18
Now that we have the results, we have to remove every consecutive output under the Badchars tab excluding “\x00” as that is a bad character for all cases. We would end up with a bad character set of: