start_socat.sh 536 B

12345678910111213141516171819
  1. kill -9 $(pgrep -f "^socat$")
  2. sleep 3
  3. host=$(ifconfig eth0 | sed -En -e 's/.*inet ([0-9.]+).*/\1/p')
  4. echo "scaning ip range $host"
  5. for ip in $(nmap -n -sn --unprivileged $host/24 -oG - | awk '/Up$/{print $2}')
  6. do
  7. echo socating $ip
  8. bia=$(echo $ip | awk -F. '{print $4}')
  9. base1=50000
  10. port1=$((base1 + bia))
  11. nohup socat -v tcp-listen:$port1,fork,reuseaddr tcp:$ip:22 >/dev/null 2>&1 &
  12. base2=58000
  13. port2=$((base2 + bia))
  14. nohup socat -v tcp-listen:$port2,fork,reuseaddr tcp:$ip:8000 >/dev/null 2>&1 &
  15. done