Skip to content

Instantly share code, notes, and snippets.

@notdodo
Last active April 15, 2018 21:17
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 notdodo/aa1d1136a32d4e8bac650ede2402c5ed to your computer and use it in GitHub Desktop.
Save notdodo/aa1d1136a32d4e8bac650ede2402c5ed to your computer and use it in GitHub Desktop.
Block an IP (better inside a loop for multiple IPs) in Wordfence plugin
#/usr/bin/env zsh
#
echo "Block IP \"${1}\""
echo "========================================="
local domain="www.mymegasite.org"
local user_agent="Mozilla/5.0 (X11; Linux x86_64; rv:55.0) Gecko/20100101 Firefox/55.0"
local nonce="COPY-PASTED-NONCE"
local data="IP=${1}&reason=Manual+block+by+administrator&perm=1&action=wordfence_blockIP&nonce=${nonce}"
local cookie="COPY-PASTED-COOKIE"
curl "${domain}/wp-admin/admin-ajax.php" \
-w "\n\n" \
-H "Host: ${domain}" \
-H "User-Agent: ${user_agent}" \
-H 'Accept: application/json, text/javascript, */*; q=0.01' \
-H "Referer: http://${domain}/wp-admin/admin.php?page=WordfenceBlocking" \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
-H "Cookie: ${cookie}" \
--data ${data}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment