0

I learnt that we can use LD_PRELOAD to preload open() function to fake a path to a process.

I learnt it from here: Is it possible to fake a specific path for a process?

I am wondering if there is a command, which redirects a process' reading/writing file to another path? Like proxychains, it uses LD_PRELOAD.

1 Answers1

1

Why don't you write it yourself?

#include <dlfcn.h>
#include <sys/stat.h>
#include <fcntl.h>

int
open(const char *name, int flags, mode_t mode)
{
    int (*real_open)() = dlsym(RTLD_NEXT, "open");

    if (strcmp(name, "xxzzy") == 0) {

          do my stuff
          .....
    }
    return (real_open(name, flang, mode);
}
schily
  • 19,173