zardus / preeny

Some helpful preload libraries for pwning stuff.
BSD 2-Clause "Simplified" License
1.56k stars 171 forks source link

Errors with desock.so and desock.dup #74

Closed powerthe900 closed 3 years ago

powerthe900 commented 3 years ago

I am trying to use preeny to make recieve http requests from stdin. Hence, I used desock.so and desock_dup,so. When I use desock.so, I get this error: setsockopt(TCP_NODELAY) failed: Operation not supported. When I use desock_dup.so, I get this error: setting default fds failed: Success.

Have you guys occurred this error before? How would I solve this?

zardus commented 3 years ago

It looks like lighttpd is treating the socketpair that preeny replaced the network connection with as a network socket, and is trying to set socket options on it. The way to handle this for desock is to add some handling (probably just return 0) for setsockopts in the module. Not sure what's happening with desock_dup, but I'm guessing a similar root cause (treating the FD as a socket).

powerthe900 commented 3 years ago

Sorry if the source code part looks wierd.

powerthe900 commented 3 years ago

The return zero method did not work.

powerthe900 commented 3 years ago

The binary has a one shot mode that process single (one) request on stdin socket, then exit. When I use desock.so and pass a normal http request through stdin, it says that -1 is not a socket. How would I bypass this?

powerthe900 commented 3 years ago

Ive got it to work

zardus commented 3 years ago

What was the solution in the end?

https://xkcd.com/979/ :-)

gstrauss commented 3 years ago

FYI: the next version of lighttpd 1.4.56 additionally supports a special case of lighttpd -1 (one-shot mode) with pipes on stdin and stdout, e.g. for use with a netcat listener. The current lighttpd -1 expects a socket on stdin.

powerthe900 commented 3 years ago

The solution was that they closed stdin in the program. You would just have to delete that section in the code and desock worked.