我今天开始组装以创建 shell 代码。ASM 很好,过了一会儿我创建了这个:
[SECTION .text]
global _start
_start:
call ender
starter:
mov al, 4
mov bl, 1
pop ecx
mov dl, 21
int 0x80
xor eax, eax
mov al, 1
xor ebx,ebx
int 0x80
ender:
call starter
db 10,'Shellcode forever!',10 ,10
效果很好:
Shellcode forever!
root@root:~/Desktop# clear;nasm -f elf test.asm;ld -s -o test test.o;./test
所以我然后使用'objdump -d test'并得到了这个:
test: file format elf32-i386
Disassembly of section .text:
08048060 <.text>:
8048060: e8 11 00 00 00 call 0x8048076
8048065: b0 04 mov $0x4,%al
8048067: b3 01 mov $0x1,%bl
8048069: 59 pop %ecx
804806a: b2 15 mov $0x15,%dl
804806c: cd 80 int $0x80
804806e: 31 c0 xor %eax,%eax
8048070: b0 01 mov $0x1,%al
8048072: 31 db xor %ebx,%ebx
8048074: cd 80 int $0x80
8048076: e8 ea ff ff ff call 0x8048065
804807b: 0a 53 68 or 0x68(%ebx),%dl
804807e: 65 gs
804807f: 6c insb (%dx),%es:(%edi)
8048080: 6c insb (%dx),%es:(%edi)
8048081: 63 6f 64 arpl %bp,0x64(%edi)
8048084: 65 20 66 6f and %ah,%gs:0x6f(%esi)
8048088: 72 65 jb 0x80480ef
804808a: 76 65 jbe 0x80480f1
804808c: 72 21 jb 0x80480af
804808e: 0a 0a or (%edx),%cl
但是当我把它变成 shellcode 时:
char code[] = "\xe8\x11\x00\x00\x00\xb0\x04\xb3\x01\x59\xb2\x15\xcd\x80\x31\xc0\xb0\x01\x31\xdb\xcd\x80\xe8\xea\xff\xff\xff\x0a\x53\x68\x65\x6c\x6c\x63\x6f\x64\x65\x20\x66\x6f\x72\x65\x76\x65\x72\x21\x0a\x0a";
它没有用。我做错了什么?