up_imgbox.sh
Manual Torification Required
This script was written with the belief that socks5 proxies could not stack without a system like Whonix
This is incorrect, it just requires a workaround:
torsocks -i ./up_imgbox.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 | #!/bin/bash
echo -e "\e]0;up_imgbox.sh\a"
file="$1"
proxy="ip:port" # socks5
ua="Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0"
cookies=$(mktemp /tmp/_imgbox_session.XXXXXX)
r="$(tput rev)" #invert
b="$(tput bold)"
res="$(tput sgr0)" #reset
blue="${b}$(tput setaf 110)"
yellow="${b}$(tput setaf 184)"
hres=$(tput clear; printf '%s\n' "${r}up_imgbox.sh${res}\t${blue} $(basename "${file#/*}") ${res}\n\n") # persistent title (hres="hard reset")
echo -e "$hres"
echo -ne "${yellow}Getting CSRF token...${res}"
#Step 1: Get CSRF authenticity token from response header, initialise cookies
init=$(curl --proxy "$proxy" -c "$cookies" -sLi \
-X GET \
-H "User-Agent: $ua" \
-H "Referer: https://imgbox.com/" \
-H "Origin: https://www.imgbox.com" \
-H "Content-Type: application/x-www-form-urlencoded" \
"https://imgbox.com/")
csrf_token=$(grep -Po '(?<=<meta content=").*(?=" name="csrf-token" />)' <<< "${init}" )
echo -e "\t$csrf_token\n\n"
echo -e "$hres"
echo -ne "${yellow}Generating token_id & token_secret...${res}"
#Step 2: Generate token_id and secret
generate=$(curl --proxy "$proxy" -b "$cookies" -c "$cookies" -Ls \
-X POST \
-H "User-Agent: $ua" \
-H "Accept: application/json, text/javascript, */*; q=0.01" \
-H "Referer: https://imgbox.com/" \
-H "Origin: https://www.imgbox.com" \
-H "X-CSRF-Token: ${csrf_token}" \
-H "X-Requested-With: XMLHttpRequest" \
-H "Content-Type: application/x-www-form-urlencoded; charset=UTF-8" \
"https://imgbox.com/ajax/token/generate")
token_id=$(jq -r '.token_id' <<< "${generate}")
token_st=$(jq -r '.token_secret' <<< "${generate}")
echo -e "\t$token_id & $token_st\n\n"
echo -e "${yellow}Uploading image...${res}"
#Step 3: POST file
process=$(curl --proxy "$proxy" -b "$cookies" -Ls \
-X POST \
-H "User-Agent: $ua" \
-H "Referer: https://imgbox.com/" \
-H "Origin: https://imgbox.com" \
-H "Content-Type: multipart/form-data" \
-H "X-CSRF-Token: ${csrf_token}" \
-H "X-Requested-With: XMLHttpRequest" \
-F "files[]=@${file}" \
-F "content_type=2" \
-F "thumbnail_size=300r" \
-F "comments_enabled=0" \
-F "gallery_id=" \
-F "gallery_secret=" \
-F "token_id=${token_id}" \
-F "token_secret=${token_st}" \
"https://imgbox.com/upload/process")
viewer_url=$(jq -r '.files[].url' <<< "${process}")
direct_url=$(jq -r '.files[].original_url' <<< "${process}")
echo -e "Viewer URL: ${viewer_url}"
echo -e "Direct URL: ${direct_url}"
echo -e "BBCode URL: [img]${direct_url}[/img]"
|