Register for your free account! | Forgot your password?

Go Back   elitepvpers > Coders Den > General Coding
You last visited: Today at 19:35

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Problem with bot development (Cookies)

Discussion on Problem with bot development (Cookies) within the General Coding forum part of the Coders Den category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Problem with bot development (Cookies)

Hey all, got a question for the other bot developers here.
Was trying to make a small bot for Grepolis (Building queue only).

I created my other bots with C#, using httpget and httppost requests. That way I can easily get the cookies from the response header (Set-Cookie).

But now comes the problem...
The developers of Grepolis found a way to set cookies without Set-Cookie. Looks like they use java script for it.

The cookie called PHPSESSID is still set using Set-Cookie but portal_tid is not.
To login on the server I need both cookies

Someone that can help me with it?
Or if you want to try it yourself to make a bot that can login on this game:




Greetings Uthar
Utharnl is offline  
Old 01/24/2010, 16:51   #2
 
elite*gold: 150
The Black Market: 102/1/0
Join Date: Jul 2008
Posts: 3,417
Received Thanks: 4,064
Hey,

I think you are in the wrong section.
Maybe you can ask in the Coding Section for help

jere88 is offline  
Old 01/24/2010, 20:32   #3
 
Atheuz's Avatar
 
elite*gold: 81
Join Date: Jul 2005
Posts: 1,921
Received Thanks: 2,239
Quote:
Originally Posted by Utharnl View Post
Hey all, got a question for the other bot developers here.
Was trying to make a small bot for Grepolis (Building queue only).

I created my other bots with C#, using httpget and httppost requests. That way I can easily get the cookies from the response header (Set-Cookie).

But now comes the problem...
The developers of Grepolis found a way to set cookies without Set-Cookie. Looks like they use java script for it.

The cookie called PHPSESSID is still set using Set-Cookie but portal_tid is not.
To login on the server I need both cookies

Someone that can help me with it?
Or if you want to try it yourself to make a bot that can login on this game:




Greetings Uthar
Login1
PHP Code:
http://de.grepolis.com/start/?action=ajax_played_worlds&name=derp&password=hurp 
This will retrieve the set of worlds the account has access to.

Login2
PHP Code:
http://de.grepolis.com/start?action=login
world=4&facebook_login=&name=derp&password=hurp 
This actually logs a player in, including the session_id in the response.

PHP Code:
http://de4.grepolis.com/game/login?session_id=1fl802syva2s 
Simply use the session id from now on you got from the response.


In my testing I was able to retrieve the session id perfectly and without to use any other part of the cookie for the rest of the requests. You have to crawl the response html though for valueable information.
Atheuz is offline  
Thanks
1 User
Old 01/24/2010, 23:37   #4
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Thanks Atheuz, but how did you test it?
Because I'm having problems with the second login (Probably because I'm missing a cookie?)

PHP Code:
http://nl.grepolis.com/start?action=login
world=1&facebook_login=&name=Uthar&password=Utharpw 
The response I get from the second login is:
The remote server returned an error: (417) Expectation Failed.

-edit-
Previous error fixed by adding
Code:
System.Net.ServicePointManager.Expect100Continue = false;
Trying to get session_id now, will keep you updated

~Uthar
Utharnl is offline  
Old 01/25/2010, 16:23   #5

 
elite*gold: 146
Join Date: Apr 2008
Posts: 14,686
Received Thanks: 9,969
#moved
Die Schnittstelle is offline  
Old 01/25/2010, 20:51   #6
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Thanks for moving it to the correct section Mio.

I can't get it to work with my current htmlhandler.
The location header:
Code:
Location: http://nl1.grepolis.com/game/login?session_id=d64ma2eqtts0
Is causing an auto redirect and my code can't get that response.

I'm using the class "System.Net.WebRequest" for my requests. Does anybody know if I can turn of the auto redirection?

After some research I found that the class HttpWebRequest has the option to turn auto redirection of. If it isn't possible to turn it of with "System.Net.WebRequest" I could always rewrite my code and use HttpWebRequest.


-edit-
Looks like I can just cast it to an HttpWebRequest
Code:
HttpWebRequest l_Req = (HttpWebRequest)WebRequest.Create(p_URI);
l_Req.AllowAutoRedirect = false;
Going to try again now to see if it works, will let you know when I'm stuck again.




//edit :


I'm almost done with the login process, stuck at the last step now.

Successfully called "http://nl1.grepolis.com/game/login?session_id=4r5anyvv32m8" and retrieved some cookies.

The final step of the login process is to visit "http://nl1.grepolis.com/game/index" but I get only a empty page as response with a Location header that contains:
"http://nl.grepolis.com/start?nosession"

I can simulate a location header with "http://nl.grepolis.com/start?nosession" in a normal browser by logging in with cookies turned off.

Does someone want to give it a try to write some code to login on this game?
I have no idea what goes wrong, any help/tips are welcome!

Greetings Uthar
Utharnl is offline  
Old 01/26/2010, 00:13   #7


 
Cholik's Avatar
 
elite*gold: 4
Join Date: Aug 2008
Posts: 6,783
Received Thanks: 4,992
Okay just wrote some stuff...



Hope I could help you.
Cholik is offline  
Thanks
1 User
Old 01/26/2010, 01:19   #8
 
elite*gold: 0
Join Date: Aug 2009
Posts: 1,656
Received Thanks: 703
Thanks Walter,
Used WireShark to check the http request your code send, was almost the same as my code.
Changed my code a bit so that the requests were the same, but still not working.

It looks like the Location header is causing the problem.
Because your class saves cookies automatic you can follow the Location header without any problems.
In my case I have to visit each location in the Location header manually because my cookies are lost otherwise.

Somewhere there is a small difference in how I do it manually and how your class does it automatic. No idea what ^^

But I must say it looks a lot easier to use the class WebClient like you.
I think I will give that a try tomorrow.


//edit
Thanks for the help, I have it working now.
Here is the link to the bot:


~Uthar
Utharnl is offline  
Reply


Similar Threads Similar Threads
COOKIES OMG LOL..
07/23/2010 - Off Topic - 3 Replies
THANK THIS POST IF YOU LIKE COOKIES!!!!!!!!!!!!!!!!!!!!!! Disclaimer. p.s This post is not spam related, All "thanks" will be recorded into a database were it will be tallyed up to say if people actually like cookies or not thank you for your time noobs :) .
All*CoOKies
04/10/2010 - CrossFire - 2 Replies
Wir All*CoOKies suchen Clan-Member ;-) geht auf die Seite: Z8Games ? Home of the Best Free MMO Games - Clans - Clan Home wir freuen uns auf jeden Neuen :) Kontakt per Skype:
Cookies optimieren?
01/09/2010 - Technical Support - 14 Replies
Hi, langsam gehen mir die darstellungsfehler meines browser richtig gegen den Strich... E*pvp zeichen wird in einzelne Pixel aufgelöst, der Thx button ist auf einmal das Userbild von Vulcan o0 Ich lösch jeden 2. Tag meine Cookies - langsam sogar jeden Tag, jetz kann man natürlich verstehn das das ziemlich nerven kann :awesome:, ohne cookies kann man aber auch nur unbequem arbeiten Jetzt ist meinre Frage: kann ich die Cookieverwaltung irgendwie optimieren oder wäre es dann sogar...
rapidshare cookies
10/07/2005 - Technical Support - 4 Replies
Hallo, wollte fragen wie ich das mache das rapid meine cookies nicht speichert und ich mehrmals von rapid sauegen kann ohne sone dumme meldung zu bekommen das ich bereits zu viel gesaugt hätte. Also, wie soll das gehn? Danke für eure hilfe ^^ MfG C0rnh0lio



All times are GMT +1. The time now is 19:36.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.