daily pastebin goal
57%
SHARE
TWEET

Untitled

a guest Nov 22nd, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. echo exit | telnet {site} {port}
  2.    
  3. sleep <n> | telnet <server> <port>
  4.    
  5. sleep 1 | telnet <server> <port> > output.log
  6.    
  7. while read host port; do
  8. r=$(bash -c 'exec 3<> /dev/tcp/'$host'/'$port';echo $?' 2>/dev/null)
  9. if [ "$r" = "0" ]; then
  10.      echo "$host $port is open"
  11. else
  12.      echo "$host $port is closed"
  13.      exit 1 # To force fail result in ShellScript
  14. fi
  15. done
  16.    
  17. #!/bin/bash
  18. if [ "$2" == "" ]; then
  19.  echo "Syntax: $0 <host> <port>"
  20.  exit;
  21. fi
  22.  
  23. host=$1
  24. port=$2
  25.  
  26. r=$(bash -c 'exec 3<> /dev/tcp/'$host'/'$port';echo $?' 2>/dev/null)
  27. if [ "$r" = "0" ]; then
  28.      echo "$host $port is open"
  29. else
  30.      echo "$host $port is closed"
  31.      exit 1 # To force fail result in ShellScript
  32. fi
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top