在为 shellcode 编写最简单的程序集时,我编写了这段代码
BITS 64
global _start
section .data
_start:
;ssize_t write(int fd, const void *buf, size_t count);
;rax = 1
jmp poziv
vracajse:
xor rsi,rsi
pop rsi
xor rax,rax
mov al,1 ; were calling write
;The parameters are in rdi, rsi, rdx, r10, r8, r9. in that order
xor rdi,rdi ;
xor rcx,rcx ; need low 8 bytes dont want null in machine code
mov cl,1
mov edi,ecx ; edi =1 writing to stdout
xor rdx,rdx
mov dl,15 ; were writing 15 chars
syscall
poziv:
call vracajse
poruka:
.ascii "Pozdrav svete!\n"
并得到以下错误
writing_2nd_try.nasm:28: error: parser: instruction expected
为什么告诉我我的代码 poruka: .ascii "Some string" 不是有效指令(标签和消息),但如果我将其写为 db 则没关系。
(对我来说也很有趣的是,如果我写 .section 数据而不是 section .data 我会收到以下错误
writing_2nd_try.nasm:3: error: attempt to define a local label before any non-local labels
writing_2nd_try.nasm:3: error: parser: instruction expected
)
我对这一切有点陌生,但我以为我知道我在做什么。