Skip to content

Instantly share code, notes, and snippets.

@masdeseiscaracteres
Last active June 21, 2019 11:51
Show Gist options
  • Save masdeseiscaracteres/64ee182aa8f18beee7cf225bed081f1b to your computer and use it in GitHub Desktop.
Save masdeseiscaracteres/64ee182aa8f18beee7cf225bed081f1b to your computer and use it in GitHub Desktop.
UNIX tricks
#!/usr/bin/env bash
# DNS lookup in Bash without "host", "dig" or "nslookup"
[[ $# -ne 1 ]] && echo "Please provide host name" && return 1
HOST="$1"
getent hosts $HOST
#!/usr/bin/env bash
# Port scan in Bash (without sudo, nmap or nc)
[[ $# -ne 2 ]] && echo "Please provide server name and port" && return 1
SERVER="$1"
PORT="$2"
(echo > /dev/tcp/$SERVER/$PORT) >& /dev/null && echo "Port $PORT seems to be open in server $SERVER"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment