Register for your free account! | Forgot your password?

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

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

Advertisement



HttpWebRequest C# Browsergame Bot

Discussion on HttpWebRequest C# Browsergame Bot within the .NET Languages forum part of the Coders Den category.

Closed Thread
 
Old   #1
 
elite*gold: 0
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
Thorbadin is offline  
Old 05/08/2010, 11:54   #2
 
Atheuz's Avatar
 
elite*gold: 81
Join Date: Jul 2005
Posts: 1,921
Received Thanks: 2,239
Liegt hier drann, nach dem abschicken der Daten wird noch ein request geschickt.
Bin mir so ziemlich sicher.

Quote:
Atheuz is offline  
Old 05/09/2010, 16:49   #3
 
elite*gold: 0
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  
Old 12/07/2017, 02:15   #4
 
elite*gold: 0
Join Date: Jan 2014
Posts: 370
Received Thanks: 167
Du musst dem WebBrowser auch die Cookies geben
kannst mich per PN anschreiben dann sag ich dir wie.
Onkelmat is offline  
Old 12/07/2017, 10:21   #5



 
Serraniel's Avatar
 
elite*gold: 0
The Black Market: 205/1/0
Join Date: May 2010
Posts: 6,853
Received Thanks: 5,107
@ Bitte pushe keine veralteten Threads. Dies ist oft nicht förderlich, da die User eventuell nicht mehr auf elitepers sind oder das Problem gar nicht mehr existiert. Zusätzlich verstößt dies gegen die Forenregeln: .

#Closed
Serraniel is offline  
Closed Thread


Similar Threads Similar Threads
[C#]MD5-Cheksumme mit HttpWebRequest oä
08/18/2010 - .NET Languages - 1 Replies
Ich will mir mal einen gescheiten Patcher für Metin2 machen.. Jetzt soll er von den Files auf meinem Server die Checksummen ausspucken. Die Datei sollte nicht heruntergeladen werden... System.IO.FileStream FileCheck = System.IO.File.OpenRead(Dateipfad); System.Security.Cryptography.MD5 md5 = new System.Security.Cryptography.MD5CryptoServiceProvi der(); byte md5Hash = md5.ComputeHash(FileCheck);
Browsergame Bot ?
04/28/2010 - AutoIt - 4 Replies
Hey Leute, Ich bin gerade dabei AutoIt zu lernen und man kann ja mit AutoIt nen Browsergame bot machen. (z.B. für die Stämme) Nun meine Frage, ist das schwer ? Habe vor für das game robot-invasion . at einen Bot zu coden, Spielprinzip ist GLEICH wie bei Die-Stämme. Könntet ihr mir vllt. nen kleinen Ausschnitt zeigen aus einem Stämme (o.ä. Game) Bot zeigen ? Wäre echt nett :D Achja und dauert es lange so nen Bot zu scripten und ist das arg schwer ? Mfg
Neues Browsergame!/New Browsergame!
04/20/2009 - Browsergames - 1 Replies
Also ich hab mal ein neues Browsergame für euch! das mega geil! Steege My Brute A new Browsergame is´t very cool and make a lot of fun :) :mofo:
Browsergame
05/07/2008 - General Gaming Discussion - 4 Replies
Hi, anyone knows a good browsergame, which have good pvp and mission system or an online footballmanager. Don't need: ogame battleknight knightfight monstergame bitfight
i need help for a browsergame...
03/09/2008 - General Coding - 0 Replies
hallo, sag mal kennt hier jemand methoden um sich etwas hilfe bei einem browsergame zu verschaffen ? klick for the game wäre supi nett =) danke schön, gruß sabse! translate: hello, i am searching for methods of helps at a browsergame!i hope someone can help me! here is the link: klick for the game



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


Powered by vBulletin®
Copyright ©2000 - 2025, 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 ©2025 elitepvpers All Rights Reserved.