在hello编码方面,我是新来的,我尝试为(Hello world )编写一个hello代码,所以这是我第一次使用空字节的代码:
global _start
section .text
_start: ;tell linker entry point
mov edx,len ;message length
mov ecx,msg ;message to write
mov ebx,1 ;file descriptor (stdout)
mov eax,4 ;system call number (sys_write)
int 0x80 ;call kernel
mov eax,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string这是我删除空x00后的第二段代码!!
global _start
section .text
_start:
;tell linker entry point
xor edx,edx
mov dl,len ;message length
mov ecx,msg ;message to write
xor ebx,ebx
mov bl,1 ;file descriptor (stdout)
xor eax,eax
mov al,4 ;system call number (sys_write)
int 0x80 ;call kernel
xor eax,eax
mov al,1 ;system call number (sys_exit)
int 0x80 ;call kernel
section .data
msg db 'Hello, world!',0xa ;our dear string
len equ $ - msg ;length of our dear string我通过以下方法编译它以进行测试:
nasm -f elf32 -o hello-un-null.o hello-un-null.asm ld -o hello-hello-un-null.o
当我运行它时,它的工作。/hello-
而不是我使用的: objdump -d hello- used intel。
这就是结果:
Disassembly of section .text:
08048080 <_start>:
8048080: 31 d2 xor edx,edx
8048082: b2 0e mov dl,0xe
8048084: b9 9c 90 04 08 mov ecx,0x804909c
8048089: 31 db xor ebx,ebx
804808b: b3 01 mov bl,0x1
804808d: 31 c0 xor eax,eax
804808f: b0 04 mov al,0x4
8048091: cd 80 int 0x80
8048093: 31 c0 xor eax,eax
8048095: b0 01 mov al,0x1
8048097: cd 80 int 0x80然后通过以下方式将其转换为shellcode代码:
objdump -d ./hello-objdump grep‘0-9a-f:“grep -v”文件“-f2 -d:|cut -f1-6 -d”’\\tr -s‘\\t '\t’x 's/ $//g‘_s//\x/g’+粘贴-d‘-s 's/ ^/“/’sed‘s/s/”/g“/g”
产出如下:
"\x31\xd2\xb2\x0e\xb9\x9c\x90\x04\x08\x31\xdb\xb3\x01\x31\xc0\xb0\x04\xcd\x80\x31\xc0\xb0\x01\xcd\x80“
当我测试它时,我得到了以下错误:
外壳代码长度: 25段故障(核丢弃)
我的c代码用于测试:
#include<stdio.h>
#include<string.h>
unsigned char code[] = \
"\x31\xd2\xb2\x0e\xb9\x9c\x90\x04\x08\x31\xdb\xb3\x01\x31\xc0\xb0\x04\xcd\x80\x31\xc0\xb0\x01\xcd\x80";
int main()
{
printf("Shellcode Length: %d\n", strlen(code));
int (*ret)() = (int(*)())code;
ret();
}那么问题是什么呢?我怎么才能解决呢?
发布于 2018-12-03 16:10:57
我通过改变来解决它
char shellcode[]
至
const char shellcode[]
使用JMP/CALL/POP方法
https://stackoverflow.com/questions/53592134
复制相似问题