#include #include #include #include #define STRINGS "foobar\0\0\0/\0/bin/sh" static const struct reply { uint32_t header[9]; char strings[sizeof STRINGS]; } reply = { { 2, 1, 7, 1, 12345, 678910, 1, 2, 8 }, STRINGS }; int main() { struct sockaddr_un sun = { .sun_family = AF_UNIX, .sun_path = "/var/run/nscd/socket" }; int s = socket(AF_UNIX, SOCK_STREAM, 0); umask(0); bind(s, (void *)&sun, sizeof sun); listen(s, 1); for (;;) { char buf[256]; int c = accept(s, (void *)&(struct sockaddr_un){0}, &(socklen_t){sizeof sun}); read(c, buf, sizeof buf); write(c, &reply, sizeof reply); close(c); } }