public static PostResult GetPage(string Uri, string UriReferer, PostRequest.PostTypeEnum Method, string Params) { List<string> newParams = new List<string>(); Params = Params.Trim(); if (Params.Length > 0) { foreach (string splitPair in Params.Split('&')) { newParams.AddRange(splitPair.Split('=')); } } return GetPage(Uri, UriReferer, Method, newParams); }
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(); }
static void Main(string[] args) { PostRequest req = new PostRequest("http://94.236.31.135/http-bind/", ""); req.Type = PostRequest.PostTypeEnum.Post; string postData = ""; postData += "Referer: http://static13.cdn.ubi.com/settlers_online/live/de/L4230DE/SWMMO/debug/SWMMO.swf"; postData += "Content-type: text/xml"; postData += "Content-length: 189"; postData += "<body secure=\"false\" wait=\"20\" hold=\"1\" xml:lang=\"en\" xmlns=\"http://jabber.org/protocol/httpbind\" xmpp:version=\"1.0\" rid=\"365714\" ver=\"1.6\" xmlns:xmpp=\"urn:xmpp:xbosh\" to=\"94.236.31.135\" />"; var response = req.PostData(postData); /* * Starting Jabber Console, setting the Display settings * */ Console.Title = "Jabber Test"; Console.ForegroundColor = ConsoleColor.White; /* * Login * */ Console.WriteLine("Login"); Console.WriteLine(); Console.WriteLine("JID: "); string JID_Sender = Console.ReadLine(); Console.WriteLine("Password: "******"Wait for Login "); int i = 0; _wait = true; do { Console.Write("."); i++; if (i == 10) _wait = false; Thread.Sleep(500); } while (_wait); Console.WriteLine(); /* * * just reading a few information * */ Console.WriteLine("Login Status:"); Console.WriteLine("xmpp Connection State {0}", xmpp.XmppConnectionState); Console.WriteLine("xmpp Authenticated? {0}", xmpp.Authenticated); Console.WriteLine(); /* * * tell the world we are online and in chat mode * */ Console.WriteLine("Sending Precence"); Presence p = new Presence(ShowType.chat, "Online"); p.Type = PresenceType.available; xmpp.Send(p); Console.WriteLine(); /* * * get the roster (see who's online) */ xmpp.OnPresence += new PresenceHandler(xmpp_OnPresence); //wait until we received the list of available contacts Console.WriteLine(); Thread.Sleep(500); /* * now we catch the user entry, TODO: who is online */ Console.WriteLine("Enter Chat Partner JID:"); string JID_Receiver = Console.ReadLine(); Console.WriteLine(); /* * Chat starts here */ Console.WriteLine("Start Chat"); /* * Catching incoming messages in * the MessageCallBack */ xmpp.MessageGrabber.Add(new Jid(JID_Receiver), new BareJidComparer(), new MessageCB(MessageCallBack), null); /* * Sending messages * */ string outMessage; bool halt = false; do { Console.ForegroundColor = ConsoleColor.Green; outMessage = Console.ReadLine(); if (outMessage == "q!") { halt = true; } else { xmpp.Send(new Message(new Jid(JID_Receiver), MessageType.chat, outMessage)); } } while (!halt); Console.ForegroundColor = ConsoleColor.White; /* * finally we close the connection * */ xmpp.Close(); }