Search this site





Overriding shared library functions

Long story short...

File: 'connect.over' contains

#include <netinet/in.h>

override(`connect', `
    // code to inject before the connect() call is actually made
Output is '' which overrides libc's connect function.
% LD_PRELOAD=./ nc 80
stream connect: fd=3 host=
% LD_PRELOAD=./ nc -u 53 
dgram connect: fd=3 host=
% LD_PRELOAD=./ ssh scorn           
stream connect: fd=3 host=
stream connect: fd=4 host=
scorn(~) %
The output by nc was due to my function above outputting this.

The strange ssh connection on fd=4 above is seemingly due to ssh calling connect() on a tty? fstat says:

jls      ssh         3221    4 /dev        122 crw--w----   ttypd rw
inode 122 on /dev is /dev/ttypd.