I only study assembler (nasm) and have more question. For example i want make asm code that get info about operating system. I use linux 86 bit. In a code i use syscall uname. In a browser have more information about this syscall and code. I found this link:
https://github.com/hc0d3r/asm/blob/master/uname.asm
Uname syscall in buffer overflow
But i use 86 bit system. So, i tried rewrite code for my system. I understand, that in register eax i should move value of syscall (0x7a or 122) and in register ebx addres of array.
I used first link as example, but get error. So, can you help me decide this problem?
This is my main code:
extern printf
SYS_WRITE equ 4
SYS_UNAME equ 122
SYS_EXIT equ 60
STDOUT equ 1
section .data
str: db '%s',10,0
UTSNAME_SIZE equ 65
space db ' '
break_line db 0xa
section .bss
uname_res resb UTSNAME_SIZE*5
section .text
global main
main:
mov eax, 0x7A
mov ebx, uname_res
int 80h
push dword [uname_res]
push dword str
call printf
mov eax, 1
int 80h
and I got this error:
segmentation error (memory dump made)
This mistake on printf. Sorry for my crooked english
push str
instead ofpush dword [str]
? Also, by 86 bit do you meanx86
? – mediocrevegetable1push dword [uname_res]
is probably wrong, you probably wantpush uname_res
. Also, familiarize yourself with gdb, radare2, or any debugger, they will help you shed some light on the crashes. – Margaret Bloom