26.07.2018 Views

hacking-the-art-of-exploitation

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

From /usr/include/unistd.h<br />

/* Standard file descriptors. */<br />

#define STDIN_FILENO 0 /* Standard input. */<br />

#define STDOUT_FILENO 1 /* Standard output. */<br />

#define STDERR_FILENO 2 /* Standard error output. */<br />

Writing bytes to standard output’s file descriptor <strong>of</strong> 1 will print <strong>the</strong> bytes;<br />

reading from standard input’s file descriptor <strong>of</strong> 0 will input bytes. The standard<br />

error file descriptor <strong>of</strong> 2 is used to display <strong>the</strong> error or debugging messages<br />

that can be filtered from <strong>the</strong> standard output.<br />

0x511<br />

Linux System Calls in Assembly<br />

Every possible Linux system call is enumerated, so <strong>the</strong>y can be referenced<br />

by numbers when making <strong>the</strong> calls in assembly. These syscalls are listed in<br />

/usr/include/asm-i386/unistd.h.<br />

From /usr/include/asm-i386/unistd.h<br />

#ifndef _ASM_I386_UNISTD_H_<br />

#define _ASM_I386_UNISTD_H_<br />

/*<br />

* This file contains <strong>the</strong> system call numbers.<br />

*/<br />

#define __NR_rest<strong>art</strong>_syscall 0<br />

#define __NR_exit 1<br />

#define __NR_fork 2<br />

#define __NR_read 3<br />

#define __NR_write 4<br />

#define __NR_open 5<br />

#define __NR_close 6<br />

#define __NR_waitpid 7<br />

#define __NR_creat 8<br />

#define __NR_link 9<br />

#define __NR_unlink 10<br />

#define __NR_execve 11<br />

#define __NR_chdir 12<br />

#define __NR_time 13<br />

#define __NR_mknod 14<br />

#define __NR_chmod 15<br />

#define __NR_lchown 16<br />

#define __NR_break 17<br />

#define __NR_oldstat 18<br />

#define __NR_lseek 19<br />

#define __NR_getpid 20<br />

#define __NR_mount 21<br />

#define __NR_umount 22<br />

#define __NR_setuid 23<br />

#define __NR_getuid 24<br />

284 0x500

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!