mad/hosts/up_ranoz.sh
kittykat 270e378e08
# 2025.03.30 - [ranoz] Fix to handle new cookie requirements
# 2025.03.28 - [up_ranoz] Fix to handle new cookie requirements
# 2025.03.28 - [up_anonfileio] Add anonfile.io as upload host
# 2025.03.28 - [anonfileio] Add anonfile.io as download host
# 2025.03.25 - [up_ranoz] Disable MAD randomized extension on uploads (7z block disabled)
# 2025.03.21 - [mad] Update random user agents 2025.03
# 2025.03.20 - [jira hosts] Update 3 jira hosts (retention and maxsize)
# 2025.03.16 - [torup] Fix torup cookies
# 2025.03.15 - [1fichier] Get new node prior to cdn download (greater possibility of a faster node)
# 2025.03.10 - [uploadscloud] Add uploadscloud.com as download host
2025-04-01 07:09:17 +00:00

243 lines
9.8 KiB
Bash

#! Name: up_ranoz.sh
#! Author: kittykat
#! Version: 2025.03.30
#! Desc: Add support for uploading files to bedrive.ru
#! Info: Files are accessible at https://ranoz.gg/file/<file_code>
#! MaxSize: 20GB
#! Expire: ??
#! Usage: Copy this file into the ./${ScriptDir}/hosts/ folder
#!
#!
#! ------------ REQUIRED SECTION ---------------
#! @[UPDATE] ListUploadHosts: This string is loaded into mad.sh and allows dynamic handling of new url data
#! Format: '/HostCode/HostNick/HostFuncPrefix@'
#! HostCode: <aUniqueCodeForHost> (ie. 'fh' for filehaus -- cannot be used by other hosts)
#! HostNick: What is displayed throughout MAD output
#! HostFuncPrefix: <aUniqueStringThatMustPrefixHostFunctions> ie. 'fh' -- fh_UploadFile()
#! * Note: Must begin with a letter a-z (functions beginning with numbers are no bueno)
HostCode='rz'
HostNick='ranoz.gg'
HostFuncPrefix='rz'
#!
#! !! DO NOT UPDATE OR REMOVE !!
#! This merges the Required HostAndDomainRegexes into mad.sh
ListUploadHosts=${ListUploadHosts}'/'${HostCode}'/'${HostNick}'/'${HostFuncPrefix}'@'
#!
#!
#! Configurables
#! -------------
#!
#! ------------ (1) Host Main Upload Function --------------- #
#!
#! @REQUIRED: Host Main Upload function
#! Must be named specifically as such:
#! <HostFuncPrefix>_UploadFile()
rz_UploadFile() {
local _hostCode=${1}
local filepath=${2}
local filecnt=${3}
local pline=${4}
local filename="${filepath##*/}"
warnAndRetryUnknownError=false
exitUploadError=false
exitUploadNotAvailable=false
fileAlreadyDone=false
tor_identity="${RANDOM}"
UploadTicket="${WorkDir}/.flocks/upload_${_hostCode}_${filepath//[^a-zA-Z0-9]/}"
MaxUploadSizeInBytes=21474836480
fsize=$(GetFileSize "$filepath" "false")
if ((fsize > MaxUploadSizeInBytes)); then
rm -f "${UploadTicket}"
echo -e "${YELLOW}| SKIP${NC}: The size of $filename is to large for $_hostCode. ($fsize > $MaxUploadSizeInBytes)"
failedUpload "$pline" "${filepath}" "${_hostCode}" "Skipping upload. The size of $filename is to large for $_hostCode. ($fsize > $MaxUploadSizeInBytes)"
return 1
fi
finalAttempt="false"
for ((z=0; z<=$MaxUploadRetries; z++)); do
if [[ $z -eq $MaxUploadRetries ]] ; then
finalAttempt="true"
fi
trap "rm -f "${UploadTicket}"; echo ""; tput cnorm; exit" 0 1 2 3 6 15
if rz_PostFile "${filepath}" "${_hostCode}" "${filename}" "${filecnt}" $((z+1)) $finalAttempt $pline ; then
return 0
elif [[ $z -lt $MaxUploadRetries ]]; then
if [[ "${fileAlreadyDone}" == "true" ]] ; then
break
fi
if [[ "${warnAndRetryUnknownError}" == "true" ]] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${filepath##*/}" "error" "Retry due to an unknown issue: attempt #$((z+1)) of ${MaxUploadRetries}"
fi
fi
if [[ "${exitUploadError}" == "true" || "${exitUploadNotAvailable}" == "true" ]] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${filepath##*/}" "error" "Exit due to unrecoverable issue"
fi
rm -f "${UploadTicket}"
break
fi
echo -e "\n${YELLOW}A recoverable error occurred, retry attempt $((z+1))/${MaxUploadRetries}${NC}"
sleep 3
fi
done
rm -f "${UploadTicket}"
}
#!
#! ----------- (2) Post File / Upload File Function --------------- #
#!
rz_PostFile() {
local filepath=$1
local _hostCode=$2
local filename=$3
local fileCnt=$4
local retryCnt=$5
local finalAttempt=$6
local pline=${7}
UploadTicket="${WorkDir}/.flocks/upload_${_hostCode}_${filepath//[^a-zA-Z0-9]/}"
echo -e "[${YELLOW}${_hostCode}${NC}] Uploading ${GREEN}${filename}${NC}"
tor_identity="${RANDOM}"
mkdir -p "${WorkDir}/.temp"
up_rz_cookie_jar=$(mktemp "${WorkDir}/.temp/up_rz_cookies""${instance_no}"".XXXXXX")
PrePostUrl='https://finer-yeti-69.clerk.accounts.dev/v1/client/handshake?redirect_url=https%3A%2F%2Franoz.gg%2Fapi%2Fv1%2Ffiles%2Fupload_url&suffixed_cookies=false&__clerk_hs_reason=dev-browser-missing'
PostUrlHost='https://ranoz.gg/api/v1/files/upload_url'
RanozRandomizeExt="false"
if [[ "$RanozRandomizeExt" == "true" ]] && [[ ! $filename == *.rar ]]; then
randomext=$(GetSemiRandomExt)
echo -e "${BLUE}MAD Randomized Extension: $randomext${NC}"
origext=${filepath##*.}
if [[ "$origext" == "7z" ]]; then
tmpfilepath="${filepath%.*}--7_.${randomext}"
elif [[ "$origext" == "zip" ]]; then
tmpfilepath="${filepath%.*}--z_.${randomext}"
elif grep -Eqi '\.part.*\.rar' <<< "${filepath##*/}" ; then
partnum="${filepath##*.part}"
partnum="${partnum%.rar*}"
echo -e "$partnum"
tmpfilepath="${filepath%.part*}_-p${partnum}--r_.${randomext}"
elif [[ "$origext" == "rar" ]]; then
tmpfilepath="${filepath%.*}--r_.${randomext}"
elif [[ "$origext" == "tar" ]]; then
tmpfilepath="${filepath%.*}--t_.${randomext}"
elif [[ "${filepath##*/}" == *".7z."* ]]; then
tmpfilepath="${filepath%\.7z*}${filepath##*\.7z}"
tmpfilepath="${tmpfilepath%.*}_-7--${origext}_.${randomext}"
else
tmpfilepath="${filepath%.*}--${origext}_.${randomext}"
fi
tmpfilename="${tmpfilepath##*/}"
else
tmpfilename="${filepath##*/}"
fi
local fsize=$(stat -c%s "$filepath")
trap "rm -f ${UploadTicket}; rm -f ${up_rz_cookie_jar}; echo ""; tput cnorm; exit" 0 1 2 3 6 15
response=$(tor_curl_upload --insecure -L -i -s \
-b "${up_rz_cookie_jar}" -c "${up_rz_cookie_jar}" \
"$PrePostUrl")
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${filepath##*/}" "${_hostCode}_prepost" "prepost_url: ${PrePostUrl}"$'\n'"${response}"
fi
trap "rm -f ${UploadTicket}; rm -f ${up_rz_cookie_jar}; echo ""; tput cnorm; exit" 0 1 2 3 6 15
response=$(tor_curl_upload --insecure -Lis \
"$PostUrlHost" \
-b "${up_rz_cookie_jar}" -c "${up_rz_cookie_jar}" \
-H "Content-Type: application/json" \
-d "{ \
\"filename\": \"$tmpfilename\", \
\"size\": $fsize}")
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${filepath##*/}" "${_hostCode}_ticket" "post_url: ${PostUrlHost}"$'\n'"data: ${filepath}, ${fsize}"$'\n'"${response}"
fi
if grep -Eqi '"upload_url":"https://' <<< "$response" ; then
PostUrlHost=$(grep -oPi '(?<="upload_url":").*?(?=".*$)' <<< "$response")
downloadLink=$(grep -oPi '(?<=,"url":").*?(?=".*$)' <<< "$response")
echo -e "${GREEN}| Upload url obtained...${NC}"
else
rm -f ${up_rz_cookie_jar};
err=$(grep -oPi '(?<="errors":\[\{"message":").*?(?=".*$)' <<< "$response")
if [[ "${finalAttempt}" == "true" ]] ; then
printf "\\n"
echo -e "${RED}| Upload request failed. Status: ${err}${NC}"
failedRetryUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "Status: $err"
exitUploadError=true
return 1
else
return 1
fi
fi
arrFiles=("$filepath")
trap "rm -f ${UploadTicket}; echo ""; rm -f ${up_rz_cookie_jar}; tput cnorm; exit" 0 1 2 3 6 15
response=$(tor_curl_upload --insecure -i -X PUT \
"${PostUrlHost}" \
--upload-file "$filepath" \
-b "${up_rz_cookie_jar}" -c "${up_rz_cookie_jar}" \
-H "Content-Length: $fsize")
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${filepath##*/}" "${_hostCode}_upload" "post_url: ${PostUrlHost}"$'\n'"${response}"
fi
rm -f ${up_rz_cookie_jar};
if grep -Eqi 'HTTP/.* 200' <<< "${response}" ; then
filesize=$(GetFileSize "$filepath" "false")
echo -e "${GREEN}| Upload Success${NC}"
echo -e "| Size: ${BLUE}${filesize}${NC} bytes${NC}"
echo -e "| Link: ${YELLOW}${downloadLink}${NC}"
if [[ "$RanozRandomizeExt" == "true" ]]; then
successUpload "$pline" "${filepath}" "${_hostCode}" "${filesize}" "${downloadLink}" "{$response}" "[rename to $filename or use MAD script]"
else
successUpload "$pline" "${filepath}" "${_hostCode}" "${filesize}" "${downloadLink}" "{$response}"
fi
return 0
else
err=$(grep -oPi '(?<=HTTP/.*).*?(?=$)' <<< "$response")
if [[ "${finalAttempt}" == "true" ]] ; then
printf "\\n"
echo -e "${RED}| Upload failed. Status: ${err}${NC}"
failedRetryUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "Status: $err"
exitUploadError=true
return 1
else
return 1
fi
fi
}
#!
#! --------------- Host Extra Functions ------------------- #
#!
GetSemiRandomExt() {
local ar_rEXT[0]='pdf'
local ar_rEXT[1]='doc'
local ar_rEXT[2]='xls'
local ar_rEXT[3]='mdb'
local ar_rEXT[4]='xml'
local ar_rEXT[5]='xsd'
local ar_rEXT[6]='svg'
local ar_rEXT[7]='img'
local ar_rEXT[8]='iso'
local ar_rEXT[9]='svg'
local ar_rEXT[10]='ico'
local ar_rEXT[11]='bmp'
local ar_rEXT[12]='eps'
local ar_rEXT[13]='3gp'
local ar_rEXT[14]='png'
local ar_rEXT[15]='wav'
local ar_rEXT[16]='mp3'
local ar_rEXT[17]='tif'
local ar_rEXT[18]='swf'
local ar_rEXT[19]='rtf'
local ar_rEXT[20]='ppt'
local ar_rEXT[21]='png'
local ar_rEXT[22]='jpg'
local ar_rEXT[23]='mpg'
local ar_rEXT[24]='mp4'
local ar_rEXT[25]='aac'
local ar_rEXT[26]='mid'
local ar_rEXT[27]='ics'
local ar_rEXT[28]='gif'
local ar_rEXT[29]='csv'
local ar_rEXT[30]='ogg'
local ar_rEXT[31]='txt'
local ar_rEXT[32]='css'
local ar_rEXT[33]='htm'
local arrSize=${#ar_rEXT[@]}
local index=$(($RANDOM % $arrSize))
printf "%s" "${ar_rEXT[$index]}"
}