diff options
Diffstat (limited to 'utils/whatsapp_ip_addresses_download.sh')
-rwxr-xr-x | utils/whatsapp_ip_addresses_download.sh | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/utils/whatsapp_ip_addresses_download.sh b/utils/whatsapp_ip_addresses_download.sh index f36f4fed3..722841015 100755 --- a/utils/whatsapp_ip_addresses_download.sh +++ b/utils/whatsapp_ip_addresses_download.sh @@ -7,16 +7,23 @@ cd "$(dirname "${0}")" || exit 1 DEST=../src/lib/inc_generated/ndpi_whatsapp_match.c.inc TMP=/tmp/wa.zip LIST=/tmp/wa.list +USER_AGENT='Mozilla/5.0 (X11; Linux x86_64) Gecko/20100101 Firefox' IP_LINK_URL='https://developers.facebook.com/docs/whatsapp/guides/network-requirements/' echo "(1) Scraping Facebook WhatsApp IP Adresses and Ranges..." -ORIGIN="$(curl -s "${IP_LINK_URL}" | sed -ne 's/.*<a href="\([^"]*\)" target="_blank">WhatsApp server IP addresses and ranges (.zip file)<\/a>.*/\1/gp' | sed -e 's/\&/\&/g')" +ORIGIN="$(curl -H "User-Agent: ${USER_AGENT}" -s "${IP_LINK_URL}" | sed -n 's/.*<a href="\(https:\/\/scontent.*\.zip?.*\)" target="_blank">.*/\1/gp')" + +if [ -z "${ORIGIN}" ]; then + echo "Error: IP webpage list does not contain any addresses. A REGEX update may be required." + exit 1 +fi echo "(2) Downloading file... ${ORIGIN}" -http_response=$(curl -s -o $TMP -w "%{http_code}" ${ORIGIN}) +http_response=$(curl -H "User-Agent: ${USER_AGENT}" -H "Referer: https://developers.facebook.com/" -s -o $TMP -w "%{http_code}" ${ORIGIN}) if [ "$http_response" != "200" ]; then echo "Error $http_response: you probably need to update the list url!" + echo "Response: $(cat ${TMP})" exit 1 fi |