public static PostResult GetPage(string Uri, string UriReferer, PostRequest.PostTypeEnum Method, List<string> Params) { PostRequest mClient; mClient = new PostRequest(Uri, UriReferer); mClient.Type = Method; if (Cookies != null) { mClient.Cookies = Cookies; } for (int i = 0; i < Params.Count; i += 2) { mClient.PostItems.Add(Params[i], Params[i + 1]); } return mClient.Post(); }
public static void Main(string[] args) { // AMF Stream test //TestAmfStreamReading(); //return; // Auth testing against DSO login server using web auth (SSL) CookieCollection cookies = null; PostRequest req = new PostRequest(); req.AutoRedirect = false; req.Cookies = new System.Net.CookieCollection(); req.IgnoreCookies = false; req.UrlReferer = ""; req.Type = PostRequest.PostTypeEnum.Post; req.Url = "https://www.diesiedleronline.de/de//api/user/login/"; req.PostItems.Add("password", "Kfbbb7bnb147wcs"); req.PostItems.Add("name", "godlesz"); PostResult result = req.Post(); // Should be "{"status":"OKAY","data":true}" if (result.ResponseString != "{\"status\":\"OKAY\",\"data\":true}") { return; } cookies = result.Cookies; /* // Auth on Server req = new PostRequest("http://w09bb01.diesiedleronline.de/authenticate", ""); //req.Cookies = cookies; req.Type = PostRequest.PostTypeEnum.Post; req.PostItems.Add("DSOAUTHTOKEN", cookies["DSOAUTHTOKEN"].Value); req.PostItems.Add("DSOAUTHUSER", cookies["DSOAUTHUSER"].Value); result = req.Post(); // [auth token]|[nickname]|[dont know] // xHO0VGr4FN8sPgmi9oal2pkdGSi5N9pP|GodLesZ|2VZ5dSE0otnrYdvXuRxLzA== Regex re = new Regex("^([^|]+)|([^|]+)|(.+)$"); Match m = re.Match(result.ResponseString); if (m.Success == false) { return; } // Take care of new cookie "dsoAuthToken" cookies = result.Cookies; */ /** * TODO: This seems some sort of queue refresh * Its called every 120ms if I'm right */ // Auth succesfull, first login on zone // TODO: fetch zoneID somewhere dynamic req = new PostRequest("http://w09bb01.diesiedleronline.de/Z" + DateTime.Now.UnixTimestamp(), ""); req.Cookies = cookies; req.Type = PostRequest.PostTypeEnum.Post; req.PostItems.Add("DSOAUTHTOKEN", cookies["DSOAUTHTOKEN"].Value); req.PostItems.Add("DSOAUTHUSER", cookies["DSOAUTHUSER"].Value); req.PostItems.Add("zoneID", "0"); // Request goes to the "BigBrother Master Server 1.01 (I AM ROCKSER)" :D result = req.Post(); // Should be "queuePos=<integer>&queueSize=<integer>" // Refresh cookies using ping (?) req = new PostRequest("http://www.diesiedleronline.de/ping.php", ""); req.Cookies = cookies; // Request goes to the "BigBrother Master Server 1.01 (I AM ROCKSER)" :D result = req.Post(); if (result.ResponseString != "OK") { } cookies = result.Cookies; // All auth things should be done // Now request "BigBrother" again to get URL of AMF stream req = new PostRequest("http://w09bb01.diesiedleronline.de/Z" + DateTime.Now.UnixTimestamp(), ""); req.Cookies = cookies; req.Type = PostRequest.PostTypeEnum.Post; req.PostItems.Add("DSOAUTHTOKEN", cookies["DSOAUTHTOKEN"].Value); req.PostItems.Add("DSOAUTHUSER", cookies["DSOAUTHUSER"].Value); req.PostItems.Add("zoneID", "0"); result = req.Post(); string amfStreamUrl = result.ResponseString; // "http://w09g02.diesiedleronline.de:80/GameServer02/amf"; string amfHeader = ""; amfHeader += "Referer: http://static13.cdn.ubi.com/settlers_online/live/de/L4230DE/SWMMO/debug/SWMMO.swf\r\n"; amfHeader += "Content-type: application/x-amf\r\n"; amfHeader += "Content-length: "; // 244\r\n\r\n"; string amfBody = ""; amfBody += new string(new char[] { '\u0000', '\u0003', '\u0000', '\u0000', '\u0000', '\u0001', '\u0000', '\u0004' }); amfBody += "null"; amfBody += new string(new char[] { '\u0000', '\u0002' }); amfBody += "/1"; amfBody += new string(new char[] { '\u0000', '\u0000', '\u0000' }); amfBody += 'à' + "\n"; amfBody += new string(new char[] { '\u0000', '\u0000', '\u0000', '\u0001', '\u0011' }); amfBody += "\n"; amfBody += '\u0013'; amfBody += "Mflex.messaging.messages.CommandMessage"; amfBody += '\u0013'; amfBody += "operation"; amfBody += '\u001b' + "correlationId" + '\t' + "body"; amfBody += '\u0013' + "messageId" + '\u0011'; amfBody += "clientId" + '\u0015' + "timeToLive" + '\u000f' + "headers" + '\u0017' + "destination"; amfBody += '\u0013' + "timestamp"; amfBody += new string(new char[] { '\u0004', '\u0005', '\u0006', '\u0001' }); amfBody += "\n"; amfBody += '\u000b' + '\u0001' + '\u0001' + '\u0006'; amfBody += "I8BA4CBAC-4903-65E8-BFD4-DAC61B28D122"; amfBody += new string(new char[] { '\u0001', '\u0004', '\u0000' }); amfBody += "\n"; amfBody += '\u0005' + "%DSMessagingVersion" + '\u0004' + '\u0001' + '\t'; amfBody += "DSId" + '\u0006' + '\u0007' + "nil" + '\u0001' + '\u0006' + '\u0001' + '\u0004' + '\u0000'; amfHeader += (amfBody.Length) + "\r\n\r\n"; string amfData = amfHeader + amfBody; req = new PostRequest(amfStreamUrl, ""); req.Cookies = cookies; req.Type = PostRequest.PostTypeEnum.Post; result = req.PostData(amfData); // Load Amf reader DsoAmfReader amfReader = new DsoAmfReader(result.ResponseData); // Open AMF stream NetConnection con = new NetConnection(); con.ObjectEncoding = GodLesZ.Library.Amf.ObjectEncoding.AMF3; con.NetStatus += new NetStatusHandler(con_NetStatus); con.OnConnect += new ConnectHandler(con_OnConnect); con.OnDisconnect += new DisconnectHandler(con_OnDisconnect); con.BeginConnect(amfStreamUrl, new AsyncCallback(con_Connect), con); Console.WriteLine("Connection started.."); Console.ReadLine(); }