I'm working on an assignment for a systems programming class, and for extra credit we are asked to modify an executable to allow it to accept the reverse of our PIN (finding the PIN was the original assignment). I was able to use GDB to change the memory values being stored for the PIN to the reverse, and when I run the program it works as intended. The only issue is that I can't save these changes to the executable. Once I exit the debugger it reverts to normal. I've tried using "set write on" and "gdb -write " before making changes, but the changes still wouldn't stick. Does anyone know if what I'm tyring to do is even possible, or where I might be going wrong?
Did you remember to reload your program after
set write on ?
And did you load your (writable) copy of the original program (as opposed to the professor's copy in a shared location that everyone has read access to, but noone can write) ?
Actually, i've never used gdb to patch files directly, i normally use a hex editor.
If you don't have a hex editor on your system, maybe you have
xxd, which allows you to turn a binary into a hex dump and vice versa.
If all else fails, you can still do something like
echo 'X' | dd of=binary.file bs=1 seek=12345 count=1
to patch the byte at offset 12345 in your file to an X. This method has the advantage that it doesn't depend on any gnu utilities, so it works on most variants of unix.