#getpriv.s
#c0d3r: ev1lut10n
#a simple code to check our privilege
#for: freebsd 32 bit

.section .rodata
w00t:
   .ascii "w00t we g0t r00t privilege\n"
   blew00t = . - w00t
n0_r00t:
   .ascii "S0rry we're n0t r00t\n"
   blen0_r00t = . - n0_r00t

.globl  _start
_start:

pr3p4r3_0pt:
 	pushl %ebx 
        pushl %esi 
        pushl %edi 
        pushl %ebp 
	jmp utama
	
get_privilege:
	pushl %ebp
        movl %esp, %ebp
	movl $24,%eax
	pushl %eax
        int $0x80
	
	cmpb $0,%al
	jz g0tr00t
	jmp n0tr00t
	movl %ebp, %esp
        popl %ebp
	lret

utama:
	pushl %ebp
        movl %esp, %ebp


	call get_privilege

	movl %ebp, %esp
        popl %ebp

g0tr00t:
	pushl %ebp
        movl %esp, %ebp
	pushl $blew00t
        pushl $w00t
	pushl $1
        movl $4,%eax
        pushl %eax
        int $0x80
	movl %ebp, %esp
        popl %ebp
	jmp out

n0tr00t:
	pushl %ebp
        movl %esp, %ebp
	pushl $blen0_r00t
        pushl $n0_r00t
	pushl $1
        movl $4,%eax
        pushl %eax
        int $0x80
	movl %ebp, %esp
        popl %ebp
	jmp out

out:
        movl $1, %eax
        pushl $0
        pushl %eax
        int $0x80