Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- set -xe
- echo "hello" | nc -lp 0 | grep -q "there" && echo "Got there" &
- PID=$(ps | grep nc | head -n 1| awk '{print $1}')
- inode=$(ls -lAF /proc/$PID/fd | grep socket | sed -e 's/.*\[//g' -e 's/\].*//g')
- hex=$(grep $inode /proc/net/tcp | awk '{print $2}' | sed 's/.*://g')
- port=$(printf '%d' "0x$hex")
- exec 3<>/dev/tcp/127.0.0.1/$port
- echo "there" >&3
- grep -q "hello" <&3 && echo "Got hello"
Add Comment
Please, Sign In to add comment