Skip to content

Use a local user hosts file to resolve host names without root permissions.

License

Notifications You must be signed in to change notification settings

maycon-zz/libhosts

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libhosts - A simple LD_PRELOAD library

$ ./resolveip a.b.c.d
./resolveip: Unable to find hostid for 'a.b.c.d': host not found
$
$ make
gcc -Wall -Wl,-soname,libhosts -shared -ldl -fPIC -o libhosts.o libhosts.c
$ echo "8.8.8.8 a.b.c.d" >> ~/.libhosts/hosts
$
$ LIBHOSTS_FILE=~/.libhosts/hosts LD_PRELOAD=./libhosts.o ./resolveip a.b.c.d
IP address of a.b.c.d is 8.8.8.8
$
$ LIBHOSTS_DEBUG=1 LIBHOSTS_FILE=~/.libhosts/hosts LD_PRELOAD=./libhosts.o ./resolveip a.b.c.d
[+] libhosts: libhosts.c:30 gethostbyname(): First call
[+] libhosts: libhosts.c:34 gethostbyname(): looking for a.b.c.d
[+] libhosts: libhosts.c:45 gethostbyname(): read from local host a.b.c.d -> 8.8.8.8
[+] libhosts: libhosts.c:49 gethostbyname(): matched
IP address of a.b.c.d is 8.8.8.8
$
$ LIBHOSTS_DEBUG=1 LIBHOSTS_FILE=~/.libhosts/hosts LD_PRELOAD=./libhosts.o ./resolveip a.b.c.d.e
[+] libhosts: libhosts.c:30 gethostbyname(): First call
[+] libhosts: libhosts.c:34 gethostbyname(): looking for a.b.c.d.e
[+] libhosts: libhosts.c:45 gethostbyname(): read from local host a.b.c.d -> 8.8.8.8
[+] libhosts: libhosts.c:65 gethostbyname(): Not found in local hosts file
./resolveip: Unable to find hostid for 'a.b.c.d.e': host not found
$ 

About

Use a local user hosts file to resolve host names without root permissions.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages