
Condivisione di file facile e veloce dalla riga di comando.
Bypass del filtro IP e dell'autenticazione HTTP tramite spoofing non autenticato dell'header X-Forwarded-For
Condivisione di file facile e veloce dalla riga di comando. Questo codice contiene il server con tutto il necessario per creare la propria istanza.
Transfer.sh attualmente supporta i provider s3 (Amazon S3), gdrive (Google Drive), storj (Storj) e il file system locale (local).
@stefanbenten è un manutentore di questo repository e la persona che ospita una nota installazione pubblica del software nel repository.
Le due cose sono comunque indipendenti, e il repository non è il luogo a cui indirizzare richieste e segnalazioni per nessuna delle installazioni pubbliche.
Nessuna installazione pubblica di terze parti del software nel repository sarà pubblicizzata o menzionata nel repository stesso, per ragioni di sicurezza.
La posizione ufficiale mia, @aspacca, come manutentore del repository, è che se desideri utilizzare il software dovresti ospitare la tua installazione.
Questa sezione descrive come utilizzare transfer.sh
$ curl -v --upload-file ./hello.txt https://transfer.sh/hello.txt
<br />
### Cripta e Carica```bash
$ gpg --armor --symmetric --output - /tmp/hello.txt | curl --upload-file - https://transfer.sh/test.txt
$ curl https://transfer.sh/1lDau/test.txt | gpg --decrypt --output /tmp/hello.txt
<br />
### Carica su Virustotal```bash
$ curl -X PUT --upload-file nhgbhhj https://transfer.sh/test.txt/virustotal
$ curl -X DELETE
<br />
---
<br />
## Intestazioni delle Richieste
Questa sezione spiega come gestire le intestazioni delle richieste con curl:
<br />
### Max-Downloads```bash
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Downloads: 1" # Limit the number of downloads
$ curl --upload-file ./hello.txt https://transfer.sh/hello.txt -H "Max-Days: 1" # Set the number of days before deletion
<br />
### X-Encrypt-Password
#### Attenzione, utilizza questa funzione solo sul tuo server self-hosted: affidarsi a un servizio di terze parti per la crittografia lato server è a tuo rischio.```bash
$ curl --upload-file ./hello.txt https://your-transfersh-instance.tld/hello.txt -H "X-Encrypt-Password: test" # Encrypt the content server side with AES256 using "test" as password
$ curl https://your-transfersh-instance.tld/BAYh0/hello.txt -H "X-Decrypt-Password: test" # Decrypt the content server side with AES256 using "test" as password
<br />
---
<br />
## Intestazioni di Risposta
Questa sezione spiega come gestire le intestazioni di risposta:
<br />
### X-Url-Delete
L'URL utilizzato per richiedere l'eliminazione di un file e restituito come intestazione di risposta:```bash
curl -sD - --upload-file ./hello.txt https://transfer.sh/hello.txt | grep -i -E 'transfer\.sh|x-url-delete'
x-url-delete: https://transfer.sh/hello.txt/BAYh0/hello.txt/PDw0NHPcqU
https://transfer.sh/hello.txt/BAYh0/hello.txt
Vedi buoni esempi di utilizzo su examples.md
Crea link di download diretto:
https://transfer.sh/1lDau/test.txt --> https://transfer.sh/get/1lDau/test.txt
File inline:
https://transfer.sh/1lDau/test.txt --> https://transfer.sh/inline/1lDau/test.txt
Se desideri utilizzare TLS con i certificati Let's Encrypt, imposta lets-encrypt-hosts sul tuo dominio, imposta tls-listener su :443 e abilita force-https.
Se desideri utilizzare TLS con i tuoi certificati, imposta tls-listener su :443, force-https, tls-cert-file e tls-private-key.
Passato a GO111MODULE```bash go run main.go --provider=local --listener :8080 --temp-path=/tmp/ --basedir=/tmp/
<br />
---
<br />
## Compilazione```bash
$ git clone [email protected]:dutchcoders/transfer.sh.git
$ cd transfer.sh
$ go build -o transfersh main.go
Per una facile distribuzione, abbiamo creato un contenitore Docker ufficiale. Ci sono due varianti, che differiscono solo per l'utente che esegue il processo.
Quella predefinita verrà eseguita come root:
[!WARNING] È scoraggiato utilizzare il tag
latestper WatchTower o strumenti simili. Il taglatestpuò fare riferimento a build di sviluppo non rilasciate, build di test e patch release per versioni precedenti. Utilizza un tag di versione effettivo fino a quando transfer.sh non supporterà tag di versione major o minor.```bash docker run --publish 8080:8080 dutchcoders/transfer.sh:latest --provider local --basedir /tmp/
<br />
### No root
I tag `-noroot` indicano build di immagini che vengono eseguite con il minimo privilegio per ridurre la superficie d'attacco qualora un'applicazione venga compromessa.
> [!NOTE]
> L'uso di `-noroot` è **raccomandato**
<br />
Quella con il suffisso `-noroot` utilizzerà `5000` sia come UID che come GID:```bash
docker run --publish 8080:8080 dutchcoders/transfer.sh:latest-noroot --provider local --basedir /tmp/
[!NOTE] Dettagli della cronologia di sviluppo presso:
Puoi anche costruire il contenitore da solo. Questo ti permette di scegliere quale UID/GID verrà utilizzato, ad esempio quando si usano mount NFS:```bash
docker build -t transfer.sh-noroot --build-arg RUNAS=doesntmatter --build-arg PUID=1337 --build-arg PGID=1338 .
<br />
---
<br />
## Utilizzo S3
Per l'utilizzo con un bucket AWS S3, è sufficiente specificare le seguenti opzioni:
- provider `--provider s3`
- aws-access-key _(tramite flag o variabile d'ambiente `AWS_ACCESS_KEY`)_
- aws-secret-key _(tramite flag o variabile d'ambiente `AWS_SECRET_KEY`)_
- bucket _(tramite flag o variabile d'ambiente `BUCKET`)_
- s3-region _(tramite flag o variabile d'ambiente `S3_REGION`)_
Se specifichi la s3-region, non è necessario impostare l'URL dell'endpoint poiché verrà utilizzato automaticamente l'endpoint corretto.
<br />
### Provider S3 personalizzati
Per utilizzare un provider S3 personalizzato non AWS, è necessario specificare l'endpoint come definito dal tuo cloud provider.
<br />
---
<br />
## Provider Storj Network
Per utilizzare la rete Storj come provider di archiviazione, è necessario specificare i seguenti flag:
- provider `--provider storj`
- storj-access _(tramite flag o variabile d'ambiente STORJ_ACCESS)_
- storj-bucket _(tramite flag o variabile d'ambiente STORJ_BUCKET)_
<br />
### Creazione del Bucket e dell'Scope
È necessario creare un access grant (o copiarlo dalla configurazione uplink) e un bucket in preparazione.
Per iniziare, accedi al tuo account e vai al menu Access Grant e avvia la procedura guidata in alto a destra.
Inserisci il nome dell'access grant desiderato, premi *Next* e limitalo come necessario/preferito.
Successivamente continua tramite CLI o all'interno del browser. Successivamente, ti verrà chiesta una passphrase utilizzata come chiave di crittografia.
**Assicurati di salvarla in un luogo sicuro. Senza di essa, perderai la possibilità di decrittare i tuoi file!**
Successivamente, puoi copiare l'access grant e quindi avviare l'endpoint di transfer.sh.
Si consiglia di fornire sia l'access grant che il nome del bucket come variabili d'ambiente per una maggiore sicurezza.
Esempio:```
export STORJ_BUCKET=<BUCKET NAME>
export STORJ_ACCESS=<ACCESS GRANT>
transfer.sh --provider storj
Per l'utilizzo con Google drive, è necessario specificare le seguenti opzioni:
Devi creare un ID client OAuth da console.cloud.google.com, scaricare il file e posizionarlo in una directory sicura.
go run main.go --provider gdrive --basedir /tmp/ --gdrive-client-json-filepath /[credential_dir] --gdrive-local-config-path [directory_to_save_config] transfer() ( if [ $# -eq 0 ]; then printf "Nessun argomento specificato.\nUtilizzo:\n transfer <file|directory>\n ... | transfer <nome_file>\n">&2; return 1; fi; file_name=$(basename "$1"); if [ -t 0 ]; then file="$1"; if [ ! -e "$file" ]; then echo "$file: File o directory inesistente">&2; return 1; fi; if [ -d "$file" ]; then cd "$file" || return 1; file_name="$file_name.zip"; set -- zip -r -q - .; else set -- cat "$file"; fi; else set -- cat; fi; url=$("$@" | curl --silent --show-error --progress-bar --upload-file "-" "https://transfer.sh/$file_name"); echo "$url"; )```
<br />
#### Now you can use transfer function
$ transfer hello.txt```
transfer()
{
local file
declare -a file_array
file_array=("${@}")
if [[ "${file_array[@]}" == "" || "${1}" == "--help" || "${1}" == "-h" ]]
then
echo "${0} - Upload arbitrary files to \"transfer.sh\"."
echo ""
echo "Usage: ${0} [options] [<file>]..."
echo ""
echo "OPTIONS:"
echo " -h, --help"
echo " show this message"
echo ""
echo "EXAMPLES:"
echo " Upload a single file from the current working directory:"
echo " ${0} \"image.img\""
echo ""
echo " Upload multiple files from the current working directory:"
echo " ${0} \"image.img\" \"image2.img\""
echo ""
echo " Upload a file from a different directory:"
echo " ${0} \"/tmp/some_file\""
echo ""
echo " Upload all files from the current working directory. Be aware of the webserver's rate limiting!:"
echo " ${0} *"
echo ""
echo " Upload a single file from the current working directory and filter out the delete token and download link:"
echo " ${0} \"image.img\" | awk --field-separator=\": \" '/Delete token:/ { print \$2 } /Download link:/ { print \$2 }'"
echo ""
echo " Show help text from \"transfer.sh\":"
echo " curl --request GET \"https://transfer.sh\""
return 0
else
for file in "${file_array[@]}"
do
if [[ ! -f "${file}" ]]
then
echo -e "\e[01;31m'${file}' could not be found or is not a file.\e[0m" >&2
return 1
fi
done
unset file
fi
local upload_files
local curl_output
local awk_output
du -c -k -L "${file_array[@]}" >&2
# be compatible with "bash"
if [[ "${ZSH_NAME}" == "zsh" ]]
then
read $'upload_files?\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m'
elif [[ "${BASH}" == *"bash"* ]]
then
read -p $'\e[01;31mDo you really want to upload the above files ('"${#file_array[@]}"$') to "transfer.sh"? (Y/n): \e[0m' upload_files
fi
case "${upload_files:-y}" in
"y"|"Y")
# for the sake of the progress bar, execute "curl" for each file.
# the parameters "--include" and "--form" will suppress the progress bar.
for file in "${file_array[@]}"
do
# show delete link and filter out the delete token from the response header after upload.
# it is important to save "curl's" "stdout" via a subshell to a variable or redirect it to another command,
# which just redirects to "stdout" in order to have a sane output afterwards.
# the progress bar is redirected to "stderr" and is only displayed,
# if "stdout" is redirected to something; e.g. ">/dev/null", "tee /dev/null" or "| <some_command>".
# the response header is redirected to "stdout", so redirecting "stdout" to "/dev/null" does not make any sense.
# redirecting "curl's" "stderr" to "stdout" ("2>&1") will suppress the progress bar.
curl_output=$(curl --request PUT --progress-bar --dump-header - --upload-file "${file}" "https://transfer.sh/")
awk_output=$(awk \
'gsub("\r", "", $0) && tolower($1) ~ /x-url-delete/ \
{
delete_link=$2;
print "Delete command: curl --request DELETE " "\""delete_link"\"";
gsub(".*/", "", delete_link);
delete_token=delete_link;
print "Delete token: " delete_token;
}
END{
print "Download link: " $0;
}' <<< "${curl_output}")
# return the results via "stdout", "awk" does not do this for some reason.
echo -e "${awk_output}\n"
# avoid rate limiting as much as possible; nginx: too many requests.
if (( ${#file_array[@]} > 4 ))
then
sleep 5
fi
done
;;
"n"|"N")
return 1
;;
*)
echo -e "\e[01;31mWrong input: '${upload_files}'.\e[0m" >&2
return 1
esac
}```
</p></details>
#### Sample output
```bash
$ ls -lh
total 20M
-rw-r--r-- 1 <some_username> <some_username> 10M Apr 4 21:08 image.img
-rw-r--r-- 1 <some_username> <some_username> 10M Apr 4 21:08 image2.img
$ transfer image*
10240K image2.img
10240K image.img
20480K total
Vuoi davvero caricare i file sopra (2) su "transfer.sh"? (Y/n):
######################################################################################################################################################################################################################################## 100.0%
Comando di eliminazione: curl --request DELETE "https://transfer.sh/wJw9pz/image2.img/mSctGx7pYCId"
Token di eliminazione: mSctGx7pYCId
Link di download: https://transfer.sh/wJw9pz/image2.img
######################################################################################################################################################################################################################################## 100.0%
Comando di eliminazione: curl --request DELETE "https://transfer.sh/ljJc5I/image.img/nw7qaoiKUwCU"
Token di eliminazione: nw7qaoiKUwCU
Link di download: https://transfer.sh/ljJc5I/image.img
$ transfer "image.img" | awk --field-separator=": " '/Delete token:/ { print $2 } /Download link:/ { print $2 }'
10240K image.img
10240K total
Vuoi davvero caricare i file sopra (1) su "transfer.sh"? (Y/n):
######################################################################################################################################################################################################################################## 100.0%
tauN5dE3fWJe
https://transfer.sh/MYkuqn/image.img```
<br />
---
<br />
## Contributions
Contributions are welcome.
<br />
---
<br />
## Creators
**Remco Verhoef**
- <https://twitter.com/remco_verhoef>
- <https://twitter.com/dutchcoders>
**Uvis Grinfelds**
<br />
---
<br />
## Maintainers
- **Andrea Spacca**
- **Stefan Benten**
<br />
---
<br />
## Copyright and License
Code and documentation copyright 2011-2018 Remco Verhoef.
Code and documentation copyright 2018-2020 Andrea Spacca.
Code and documentation copyright 2020- Andrea Spacca and Stefan Benten.
Code released under [the MIT license](https://github.com/dutchcoders/transfer.sh/blob/HEAD/LICENSE).
| Parametro | Descrizione | Valore | Env |
|---|
| listener | porta da usare per http (:80) | LISTENER | |
| profile-listener | porta da usare per il profiler (:6060) | PROFILE_LISTENER | |
| force-https | reindirizza a https | false | FORCE_HTTPS |
| tls-listener | porta da usare per https (:443) | TLS_LISTENER | |
| tls-listener-only | flag per abilitare solo l'ascoltatore tls | TLS_LISTENER_ONLY | |
| tls-cert-file | percorso del certificato tls | TLS_CERT_FILE | |
| tls-private-key | percorso della chiave privata tls | TLS_PRIVATE_KEY | |
| http-auth-user | utente per autenticazione http di base sul caricamento | HTTP_AUTH_USER | |
| http-auth-pass | password per autenticazione http di base sul caricamento | HTTP_AUTH_PASS | |
| http-auth-htpasswd | percorso del file htpasswd per autenticazione http di base sul caricamento | HTTP_AUTH_HTPASSWD | |
| http-auth-ip-whitelist | lista separata da virgole di IP consentiti per caricare senza richiesta di autenticazione | HTTP_AUTH_IP_WHITELIST | |
| virustotal-key | chiave API VirusTotal | VIRUSTOTAL_KEY | |
| ip-whitelist | lista separata da virgole di IP consentiti a connettersi al servizio | IP_WHITELIST | |
| ip-blacklist | lista separata da virgole di IP non consentiti a connettersi al servizio | IP_BLACKLIST | |
| temp-path | percorso della cartella temporanea | temp di sistema | TEMP_PATH |
| web-path | percorso dei file web statici (per sviluppo o front-end personalizzato) | WEB_PATH | |
| proxy-path | prefisso del percorso quando il servizio è eseguito dietro un proxy (un prefisso / verrà rimosso) | PROXY_PATH | |
| proxy-port | porta del proxy quando il servizio è eseguito dietro un proxy | PROXY_PORT | |
| email-contact | contatto email per il front-end | EMAIL_CONTACT | |
| ga-key | chiave di Google Analytics per il front-end | GA_KEY | |
| provider | quale provider di archiviazione utilizzare | (s3, storj, gdrive o local) | |
| uservoice-key | chiave UserVoice per il front-end | USERVOICE_KEY | |
| aws-access-key | chiave di accesso AWS | AWS_ACCESS_KEY | |
| aws-secret-key | chiave di accesso AWS | AWS_SECRET_KEY | |
| bucket | bucket AWS | BUCKET | |
| s3-endpoint | Endpoint S3 personalizzato. | S3_ENDPOINT | |
| s3-region | regione del bucket S3 | eu-west-1 | S3_REGION |
| s3-no-multipart | disabilita il caricamento multipart S3 | false | S3_NO_MULTIPART |
| s3-path-style | Forza URL in stile percorso, richiesto per Minio. | false | S3_PATH_STYLE |
| storj-access | Accesso per il progetto | STORJ_ACCESS | |
| storj-bucket | Bucket da utilizzare all'interno del progetto | STORJ_BUCKET | |
| basedir | percorso di archiviazione per provider locale/gdrive | BASEDIR | |
| gdrive-client-json-filepath | percorso del file JSON di configurazione client OAuth per provider gdrive | GDRIVE_CLIENT_JSON_FILEPATH | |
| gdrive-local-config-path | percorso per memorizzare la cache di configurazione locale di transfer.sh per provider gdrive | GDRIVE_LOCAL_CONFIG_PATH | |
| gdrive-chunk-size | dimensione del chunk per il caricamento gdrive in megabyte, deve essere inferiore alla memoria disponibile (8 MB) | GDRIVE_CHUNK_SIZE | |
| lets-encrypt-hosts | host da utilizzare per i certificati Let's Encrypt (separati da virgole) | HOSTS | |
| log | percorso del file di log | LOG | |
| cors-domains | lista separata da virgole di domini per CORS, impostandolo abilita CORS | CORS_DOMAINS | |
| clamav-host | host per la funzionalità clamav | CLAMAV_HOST | |
| perform-clamav-prescan | pre-scansiona ogni caricamento usando clamav (clamav-host deve essere un socket unix locale di clamd) | PERFORM_CLAMAV_PRESCAN | |
| rate-limit | richieste al minuto | RATE_LIMIT | |
| max-upload-size | dimensione massima di upload in kilobyte | MAX_UPLOAD_SIZE | |
| purge-days | numero di giorni dopo i quali i caricamenti vengono eliminati automaticamente | PURGE_DAYS | |
| purge-interval | intervallo (ore) per eseguire la pulizia automatica (esclusi S3 e Storj) | PURGE_INTERVAL | |
| random-token-length | lunghezza del token casuale per il percorso di upload (doppia per il percorso di eliminazione) | 6 | RANDOM_TOKEN_LENGTH |
| Nome | Utilizzo |
|---|
| latest | Ultima build CI, può essere nightly, su commit, su tag, ecc. |
| latest-noroot | Ultima build CI, può essere nightly, su commit, su tag, ecc. utilizzando [no root] |
| nightly | Build CI pianificata ogni mezzanotte UTC |
| nightly-noroot | Build CI pianificata ogni mezzanotte UTC utilizzando [no root] |
| edge | Ultima build CI dopo ogni commit su main |
| edge-noroot | Ultima build CI dopo ogni commit su main utilizzando [no root] |
vx.y.z | Build CI dopo il tagging di una release |
vx.y.z-noroot | Build CI dopo il tagging di una release utilizzando [no root] |