So this is my first time writing assembly code and I'm trying to understand everything I'm doing so far but I need a bit of help. First off, here's what my code looks like:
BITS 32 ;ssize_t write(int fd, const void *buf, size_t n); xor eax, eax ; Make eax zero for our null terminator xor esp, esp ; Clear the stack (Is this a bad idea?) push eax ; Push the null terminator to the stack push 0x7273752F ; /usr push 0x6E69622F ; /bin push 0x6465672F ; /ged push 0x7469 ; it mov ebx, 1 ; Use stdout mov eax, 4 ; Move 4 into eax for write call mov edx, 15 ; length of 15 mov ecx, esp ; push the string into ecx int 0x80 ; Do the system call ; void _exit(int status); mov eax, 1 ;Exist system call mov ebx, 0 ;Status is clean int 0x80 ;Do the system call
The comments are what I think each line does. I'm basically trying to push "/usr/bin/gedit" to the stack that way I can then move esp into the buffer, ecx. Yes I realize I'm not actually executing gedit, this is just a test for me to see if I can print the path out. I'm having trouble doing this though because when I use hexdump -C on this, my string has an 'h' in between each push I have there. So it would look like this:
Any idea why is this happening and do I have my logic correct for what each line is doing?
Edited by SonicD007, 01 September 2012 - 02:50 PM.