How can I make a packet bot?

08/11/2013 23:01 Tinwor#1
Hi guys, I know C# well and now I want to try to create a bot for ikariam. What I need to learn for making the bot?
Cheers,
Tinwor
08/13/2013 12:13 Tinwor#2
No one can help me?
08/13/2013 12:25 Ludder231#3
Google for "HttpWebRequest"
08/13/2013 13:10 dready#4
Which has nothing todo with a packetbot :P

Reverse the Client, rebuild encryption and authentication
Gather and analyse packets.

Rebuild the Client.
08/13/2013 17:10 Requi#5
Quote:
Originally Posted by dready View Post
Which has nothing todo with a packetbot :P

Reverse the Client, rebuild encryption and authentication
Gather and analyse packets.

Rebuild the Client.
Or just HttpWebRequests, because it's a browsergame and I think it's without any real client, except the browser itself.
08/13/2013 21:29 Tinwor#6
Ok thanks. I have this problem now, i use the httpwebrequest but after one request the server close the connection. I try to set keepalive=true but nothing, someone can help me?
08/13/2013 21:32 Ludder231#7
Quote:
Originally Posted by Tinwor View Post
Ok thanks. I have this problem now, i use the httpwebrequest but after one request the server close the connection. I try to set keepalive=true but nothing, someone can help me?
try cookiecontainer...if you dont save the cookies the server will think you are not logged in
08/13/2013 22:32 slayerman31#8
i have sample project for travian , but coded in vbnet. (with webbrowser)

its not good choice but coding a very simple :pimp:

source : [Only registered and activated users can see links. Click Here To Register...]

picture :
[Only registered and activated users can see links. Click Here To Register...]
08/14/2013 19:19 Tinwor#9
this is my get method:
Code:
public string get(string uri)
        {
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Method = "GET";
            webRequest.UserAgent = "Mozilla/5.0 (Windows NT 5.0; rv:5.0) Gecko/20100101 Firefox/5.0";
            try
            {
                WebResponse webResponse = webRequest.GetResponse();
                if (webResponse == null)
                    return null;
                StreamReader sr = new StreamReader(webResponse.GetResponseStream());
                return sr.ReadToEnd().Trim(); 
            }
            catch (WebException ex) 
            {
                HttpWebResponse response = (HttpWebResponse)ex.Response;
                StreamReader sr = new StreamReader(response.GetResponseStream());
                HTTPRequests.requests++;
                return sr.ReadToEnd().Trim(); 
            }
            catch (Exception)
            {
                throw;
            }
        }
and this is the post:
Code:
public string post(string uri, string parameters)
        {
            HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(uri);
            webRequest.ContentType = "application/x-www-form-urlencoded";
            webRequest.Method = "POST";
            webRequest.UserAgent = "Mozilla/5.0 (Windows NT 5.0; rv:5.0) Gecko/20100101 Firefox/5.0";
            byte[] bytes = Encoding.ASCII.GetBytes(parameters); 
            Stream sendstream = null;
            try
            {
                webRequest.ContentLength = bytes.Length;   
                sendstream  = webRequest.GetRequestStream();  
                sendstream.Write(bytes, 0, bytes.Length);   
                sendstream.Close(); 
            }
            catch (Exception)
            { 
                throw;
            }

            try
            {
                WebResponse webResponse = webRequest.GetResponse();
                if (webResponse == null)
                    return null;
                StreamReader sr = new StreamReader(webResponse.GetResponseStream());
                return sr.ReadToEnd().Trim();
            }
            catch (WebException ex) 
            {
                HttpWebResponse response = (HttpWebResponse)ex.Response;
                StreamReader sr = new StreamReader(response.GetResponseStream());
                HTTPRequests.requests++;
                return sr.ReadToEnd().Trim(); 
            }
            catch (Exception)
            {
                throw;
            }
        }
Now I have to add and use the cookiecontainer but i don't know how to do it. Can someone help?Thanks
08/19/2013 07:43 BlackHybrid#10
Insert the variable:
PHP Code:
private CookieContainer CookieContainer
and add this to your request:
PHP Code:
webRequest.CookieContainer CookieContainer
In the best case you needn't to manage the cookies by yourself :D

You can also have the problem, that your header isn't similar to the "original" header and you do a bad request.