diff --git a/documentation/README-upload_hosts.txt b/documentation/README-upload_hosts.txt index 4d58e6c..3d01144 100755 --- a/documentation/README-upload_hosts.txt +++ b/documentation/README-upload_hosts.txt @@ -20,6 +20,7 @@ Max Size . HostCode . Nickname . Notes * 2GB axfc axfc.net 90d+ inactive expiry - 1GB kraken krakenfiles.com 90d inactive expiry 1GB ansh anonsharing.com 6mo expiry + 1GB torp TorUp.onion 30d inactive expiry 300MB trbo turbo.onion ~40d expiry 250MB upev uploadev.org 90d inactive expiry * 240MB ko kouploader.jp 5mo expiry (240MB max) diff --git a/hosts/torup.sh b/hosts/torup.sh index 7c2d423..1ced86b 100644 --- a/hosts/torup.sh +++ b/hosts/torup.sh @@ -14,7 +14,7 @@ #! * Note: Must begin with a letter a-z (functions beginning with numbers are no bueno) #! HostDomainRegex: The regex used to verify matching urls HostCode='torp' -HostNick='torup' +HostNick='TorUp' HostFuncPrefix='torp' HostUrls='ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion' HostDomainRegex='^(http|https)://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd\.onion/' @@ -171,7 +171,7 @@ torp_FetchFileInfo() { #! ----------- (3) Fetch File / Download File Function --------------- # #! torp_GetFile() { - echo -e "${GREEN}# Downloading…" + echo -e "${GREEN}# Downloading…${NC} ${BLUE}(No resume)${NC}" echo -e "${YELLOW}| File path:${NC}\t./.inflight/${filename}\n" fileCnt=$1 retryCnt=$2 @@ -191,12 +191,12 @@ torp_GetFile() { --speed-limit $DownloadSpeedMin --speed-time $DownloadTimeoutInterval \ -b "${torp_cookie_jar}" -c "${torp_cookie_jar}" \ -H "Referer: $fixed_url" \ - "$download_url" --continue-at - --output "$file_path" + "$download_url" --output "$file_path" else tor_curl_request --insecure -L -G --no-alpn \ -b "${torp_cookie_jar}" -c "${torp_cookie_jar}" \ -H "Referer: $fixed_url" \ - "$download_url" --continue-at - --output "$file_path" + "$download_url" --output "$file_path" fi else if [ "${RateMonitorEnabled}" == "true" ]; then @@ -214,7 +214,7 @@ torp_GetFile() { -H "Sec-Fetch-Site: same-origin" \ -H "Sec-Fetch-User: ?1" \ -b "${torp_cookie_jar}" -c "${torp_cookie_jar}" \ - "$download_url" --continue-at - --output "$file_path" + "$download_url" --output "$file_path" else tor_curl_request --insecure -L -G --no-alpn \ -H "User-Agent: $RandomUA" \ @@ -229,7 +229,7 @@ torp_GetFile() { -H "Sec-Fetch-Site: same-origin" \ -H "Sec-Fetch-User: ?1" \ -b "${torp_cookie_jar}" -c "${torp_cookie_jar}" \ - "$download_url" --continue-at - --output "$file_path" + "$download_url" --output "$file_path" fi fi received_file_size=0 diff --git a/hosts/up_torup.sh b/hosts/up_torup.sh new file mode 100644 index 0000000..6e58041 --- /dev/null +++ b/hosts/up_torup.sh @@ -0,0 +1,186 @@ +#! Name: up_torup.sh +#! Author: kittykat +#! Version: 2024.11.09 +#! Desc: Add support for uploading files to ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion +#! Info: Files are accessible at http://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion/download/ +#! MaxSize: 1GB +#! Expire: 30d inactive expiry +#! 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: (ie. 'fh' for filehaus -- cannot be used by other hosts) +#! HostNick: What is displayed throughout MAD output +#! HostFuncPrefix: ie. 'fh' -- fh_UploadFile() +#! * Note: Must begin with a letter a-z (functions beginning with numbers are no bueno) +HostCode='torp' +HostNick='TorUp' +HostFuncPrefix='torp' +#! +#! !! 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: +#! _UploadFile() +torp_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=1073741824 + fsize=$(GetFileSize "$filepath" "false") + if ((fsize > MaxUploadSizeInBytes)); then + m -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 torp_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 --------------- # +#! +torp_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}" + PostUrlHost='http://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion/upload' + local csrf_token='' + maxfetchretries=3 + echo -e "${GREEN}# Initializing…${NC}" + for ((i=1; i<=$maxfetchretries; i++)); do + mkdir -p "${WorkDir}/.temp" + torp_cookie_jar=$(mktemp "${WorkDir}/.temp/torp_cookies""${instance_no}"".XXXXXX") + printf " ." + tor_identity="${RANDOM}" + trap "rm -f ${UploadTicket}; rm -f ${torp_cookie_jar}; echo ""; tput cnorm; exit" 0 1 2 3 6 15 + response=$(tor_curl_request --insecure -L -s -b "${torp_cookie_jar}" -c "${torp_cookie_jar}" \ + "http://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion") + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "torp_fetch$i" "${response}" + fi + if [[ -z $response ]] ; then + rm -f "${torp_cookie_jar}"; + if [ $i == $maxfetchretries ] ; then + printf "\\n" + echo -e "${RED}| Failed to start an upload [1]${NC}" + warnAndRetryUnknownError=true + if [ "${finalAttempt}" == "true" ] ; then + failedRetryDownload "${remote_url}" "Failed to start an upload [1]" "" + fi + return 1 + else + continue + fi + fi + if grep -Eqi 'input type="hidden" name="gorilla.csrf.Token" value="' <<< "$response"; then + csrf_token=$(grep -oP '(?<=name\="gorilla.csrf.Token" value\=").*?(?=".*$)' <<< "$response") + else + rm -f "${torp_cookie_jar}"; + if [ $i == $maxfetchretries ] ; then + printf "\\n" + echo -e "${RED}| Failed to start an upload [2]${NC}" + warnAndRetryUnknownError=true + if [ "${finalAttempt}" == "true" ] ; then + failedRetryDownload "${remote_url}" "Failed to start an upload [2]" "" + fi + return 1 + else + continue + fi + fi + printf "\\n" + break + done + arrFiles=("$filepath") + trap "rm -f ${UploadTicket}; rm -f ${torp_cookie_jar}; echo ""; tput cnorm; exit" 0 1 2 3 6 15 + response=$(tor_curl_upload --insecure -i \ + -H "Content-Type: multipart/form-data" \ + -H "Referer: http://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion/" \ + -H "Origin: http://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion" \ + -F "gorilla.csrf.Token=$csrf_token" \ + -F "file_type=free" \ + -F "file=@${filepath}" \ + -b "${torp_cookie_jar}" -c "${torp_cookie_jar}" \ + "${PostUrlHost}") + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "${_hostCode}_upload" "post_url: ${PostUrlHost}"$'\n'"csrf_token: ${csrf_token}"$'\n'"${response}" + fi + rm -f ${torp_cookie_jar} + if grep -Eqi 'input type="text" value="http://ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion/download/' <<< "${response}" ; then + url=$(grep -oPi '(?<=input type\="text" value\=").*?(?=".*$)' <<< "$response") + filesize=$(GetFileSize "$filepath" "false") + downloadLink="$url" + echo -e "${GREEN}| Upload Success${NC}" + echo -e "| Size: ${BLUE}${filesize}${NC} bytes${NC}" + echo -e "| Link: ${YELLOW}${downloadLink}${NC}" + successUpload "$pline" "${filepath}" "${_hostCode}" "${filesize}" "${downloadLink}" "{$response}" + 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 ------------------- # +#! diff --git a/mad.sh b/mad.sh index 6bed4cd..688955d 100644 --- a/mad.sh +++ b/mad.sh @@ -31,13 +31,13 @@ # * klonkerz - feedback and suggestions, url only processing # * Everyone who provided feedback and helped test.. and those who wish to remain anonymous -ScriptVersion=2024.11.09 +ScriptVersion=2024.11.10 #================================================= # Recent Additions -# 2024.11.09 - [torup] Add TorUp as a download host +# 2024.11.10 - [up_torup] Add TorUp as an upload host +# 2024.11.09 - [torup] Add TorUp as a download host (no resume) # (ktgzpea2b76u7fgemiibp4a76onyybo4fw5gbsagtm6jrjzmgivppyyd.onion) # 2024.11.08 - [nippy] Fix nippydrive.com. Update detection of temporarily unavailable response. -# 2024.11.08 - [nippy] Fix nippydrive.com. Update detection of temporarily unavailable response. # 2024.11.08 - [up2share] Fix download url (https) # 2024.11.08 - [up2share] Fix advertised filesize on a redirection # 2024.11.06 - [SkipUrlsInDownloadsCompletedTxt] Fix blank url check diff --git a/uploads.txt b/uploads.txt index 2abebcd..fd678e8 100755 --- a/uploads.txt +++ b/uploads.txt @@ -11,7 +11,7 @@ # 10GB nlib netlib.re 195MB dup dataupload.net 2GB axfc axfc.net # 10GB raja uploadraja.com 240MB ko kouploader.jp 4GB tmpsh temp.sh # 10GB tmpme tempfile.me 300MB trbo turbo.onion 100MB inno innocent.onion -# 1GB ansh anonsharing.com +# 1GB ansh anonsharing.com 1GB torp TorUp.onion # ?? fr4e sendfree4e.fr ?? harr harrault.fr ?? acid dl.acid.fr # (Require js -- do not use) # 4GB daily dailyuploads 1GB kraken krakenfiles 2GB hex hexload