namespace Devoid.Net.Http { using Devoid; using Devoid.Sessions; using System; using System.IO; using System.Net; using System.Text; public class siteHandler { // Faite ctrl+h et changer le lien en le liens que vous souhaiter, de préference selectionner projet actifs pour remplacer toute les valeurs dans devoid. private const string ACCOUNTSTART_SCRIPT = "me"; // Liens du me.php private const string CLIENT_SCRIPT = "client"; // liens du client.php public const string LOGIN_SCRIPT = "index.php?do=process_login"; // liens de l'index private const string REAUTH_SCRIPT = "reauthenticate.php"; // liens de la réautenthification public string sDcrLink; private const string SECURITYCHECK_SCRIPT = "security_check"; // liens du security_check public string sSiteUrl; public string sTextsLink; public string sVariablesLink; private const string USERDETAILS_APPEARANCE_SCRIPT = "account.php?tab=1"; private const string USERDETAILS_MOTTO_SCRIPT = "account.php?tab=2"; private const string USERDETAILS_TAGADD_SCRIPT = "habblet/tags_ajax.php?key=add"; public void addUserTag(userSession pSession, string Tag) { if (Engine.DEBUG_ENABLED) { Engine.Log("POSTing new tag data to habblet/tags_ajax.php?key=add for " + pSession.Username + "..."); } this.postBigRequestChunk(pSession.siteSessionID, "habblet/tags_ajax.php?key=add", "habblet/tags_ajax.php?key=add", "accountId=" + new Random().Next(0, 0x2710).ToString() + "&tagName=" + Tag); if (Engine.DEBUG_ENABLED) { Engine.Log("POSTed new tag data to habblet/tags_ajax.php?key=add for " + pSession.Username + ", tag added=" + Tag); } } private HttpWebRequest craftWebRequest(string Url, string Method, string Referer, string sessionID) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Url); request.Method = Method; request.Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"; request.Headers.Add(HttpRequestHeader.Cookie, "PHPSESSID=" + sessionID); request.ServicePoint.Expect100Continue = false; request.AllowAutoRedirect = true; request.ProtocolVersion = HttpVersion.Version11; request.Referer = Referer; request.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; nl; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4"; request.Proxy = null; request.ContentType = "application/x-www-form-urlencoded"; return request; } public string generateRandomPhpSessionID() { StringBuilder builder = new StringBuilder(0x20); Random random = new Random(DateTime.Now.Millisecond + DateTime.Now.Second); for (int i = 0; i < 0x20; i++) { int num2 = 0; if (random.Next(0, 2) == 1) { num2 = random.Next(0x61, 0x7b); } else { num2 = random.Next(0x30, 0x3a); } builder.Append((char)num2); } return builder.ToString().ToLower(); } public HttpWebResponse GetClientResponse(userSession pSession, bool allowReauthenticate) { HttpWebResponse response = (HttpWebResponse)this.craftWebRequest(this.sSiteUrl + "/client", "GET", "me", pSession.siteSessionID).GetResponse(); if (response.ResponseUri.LocalPath.Contains("client")) { return response; } response.Close(); if (allowReauthenticate && response.ResponseUri.LocalPath.Contains("reauthenticate.php")) { this.ReauthenticateSessionUser(pSession); allowReauthenticate = false; return this.GetClientResponse(pSession, false); } return null; } public string GetHtmlFromResponse(HttpWebResponse pResponse) { if (pResponse != null) { StreamReader reader = new StreamReader(pResponse.GetResponseStream()); return reader.ReadToEnd(); } return ""; } public userSession LogUserIn(string Username, string Password) { userSession session = new userSession(); if (Engine.DEBUG_ENABLED) { Engine.Log("Login attempt for " + Username + ", PHPSESSID=" + session.siteSessionID); } if (Engine.DEBUG_ENABLED) { Engine.Log("POSTing index.php?do=process_login for " + Username + " @ " + session.siteSessionID + "..."); } HttpWebResponse response = this.postBigRequestChunk(session.siteSessionID, "index.php?do=process_login", "index.php", "username=" + Username + "&password=" + Password); if (Engine.DEBUG_ENABLED) { Engine.Log("POSTed index.php?do=process_login for " + Username + " @ " + session.siteSessionID); } if ((response == null) || (!response.ResponseUri.LocalPath.Contains("security_check") && !response.ResponseUri.LocalPath.Contains("me"))) { if (Engine.DEBUG_ENABLED) { Engine.Log("Login failed, password for " + Username + " is probably incorrect."); } return null; } session.Username = Username; session.Password = Password; return session; } private HttpWebResponse postBigRequestChunk(string sessionID, string Script, string Referer, string szPostData) { try { HttpWebRequest request = this.craftWebRequest(this.sSiteUrl + "/" + Script, "POST", Referer, sessionID); Stream requestStream = request.GetRequestStream(); byte[] bytes = Encoding.Default.GetBytes(szPostData); requestStream.Write(bytes, 0, bytes.Length); requestStream.Flush(); requestStream.Close(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); response.Close(); return response; } catch { return null; } } public void ReauthenticateSessionUser(userSession pSession) { this.postBigRequestChunk(pSession.siteSessionID, "reauthenticate.php", "reauthenticate.php", "password=" + pSession.Password + "&page=client"); } public bool SetClientDetails(userSession trackerSession) { HttpWebResponse clientResponse = this.GetClientResponse(trackerSession, true); if (clientResponse != null) { string htmlFromResponse = this.GetHtmlFromResponse(clientResponse); clientResponse.Close(); if (htmlFromResponse.Contains("external.texts.txt=")) { string str2 = ""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.WriteLine(""); writer.Close(); } catch { return false; } if (Engine.DEBUG_ENABLED) { Engine.Log("Successfully written clientfile to ./client.htm"); } return true; } } }