Last active
March 22, 2022 18:15
-
-
Save yukal/2cd2602fd0060c5dc2607b69d342626c to your computer and use it in GitHub Desktop.
.bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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