Guest User

Untitled

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