I am trying to use python to write out some assembly code to redirect the flow of a binary. This is for school. I am coming along pretty well, but I am stuck, alas. I have determined a list of assembly code ops that I need to execute, and the trouble is in a movl call. I need this to look like movl $0x0, add(%ebp). I am using python to store these hex values in an env variable and planning to jump to that env variables location.
So, I do something like
export CODE=`python -c 'print "somehex...\xc7\x45\xfc\x00\x00\x00\x00...morehex"'`
This stores this in the env just fine, and when I jump to it in gdb, I can x/i the assembly code. Everything looks good except for this movl call. Rather than reading the \x00's as the argument (supposed to be $0x0), it takes the next 4 hex values as the argument for the source. I cannot find any other way of writing $0x0 into the src argument of movl in the python fashion I have chosen.
Any help would be GREATLY appreciated. Been working on this for quite some time.
add? Just a symbolic constant?