Skip to content

Instantly share code, notes, and snippets.

@NullArray
Last active October 17, 2020 21:48
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save NullArray/35e3d894fe896ee1d7d8088a3d8175b7 to your computer and use it in GitHub Desktop.
Save NullArray/35e3d894fe896ee1d7d8088a3d8175b7 to your computer and use it in GitHub Desktop.
Wrapper for proxy fetcher to sort on geolocation.
#!/bin/bash
#____ ____ __
#\ \ / /____ _____/ |_ ___________
# \ Y // __ \_/ ___\ __\/ _ \_ __ \
# \ /\ ___/\ \___| | ( <_> ) | \/
# \___/ \___ >\___ >__| \____/|__|
# \/ \/
#--Licensed under GNU GPL 3
#----Authored by Vector/NullArray
##############################################
# Coloring scheme for notfications and logo
ESC="\x1b["
RESET=$ESC"39;49;00m"
CYAN=$ESC"33;36m"
RED=$ESC"31;01m"
GREEN=$ESC"32;01m"
now=$(date)
# Warning
function warning()
{ echo -e "\n$RED [!] $1 $RESET\n"
}
# Green notification
function notification()
{ echo -e "\n$GREEN [+] $1 $RESET\n"
}
# Cyan notification
function notification_b()
{ echo -e "\n$CYAN [-] $1 $RESET\n"
}
function conclude()
{ notification "Operation completed, show results?"
read -p '[Y]es/[N]o: ' choice
if [[ $choice == 'y' || $choice == 'Y' ]]; then
cat /home/$USER/fetch-some-proxies/result.txt
exit 0
else
notification "Done."
exit 0
fi
}
function selector()
{ notification_b "Preconfigured" && sleep 1.5
printf "Secure proxies. Sorted by geolocation.\n"
options=("North America" "South America" "Western Europe" "Eastern Europe" "Asia" "Quit")
PS3='Please enter your choice: '
select opt in "${options[@]}"
do
case $opt in
"North America")
clear && notification "Invoking proxy fetcher." && sleep 1.5
# We'll sneak in common wealth Australia and New Zealand in as well
python fetch.py --country='canada|united states|greenland|australia|new zealand' --max-latency=4 --anonymity='elite|anonymous' --output=proxies.log
# This builds our header for the results.txt file
echo "" >> header.txt
echo "PROXY FETCHER RESULTS:" >> header.txt
echo "" >> header.txt
echo "CONFIG:" >> header.txt
echo "Proxy types: Elite & Anonymous" >> header.txt
echo "GeoLocation: Eastern Europe" >> header.txt
echo "MAX Latency: 4" >> header.txt
echo "Date of operation: $now" >> header.txt
echo "" >> header.txt
cat header.txt >> result.txt
cat proxies.log >> result.txt
rm -rf header.txt
rm -rf proxies.log
# Call conclude function to print results if desired
conclude
printf "%b \n"
;;
"South America")
clear && notification "Invoking proxy fetcher." && sleep 1.5
python fetch.py --country='mexico|argentina|venezuela|colombia|brazil|cuba|ecuador' --max-latency=4 --anonymity='elite|anonymous' --output=proxies.log
# This builds our header for the results.txt file
echo "" >> header.txt
echo "PROXY FETCHER RESULTS:" >> header.txt
echo "" >> header.txt
echo "CONFIG:" >> header.txt
echo "Proxy types: Elite & Anonymous" >> header.txt
echo "GeoLocation: South America" >> header.txt
echo "MAX Latency: 4" >> header.txt
echo "Date of operation: $now" >> header.txt
echo "" >> header.txt
cat header.txt >> result.txt
cat proxies.log >> result.txt
rm -rf header.txt
rm -rf proxies.log
# Call conclude function to print results if desired
conclude
printf "%b \n"
;;
"Western Europe")
clear && notification "Invoking proxy fetcher." && sleep 1.5
python fetch.py --country='germany|belgium|britain|holland|france|italy|switzerland|austria|spain' --max-latency=4 --anonymity='elite|anonymous' --output=proxies.log
# This builds our header for the results.txt file
echo "" >> header.txt
echo "PROXY FETCHER RESULTS:" >> header.txt
echo "" >> header.txt
echo "CONFIG:" >> header.txt
echo "Proxy types: Elite & Anonymous" >> header.txt
echo "GeoLocation: Western Europe" >> header.txt
echo "MAX Latency: 4" >> header.txt
echo "Date of operation: $now" >> header.txt
echo "" >> header.txt
cat header.txt >> result.txt
cat proxies.log >> result.txt
rm -rf header.txt
rm -rf proxies.log
# Call conclude function to print results if desired
conclude
printf "%b \n"
;;
"Eastern Europe")
clear && notification "Invoking proxy fetcher." && sleep 1.5
python fetch.py --country='russia|ukraine|belarus|moldova|latvia|hungary|estonia' --max-latency=4 --anonymity='elite|anonymous' --output=proxies.log
# This builds our header for the results.txt file
echo "" >> header.txt
echo "PROXY FETCHER RESULTS:" >> header.txt
echo "" >> header.txt
echo "CONFIG:" >> header.txt
echo "Proxy types: Elite & Anonymous" >> header.txt
echo "GeoLocation: Eastern Europe" >> header.txt
echo "MAX Latency: 4" >> header.txt
echo "Date of operation: $now" >> header.txt
echo "" >> header.txt
cat header.txt >> result.txt
cat proxies.log >> result.txt
rm -rf header.txt
rm -rf proxies.log
# Call conclude function to print results if desired
conclude
printf "%b \n"
;;
"Asia")
clear && notification "Invoking proxy fetcher." && sleep 1.5
python fetch.py --country='china|japan|korea|thailand|india|bangladesh|hong kong' --max-latency=4 --anonymity='elite|anonymous' --output=proxies.log
# This builds our header for the results.txt file
echo "" >> header.txt
echo "PROXY FETCHER RESULTS:" >> header.txt
echo "" >> header.txt
echo "CONFIG:" >> header.txt
echo "Proxy types: Elite & Anonymous" >> header.txt
echo "GeoLocation: Asia" >> header.txt
echo "MAX Latency: 4" >> header.txt
echo "Date of operation: $now" >> header.txt
echo "" >> header.txt
cat header.txt >> result.txt
cat proxies.log >> result.txt
rm -rf header.txt
rm -rf proxies.log
# Call conclude function to print results if desired
conclude
printf "%b \n"
;;
"Quit")
exit 1
;;
*) echo invalid option;;
esac
done
}
clear
notification "Initializing..." && sleep 1.5
if [[ -d "fetch-some-proxies" ]]; then
cd /home/$USER/fetch-some-proxies/
selector
else
warning "Proxy fetcher not found."
printf "Cloning latest version from Github.\n" && sleep 1
git clone https://github.com/stamparm/fetch-some-proxies.git
notification "Done." && sleep 1
cd /home/$USER/fetch-some-proxies/
selector
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment