Skip to content

Instantly share code, notes, and snippets.

@ederoyd46
Last active October 14, 2015 10:11
Show Gist options
  • Save ederoyd46/8bac36bace9976c5167a to your computer and use it in GitHub Desktop.
Save ederoyd46/8bac36bace9976c5167a to your computer and use it in GitHub Desktop.
Useful Blacklist Functions
#Docker Tools
alias docker-container-ip="docker inspect --format '{{ .NetworkSettings.IPAddress }}'"
function docker_container_ip() { docker inspect --format '{{ .NetworkSettings.IPAddress }}' $1; }
#.htpassword file password hasher
function hash_password() { perl -le "print crypt(\"$1\", \"salt-hash\")"; }
#Firewall Tools
alias flush-blacklist='sudo bash -c "echo / > /proc/net/xt_recent/iptables_blacklist"'
alias blacklist='cat /proc/net/xt_recent/iptables_blacklist'
alias blacklist-count='blacklist | wc -l'
alias flush-watchlist='sudo bash -c "echo / > /proc/net/xt_recent/iptables_watchlist"'
alias watchlist='cat /proc/net/xt_recent/iptables_watchlist'
alias watchlist-count='watchlist | wc -l'
function blacklist_ip() { sudo bash -c "echo +\"$1\" > /proc/net/xt_recent/iptables_blacklist"; }
function unblacklist_ip() { sudo bash -c "echo -\"$1\" > /proc/net/xt_recent/iptables_blacklist"; }
function watchlist_ip() { sudo bash -c "echo +\"$1\" > /proc/net/xt_recent/iptables_watchlist"; }
function unwatchlist_ip() { sudo bash -c "echo -\"$1\" > /proc/net/xt_recent/iptables_watchlist"; }
function block_ip() { sudo iptables -A INPUT -s $1 -j DROP; }
function unblock_ip() { sudo iptables -D INPUT -s $1 -j DROP; }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment