my problem related assembler , shellcoding.
i started off writing first shellcode , worked out pretty far. made assembly script of following c code:
#include <stdio.h> #include <unistd.h> #include <fcntl.h> int main() { int fd = open("test.txt", o_creat | o_wronly); write(fd, "hello world!", 6); return 0; }
the assembly code piece looks this:
global _start _start: xor eax, eax ; null eax reg push 0x7478742e ; push "test.txt" on stack push 0x74736574 mov ebx, esp ; first argument mov cl, 0x41 ; flags o_creat | o_wronly mov al, 0x5 ; sys_open int 0x80 push 0x736b6330 ; "shellcodingr0cks" push 0x72676e69 push 0x646f636c push 0x6c656853 mov ebx, eax ; file identifier mov ecx, esp ; string on stack mov dl, 0x10 ; 0x10 size of string mov al, 0x4 ; sys_write int 0x80 xor eax, eax ; exit proc inc eax int 0x80
the program works pretty , i've got expected output there 1 problem , don't know why occurring.
the filename of file i'm writing should test.txt
writing test.txt^a
. don't know ^a
coming from, nor know how fix it.
does know wrong, , how can fix it?