File: 'connect.over' contains
#include <netinet/in.h>
override(`connect', `
{
// code to inject before the connect() call is actually made
}
')
Output is 'connect.so' which overrides libc's connect function.
% LD_PRELOAD=./connect.so nc google.com 80 stream connect: fd=3 host=64.233.187.99:80 % LD_PRELOAD=./connect.so nc -u 129.21.60.9 53 dgram connect: fd=3 host=129.21.60.9:53 % LD_PRELOAD=./connect.so ssh scorn stream connect: fd=3 host=129.21.60.26:22 stream connect: fd=4 host=109.112.47.115:12148 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 rwinode 122 on /dev is /dev/ttypd.