Not a member yet? Register for your free account!


Go Back   elitepvpers > Coders Den > .NET Languages
You last visited: Today at 17:17

  • Did you know? elitepvpers has its own image host, epvpimg.com.

 

HttpWebRequest C# Browsergame Bot

This is a discussion on HttpWebRequest C# Browsergame Bot within the .NET Languages forum part of the Coders Den category; Hi, i have the following problem and it would be great if s.o. could help me. I try to write ...

Reply
 
Thread Tools
Old 05-08-2010, 01:10   #1
Junior Member
 
Join Date: Feb 2009
Posts: 2
Received Thanks: 0
HttpWebRequest C# Browsergame Bot


Hi,

i have the following problem and it would be great if s.o. could help me.
I try to write a simple bot for a browsergame which uses the HttpWebRequest and Response classes from C#. Currently i try to log in with the following script but i only get back to the login page. When i try to catch a site for logged in members only i also only get the login page. There has to be a problem with the cookie but i don't know where

Code:
class HttpHelper
    {
        private CookieContainer cookieContainer = new CookieContainer();
        HttpWebRequest request;
        HttpWebResponse response;
        StreamReader sr;

        public string GetHtml(string Url)
        {
            request = (HttpWebRequest)HttpWebRequest.Create(Url);
            request.Referer = "http://s40.wurzelimperium.de";
            request.AllowAutoRedirect = true;
            request.ServicePoint.Expect100Continue = false;
            request.Timeout = 10000;
            request.CookieContainer = cookieContainer;
            request.Method = "GET";
            request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5";


            response = (HttpWebResponse)request.GetResponse();
            Console.WriteLine();
            sr = new StreamReader(response.GetResponseStream());
            string html = sr.ReadToEnd();
            sr.Close();
            response.Close();         

            return html;
        }

        public void Login()
        {
            HttpWebResponse res;
            HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create("http://www.wurzelimperium.de/serverwahl_login.php");
            req.AllowAutoRedirect = true;
            req.Method = "POST";
            req.ServicePoint.Expect100Continue = false;
            req.Timeout = 10000;
            req.CookieContainer = cookieContainer;
            req.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.3) Gecko/20100401 Firefox/3.6.3";
            req.ContentType = "application/x-www-form-urlencoded";


            ASCIIEncoding encoding = new ASCIIEncoding();
            byte[] loginDataBytes = encoding.GetBytes("server=server40&submitlogin=Einloggen&login=tobu&dummy=12346&pass=MTIzNDY%3D");
            req.ContentLength = loginDataBytes.Length;

            Stream stream = req.GetRequestStream();
            stream.Write(loginDataBytes, 0, loginDataBytes.Length);
            stream.Close();


            res = (HttpWebResponse)req.GetResponse();

            res.Close();
        }
    }
You can use the login data. Its only a test account with fake email.

I created a WPF-Project so that i can see the results.
Here my call:
Code:
Login()
webBrowser1.DocumentText = GetHtml("http://s40.wurzelimperium.de/garten_map.php")
But like said before, i only get the login page.

€dit:
I've tested it with other games. Works fine there. I've really no clue why it doesn't work there

Thorbardin
__________________


Last edited by Thorbadin; 05-08-2010 at 04:36.
Thorbadin is offline  
Old 05-08-2010, 11:54   #2
Senior Member
 
Atheuz's Avatar
 
Join Date: Jul 2005
Posts: 1,929
Received Thanks: 2,236
Liegt hier drann, nach dem abschicken der Daten wird noch ein request geschickt.
Bin mir so ziemlich sicher.

Quote:
[Only registered and activated users can see links. ]
Atheuz is offline  
Old 05-09-2010, 16:49   #3
Junior Member
 
Join Date: Feb 2009
Posts: 2
Received Thanks: 0
Dieser zweite wird ja auch bearbeitet, denn danach kommt nochmal ein redirect. Also hat der login irgendwie geklappt.
Jedoch komme ich trotzdem nicht in den Internen bereich.
Bei anderen wie gesagt, welche die selben redirects benutzen funktionierts. Das wurmt mich wirklich sehr.
Thorbadin is offline  
Reply

Thread Tools

Similar Threads
Thread Thread Starter Forum Replies Last Post
[C#]MD5-Cheksumme mit HttpWebRequest oä LordMampf2 .NET Languages 1 08-18-2010 23:01
Browsergame Bot ? TheShadowCore AutoIt 4 04-28-2010 15:04
Neues Browsergame!/New Browsergame! steege MyBrute 1 04-20-2009 21:25
Browsergame Fedol General Gaming Discussion 4 05-07-2008 22:14
i need help for a browsergame... sabse General Coding 0 03-09-2008 02:17




All times are GMT +2. The time now is 17:17.


Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.