Loading...
Help keep this site alive, take a look at one of our sponsors

Welcome to TheBestTrek, thank you for visiting the site, to see everying and to participate in discussions Register, its free, quick and easy to do plus, you get all the benefits.
Pages: [1]   Go Down
Print
Author Topic: cURL and Remote Uploading to Free Hosts  (Read 262 times)
0 Members and 1 Guest are viewing this topic.
mijcsmu
Guest
« on: June 23, 2006, 01:07:34 AM »

If you have access to a server with SSH access, and it has the cURL libraries installed, you can upload files stored on your server to free hosts such as filefactory, sendspace, upfile etc etc. This is achieved with a (somewhat) simple curl command. I wrote some bash scripts that you can use to make it even easier. Here they are:

BASH SCRIPT FOR FILEFACTORY
[spoiler]
Code:
#!/bin/sh

if [ "$#" -lt "1" ]
then
  echo "you forgot to choose file to upload ya plonker"
exit 1
fi

#get index.html
curl http://www.filefactory.com > fileff.tmp

#get filename
FILE=$1

#get Session ID address for upload
UPLOADVAR=`grep 'sessionid' fileff.tmp|head -1|awk '{print $4}'|perl -npe '$_=substr($_,7,-3)'`

#get server address for upload
SERVERVAR=`grep 'multipart/form-data' fileff.tmp|head -1|awk '{print $3}'|perl -npe '$_=substr($_,8,-2)'`

echo $SERVERVAR
echo $UPLOADVAR
echo $FILE

curl -v --progress-bar -F "file=@$FILE" -F "sessionid=$UPLOADVAR" $SERVERVAR > fout.tmp

rm fileff.tmp

LINKVAR=`grep 'window.parent.location.href' fout.tmp|perl -npe '$_=substr($_,30,-3)'`
echo $LINKVAR

rm fout.tmp
[/spoiler]

BASH SCRIPT FOR SENDSAPCE
[spoiler]
Code:
#!/bin/sh

if [ "$#" -lt "1" ]
then
  echo "you forgot to choose file to upload ya plonker"
exit 1
fi

#get index.html
curl sendspace.com > ~/file.tmp

#get filename
FILE=$1

#get uoload identifier
UPLOADVAR=`grep UPLOAD_IDENTIFIER file.tmp|head -1|awk '{print $4}'|perl -npe '$_=substr($_,7,-3)'`

#get server address for upload
SERVERVAR=`grep "processupload.html" ~/file.tmp|awk '{print $3}'|cut -b9-`

#get Destination DIR
DESTINATIONVAR=`grep DESTINATION_DIR file.tmp|head -1|awk '{print $4}'|perl -npe '$_=substr($_,7,-3)'`

SERVERLEN=${#SERVERVAR}-1
SERVERVAR=${SERVERVAR:0:SERVERLEN}

echo $SERVERVAR
echo $UPLOADVAR
echo $FILE
echo $DESTINATIONVAR

curl -v -F "MAX_FILE_SIZE=314572800" -F "UPLOAD_IDENTIFER=$UPLOADVAR" -F "DESTINATION_DIR=$DESTINATIONVAR" -F "js_enabled=0" -F userfile=@$FILE -F "desc=Upped By Me" -F "recpemail=recepient@email.com" -F "ownemail=my@email.com" -F "terms=1" $SERVERVAR

rm file.tmp
[/spoiler]

To get these scripts to work, copy an paste into a file, and name the file "upload" or whatever you want to call it. I call the filfefactory one "fupload" and the sendspace one "supload". Dont use a file extension. Upload it to your server (ASCII transfer type, not binary), then chmod the file to at least 755, to allow you execute permission.

Then ssh into the server, cd to the directory you uploaded to, and use the following command to upload files:

Code:
./fupload folder1/folder2/filename.rar

Easy as that. Dont forget to change the description of the file you are uploading to something you want to use, like Upped by Q, or whatever, and the emial addresses you want to use. I dont wanna get a crap load of emails saying you have successfully uploaded a file to sendspace! Cheesy

Also, pay attention to the directories of the files you want to upload. I'd recommend putting the script in the home directory, as it will then be able to access any files beneath it easily! When the script finishes executing, copy and paste the link that it outputs into your browser, and voila. file uploaded.

******************

Thanks to Jirkal, Qasim, Xyster and Iluphade for their help with this.
Logged
FiSH
sysop
Fleet Admiral
Commander
*****

Karma: 30
Offline Offline

Posts: 1100



« Reply #1 on: August 01, 2006, 12:19:19 AM »

thanks again mike works like great :)
Logged

AncientNET
Guest
« Reply #2 on: October 01, 2006, 08:46:37 PM »

hey, what about rapidshare? how do i do that when there's the captcha?
Logged
t2005
Commodore
Lieutenant
*****

Karma: 49
Offline Offline

Posts: 183


« Reply #3 on: October 02, 2006, 01:49:02 PM »

You don't, cos it's bound to an IP.

Options:
1, No remote dl Wink
2, RS account
3, you can try to install a web-proxy (there's something called phpproxy) onto the same server
Logged
Pages: [1]   Go Up
Print
Jump to: