Skip to content

Instantly share code, notes, and snippets.

@yukal
Last active March 22, 2022 18:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukal/2cd2602fd0060c5dc2607b69d342626c to your computer and use it in GitHub Desktop.
Save yukal/2cd2602fd0060c5dc2607b69d342626c to your computer and use it in GitHub Desktop.
.bashrc
# Generate Hash
# Usage:
# genhash
# genhash 64
function genhash() {
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w ${1:-32} | head -n 1
}
# Get External IP
# External IP
# https://ip-api.com/docs/dns
function extip() {
curl -s "http://$(genhash).edns.ip-api.com/json";
echo;
}
# Scan open local ports (1..1024)
# Usage:
# scan_ports 0.0.0.0
# scan_ports 192.168.0.1
function scan_ports() {
host=$1
for ((port=1; port<1024; port++)); do
echo > /dev/null 2>&1 < /dev/tcp/${host}/${port}
if (($? == 0)); then
echo -e "$host\t$port";
#printf '%d ' "$port";
fi
done
echo;
}
export -f scan_ports
export -f extip
export -f genhash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment