I'm studying about basic shell code with orw code.
But, in the process, I've got this error message:
Error: unsupported instruction
mov
This is my skeleton code in C and assembly:
// File name: orw.c
// Compile: gcc -o orw orw.c -masm=intel
__asm__(
".global run_sh\n"
"run_sh:\n"
"push 0x67\n"
"mov rax, 0x616c662f706d742f \n"
"push rax\n"
"mov rdi, rsp\n"
"xor rsi, rsi\n"
"xor rdx, rdx\n"
"xor eax, eax\n"
"mov eax, 2\n"
"syscall"
"\n"
"mov rdi, eax\n"
"mov rsi, rsp\n"
"sub rsi, 0x30\n"
"mov rdx, 0x30\n"
"xor eax, eax\n"
"syscall"
"\n"
"mov rdi,1\n"
"mov eax,1\n"
"syscall"
);
void run_sh();
int main() { run_sh(); }
I have put movq
and movl
but they didn't work.
Why does this problem occur with my code?
What is the solution?