3main file descriptors (often abbreviated fd) for each application:
/dev/null, which is the same principle.
stderr) to the user when they connect. These are super simple and often require no more than a replacement of
stdoutmay not be shown back to the user.
3. Once we connect, we set up another fd, fd
4is certain, but statistically likely).
2for its I/O.
4, and glibc provides a simple way to do so.
dupsyscall (and C function) duplicates the fd and uses the lowest-numbered free fd. However, we need to ensure it's fd
4that's used, so we can use
dup2takes in two parameters: a
oldfdis duplicated to
newfd, allowing us to interact with
stdoutand actually use any shell we may have popped.