Opening a File
Opening a File
Opening a File
We're getting dangerously close to do something interesting! How about that?
Can you use the sys_open syscall to open /etc/passwd, then return the file handle (in rax)?
Have another look at the syscall table. Can you call sys_open on the file /etc/passwd, then return the file handle? Here's the syscall table again.
Hints
- This is nearly the same as
Hello, World!!, only usingsys_openinstead ofsys_write! - Don't forget to read the boilerplate comments!
Looking back at the syscall table

We need 2 in rax to denote we are using sys_open
We need an address to a string denoting the filename in rdi
We need 0 in rsi (no flags)
We need 0 in rdx (mode of 0 I guess?)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | |
yay