5
votes

I am trying to hook the socket system call on linux x86_32. This system call does not exist but is gated through socketcall.

man socketcall: socketcall() is a common kernel entry point for the socket system calls. call determines which socket function to invoke. args points to a block containing the actual arguments, which are passed through to the appropriate call.

I hooked this syscall (__NR_socketcall is 102 on my system which is also stated on http://docs.cs.up.ac.za/programming/asm/derick_tut/syscalls.html) with my own function which prints something and calls the original function afterwards. However, my function is never called. Furthermore, strace shows that a socket() syscall is called.

The basic question: How can I hook socket syscalls on linux x86_32?

Subquestion: Why does strace show the socket() syscall and not socketcall()?

Everything works as expected on x86_64 where a socket syscall exists.

1

1 Answers

0
votes

hi i was like you searching a way to call directly syscalls like : socket , bind and so on.

Searching on the internet i found that you can call this syscalls that are defined in this file : /usr/include/i386-linux-gnu/asm/unistd_32.h

for example the syscall for socket is 359 in decimal and the one for bind is 361 in decimal

all tested in a x86_32