cURL / Mailing Lists / curl-users / Single Mail

curl-users

Re: Post in a forum

From: lakk_esbjrn <lakk_esbjrn_at_yahoo.fr>
Date: Sun, 31 Aug 2008 12:47:56 +0200

Daniel, good new !

I noticed this 2 parameters in the LiveHTTP log, which change every time :
/
----------------------------4079334012024001462096312857
Content-Disposition: form-data; name="creation_time"
1220128290
-----------------------------4079334012024001462096312857
Content-Disposition: form-data; name="form_token"
ec818057125a858ae2d5a3380dc36d3a41c46dc8
/
In the source-code of the form reply :
/
/

/<input name="creation_time" value="1220177192" type="hidden">
<input name="form_token" value="14ff2ec30257562e22c5485ea86e42ab09218d20" type="hidden">/

/
/And it was necessary to extract them in the same way it is necessary to
extract the SID. I've finally written this shell script

#!/bin/bash
cd ~/Desktop

# Connexion
# + first we have to login in the forum to keep authentification's cookies

curl -A "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.1)
Gecko/2008070400 SUSE/3.0.1-7.1 Firefox/3.0.1" -d
"username=username&password=password&login=Connexion" -c "Cookie1.txt"
"http://www.nameforum.org/phpBB3/ucp.php?mode=login" > coucou.txt

# Récupération du SID / now we keep the SID from the authentification's
response

SID=$(grep -o -m1 "sid=.*\"" coucou.txt | sed 's/sid=//g;s/"//g')

# We go now in the page of the reply and save it as FormRep.html to
extract this 2 values (FormToken & creation_time)

curl -A "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.1)
Gecko/2008070400 SUSE/3.0.1-7.1 Firefox/3.0.1" -b "Cookie1.txt"
"http://www.nameforum.org/phpBB3/posting.php?mode=reply&f=24&t=55" >
FormRep.html
FormToken=$(grep "form_token" FormRep.html | sed -e 's/^.*="//g;s/" \/>//g')
creation_time=$(grep "creation_time" FormRep.html | sed -e
's/^.*="//g;s/" \/>//g')

# It's time to post the reply using all this data (except the -v option,
I don't know if all is necessary, but it works)

curl -v -A "Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.0.1)
Gecko/2008070400 SUSE/3.0.1-7.1 Firefox/3.0.1" -e
"http://www.nameforum.org/phpBB3/posting.php?mode=reply&f=24&t=55" -b
"Cookie1.txt" -F "subject=Re: Test" -F addbbcode20=100 -F message=Hello
-F topic_cur_post_id=844 -F lastclick=1220128290 -F post=Envoyer -F
attach_sig=on -F notify=on -F creation_time=$creation_time -F
form_token=$FormToken -F fileupload= -F filename= -F filecomment=
"http://www.nameforum.org/phpBB3/posting.php?mode=reply&f=24&t=55&sid=$SID"
> ReponseForum.html

And the reply "Hello" appear in the forum.

What d'you think about that ?

-------------------------------------------------------------------
List admin: http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-users
FAQ: http://curl.haxx.se/docs/faq.html
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2008-08-31