AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Need help with WebForms (maybe cURL)
Goto page 1, 2  Next
 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
NiJo



Joined: 12 Nov 2005
Posts: 73

PostPosted: Sun Oct 08, 2006 4:59 pm    Post subject: Need help with WebForms (maybe cURL) Reply with quote

I'm Trying to make a script, just like Payam wanted in this Post: http://www.autohotkey.com/forum/viewtopic.php?t=940
Behind the scenes login and webdocument parsing. The parsing i can manage, the login and Posts don't...

I have tried lots of things in ahk, with no sucess. And now tried with cURL.
I tried forms filling and log'in with curl in lots of sites, and I couldn't manage it in none of them :S

Can you just tell me a little example of a cURL command, or even ahk, to login in the http://www.autohotkey.com/forum/login.php , for example..

I first tried directly from the adress bar in IE :
Code:
http://www.autohotkey.com/forum/login.php?username="myuser"

and things like that, and then went to try in cURL. Using:
Code:
curl -d username=myuser -d password=mypass www.autohotkey.com/forum/

and nothing... It keeps logged off (I can see "Log in to check your private messages" in the Command Line). Sad

Anyone, an example please.?.?.

I can do what I need, but with the browser opened and using javascripts (ControlSetText, Edit1, javascript:blahblahblah).
But i want to do it invisible, on the background. If login in by adress is too hard, any way of doing javascripts on the background?
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 10, 2006 12:28 pm    Post subject: Reply with quote

You found an old post here... Smile
Perhaps this one can give more info: http://www.autohotkey.com/forum/viewtopic.php?t=10502
I often advice to use cURL, but didn't played a lot with this form post feature.
Let me know if this helps.

Note 1: you might need to manage cookies for login forms.
Note 2: AFAIK, you can't "do" JavaScripts on the background, it is easier to use a browser for this.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
not-logged-in-daonlyfreez
Guest





PostPosted: Tue Oct 10, 2006 1:24 pm    Post subject: Reply with quote

Try this bookmarklet on your target page: frmget

Quote:
Makes "Post" forms submit to bookmarkable URLs (with ?var=value).


You can submit the result with JavaScript in your browser or use it for cURL (but then you'd need to handle cookies too)
Back to top
BoBo
Guest





PostPosted: Tue Oct 10, 2006 2:50 pm    Post subject: Reply with quote

The above mentioned Bookmarklet is changing the functionality of the web page to accept 'form parameters' (name="value") via the addressbar.
Please confirm!
Cool
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 10, 2006 3:35 pm    Post subject: Reply with quote

BoBo, you are right:
Form Bookmarklets wrote:
Some sites use Post forms for searches when the URL is ugly or long, which makes it difficult to bookmark the results of the search, but most of these sites also accept the same form submitted using the Get method.
This requires that the Web site is programmed to accept either submit method! This is rather uncommon, most processes I know only accept the method coded in the HTML page.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
not-logged-in-daonlyfreez
Guest





PostPosted: Tue Oct 10, 2006 4:42 pm    Post subject: Reply with quote

The bookmarklet changes the form method from POST to GET, meaning, after you submitted the form, the URL will reveal the string sent to the server. With POST forms, this string is not returned, so you don't know how the server expects its formdata (well, you can find out by taking a look at the source of the page).
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 10, 2006 4:58 pm    Post subject: Reply with quote

Ah, OK. There are other tools to see this, but for simple form, this one is easy and fast to set up. Thanks for the idea.
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Tue Oct 10, 2006 5:36 pm    Post subject: Reply with quote

Quote:
The bookmarklet changes the form method from POST to GET, meaning, after you submitted the form, the URL will reveal the string sent to the server.
Which means in reverse, if I'd enter that revealed string at the browsers address line and press ENTER, I'd submit/send the forms content in the correct format (exactly as the server has to GET it.) Right?

I don't wanna bother you - it's just that I've to provide a temporary solution/web feed/such a mimikry for an intranet page till end of the week ... ShockedRolling EyesSmile

Thx for your effort. Cool
Back to top
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Tue Oct 10, 2006 5:45 pm    Post subject: Reply with quote

Yes and no...
Yes: "I'd submit/send the forms content in the GET format".
No: It might not work, if your intranet CGI/script isn't designed to handle this GET format, but only the POST one.
If it works, you are lucky. Otherwise, try cURL...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
NiJo-NotLoggedIn
Guest





PostPosted: Wed Oct 11, 2006 12:00 am    Post subject: Reply with quote

Well...
Once more I read, and once more I kept not knowing how to.
I read all the cURL Forum Posts, and couldn't get what I want.

I know most of the javascripts-Forms-Related stuff, all those bookmarklet things I already did, with manual javascript - javascript:void(document.forms[0].method="get") . All right, it works fine with google or other search engines, But i need protected sites login.
I think the problem is those ...
PhiLho wrote:
This requires that the Web site is programmed to accept either submit method! This is rather uncommon, most processes I know only accept the method coded in the HTML page.

Pages that don't accept Coded URL.

I have 2 examples: one is AHK-Forum-Login. I just can't do it with either manual or cURL encoded adress (exactly the same , with the -D or -F options). I only manage it filling the forms manually, or with Javascript, but that's with my browser opened Sad For the AHK I was trying
Code:
http://www.autohotkey.com/forum/login.php?username=USER&password=PASSWORD&redirect=index.php%3F&login=Log+in

And variations, lots of them.

Another one is a Site with Protection: the URL from POST (with GET) has 2 variables parsed after 3 functions in a included-javascript, with a very weird effect. Can show you the functions has a quizz Wink, easy one though. But i think i can get those from the cookies. But from the cURL Post/Form Feature, it should be able to pratically-fill those fields, and than I wouldn't need to find those 2 variables, right? :S
I got another program written in Python that can login to it on the background, and all it uses is cookies and an urllib and urllib2 from the system32 folder (well, at seems it says it does, It's crashing and i don't know why).

Gona check the cookies for info, again, but I think it's encrypted, and the python don't have the de-cryptor for sure! Can't cURL virtually-fill the forms? From the manual it seems it only encodes the URL, just like the GET method would show us. Sad
Back to top
BoBo
Guest





PostPosted: Wed Oct 11, 2006 7:55 am    Post subject: Reply with quote

AFAIK cURL provides a 'cookies' option to retrieve/request a cookie. In many cases it's necessary to send/provide a session ID with the stream when POSTing (you should be able to get it from the cookie).
Back to top
NiJo



Joined: 12 Nov 2005
Posts: 73

PostPosted: Wed Oct 11, 2006 2:04 pm    Post subject: Reply with quote

Ok, for now, forget the cookie thing. But not the SessionID, I'm still to figure if that's needed.

I just want to login to ahk forum using direct adress or cURL. Can any of you make it?
After this last Bobo post, I grabbed my code and tried adding pieces of the cookie I get from the login.php.
Anything I trie, just gives me a "You have specified an incorrect or inactive username, or an invalid password." But i didn't, it's correct.

I Just need to know if the cURL can pass all that, without having to new SessionID and those stuff. i.e.: Can REALLY virtually fill the form and submit.
If not, I think I'd rather open IE and Hide the window with a timer, than decrypting the javascript and getting ID...
Back to top
View user's profile Send private message
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Oct 11, 2006 4:38 pm    Post subject: Reply with quote

Hum, I tried various things, and failed...
Lastest attempt:
Code:
curl -d "username=NoBoDy&password=NoPWD&login=Log+in" -e http://www.autohotkey.com/forum/ -v -o AHK.html http://www.autohotkey.com/forum/login.php?sid=563d9f0edf8c4e22c52f7ba67f59bbb8

Either this doesn't work, or AutoHotkey.com is heavily protected against robots, using various tricks to defeat them...
I even added a Referer and a sid got from a previous request. Perhaps cookies are mandatory, I haven't tried it yet.

What makes me think this is that I tried this method in the Search form, which works well:
Code:
curl -d "search_keywords=DllCall&search_terms=all&search_author=PhiLho&search_forum=1&
search_time=0&search_fields=all&show_results=topics&return_chars=500&sort_by=0&sort_dir=DESC" -e http://www.autohotkey.com/forum/ -v -o AHK.html http://www.autohotkey.com/forum/search.php?mode=results

Note: for quick gathering of needed fields, I used Fiddler, an extension of Microsoft for IE which shows behind the scene data. I could have used Ethereal/Wireshark, but it was faster this way.
I can also use my Live HTTP Headers extension in Firefox, I almost forgot about them...
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")


Last edited by PhiLho on Wed Oct 11, 2006 6:07 pm; edited 1 time in total
Back to top
View user's profile Send private message Visit poster's website
PhiLho



Joined: 27 Dec 2005
Posts: 6721
Location: France (near Paris)

PostPosted: Wed Oct 11, 2006 5:48 pm    Post subject: Reply with quote

New info: it worked when I used cookies:
Code:
curl --dump-header AHKcookies.txt http://www.autohotkey.com/forum/
curl -d "username=NoBoDy&password=NoPWD&login=Log+in" -c AHKcookies.txt -e http://www.autohotkey.com/forum/ -v -o AHK.html http://www.autohotkey.com/forum/login.php?sid=e11a8270d84e231eb706fc3d31ba6ebe
The sid is taken from the cookie file.
I got at least a "You have specified an incorrect or inactive username, or an invalid password." message! Smile
_________________
vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")
Back to top
View user's profile Send private message Visit poster's website
Guest






PostPosted: Wed Oct 11, 2006 11:07 pm    Post subject: Reply with quote

PhiLho, thanks, I learned a lot from that Wink
At least I saw other options that could be useful and read more 20% of the manual...
Well, It does tell me Invalid, when i enter a fake login. When i enter my real login, It never downloads... :\ No, It hasn'e especial characters :S just 9 digit a-z password.

Don't know why. Any way, I removed the -v of your code, and put the -c being -b, so he uses the cookie to send. Yours was dling Again. :S

But this isn't that great stuff, We can easily get this by just making a
Code:
curl -d "username=User&password=PSSWD&login=Log+in" -o login.html http://www.autohotkey.com/forum/login.php

Or just going to the adress:
http://www.autohotkey.com/forum/login.php?username=User&password=PSSWD&login=Log+in

Are you sure this has some evolution? Sending the cookie should work now, right? :\ but it doesn't Sad
Back to top
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group