Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Mac support #489

Merged
merged 4 commits into from
Apr 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions bash/cfScanner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
#
# DESCRIPTION: Scan all 1.5 Mil CloudFlare IP addresses
#
# OPTIONS: ---
# REQUIREMENTS: ThreadCount (integer Number which defines the parallel processes count)
# BUGS: ---
# NOTES: ---
# OPTIONS: -h, --help
# REQUIREMENTS: getopt, jq, git, tput, bc, curl, parallel (version > 20220515), shuf
# AUTHOR: Morteza Bashsiz (mb), morteza.bashsiz@gmail.com
# ORGANIZATION: Linux
# CREATED: 01/24/2023 07:36:57 PM
# REVISION: nomadzzz, armgham, beh-rouz, amini8, mahdibahramih, armineslami, miytiy
# REVISION: nomadzzz, armgham, beh-rouz, amini8, mahdibahramih, armineslami, miytiy, F4RAN
#===============================================================================

export TOP_PID=$$
Expand Down Expand Up @@ -100,8 +98,20 @@ fncSubnetToIP() {
done
done
# Choose random IP addresses from generated IP list
mapfile -t ipList < <(shuf -e "${ipList[@]}")
mapfile -t ipList < <(shuf -e "${ipList[@]:0:$randomNumber}")
if [[ "$osVersion" == "Linux" ]]
then
mapfile -t ipList < <(shuf -e "${ipList[@]}")
mapfile -t ipList < <(shuf -e "${ipList[@]:0:$randomNumber}")
elif [[ "$osVersion" == "Mac" ]]
then
# shellcheck disable=SC2207
ipList=($(printf '%s\n' "${ipList[@]}" | shuf))
# shellcheck disable=SC2207
ipList=($(printf '%s\n' "${ipList[@]:0:$randomNumber}" | shuf))
else
echo "OS not supported only Linux or Mac"
exit 1
fi
for i in "${ipList[@]}"; do
echo "$i"
done
Expand Down Expand Up @@ -212,7 +222,16 @@ function fncCheckIPList {
if [[ "$domainFronting" == "200" ]]
then
mainDomain=$(echo "$configHost" | awk -F '.' '{ print $2"."$3}')
randomUUID=$(cat /proc/sys/kernel/random/uuid)
if [[ "$osVersion" == "Linux" ]]
then
randomUUID=$(cat /proc/sys/kernel/random/uuid)
elif [[ "$osVersion" == "Mac" ]]
then
randomUUID=$(uuidgen | tr '[:upper:]' '[:lower:]')
else
echo "OS not supported only Linux or Mac"
exit 1
fi
configServerName="$randomUUID.$mainDomain"
ipConfigFile="$tempConfigDir/config.json.$ip"
cp "$scriptDir"/config.json.temp "$ipConfigFile"
Expand Down