Sim Editor Stack Based Buffer Overflow

Last week I bought a SIM card reader. Along with it came the software for it. It was SIM Card Editor 6.6. You can download it from here. The app is pretty cool. You can manipulate the SIM cardโ€™s data with it. However I noticed something strange in this application. When we are loading file for example suppose with 4 โ€œAโ€ characters we would get the output as โ€œยชยชโ€. Just two characters will be displayed. When I gave the input as โ€œ4141โ€ the result would be โ€œAAโ€. This time the correct output we need. What was the reason for this? From what I noticed was that when we enter โ€œAAAAโ€ the hex values would be โ€œ\x41\x41\x41\x41โ€ the app will take two values each and evaluate to hex.

When we give the input as โ€œ4141โ€ this is what happens.

So suppose we want to enter a hex string we have to just give the input. For example we want to give the application โ€œAAโ€ we have to give just โ€œ4141โ€. Taking that into consideration the rest was easy. The return address is overwritten with our buffer.

buff = "41" * 500
with open("ex.sms", 'w') as f:
    f.write(buff)

(more…)