CreatePostData() публичный статический Метод

public static CreatePostData ( string>.Dictionary postData ) : byte[]
postData string>.Dictionary
Результат byte[]
Пример #1
0
        private void LoginGithub(string username, string password, string data, ref CookieContainer cookies)
        {
            //POST login data
            Dictionary <string, string> postData = new Dictionary <string, string> ();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://github.com/session");

            request.UserAgent       = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
            request.CookieContainer = cookies;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";

            postData.Add("utf8", "\u2713");
            postData.Add("authenticity_token", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name=\"authenticity_token\""), "value"));
            postData.Add("login", username);
            postData.Add("password", password);
            postData.Add("return_to", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input id=\"return_to\" name=\"return_to\""), "value"));

            byte[] postBuild = HttpHelper.CreatePostData(postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream().Write(postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
            {
                LoginCompleted(this, new LoginEventArgs(data, cookies));
            }
        }
Пример #2
0
        private void LoginNormal(string username, string password, string data, ref CookieContainer cookies)
        {
            //POST login data
            Dictionary <string, string> postData = new Dictionary <string, string> ();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://www.livecoding.tv/accounts/login/");

            request.UserAgent       = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
            request.CookieContainer = cookies;
            request.Method          = "POST";
            request.Referer         = "https://www.livecoding.tv/accounts/login/";
            request.ContentType     = "application/x-www-form-urlencoded";

            postData.Add("csrfmiddlewaretoken", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input type='hidden' name='csrfmiddlewaretoken'"), "value"));
            postData.Add("login", username);
            postData.Add("password", password);
            byte[] postBuild = HttpHelper.CreatePostData(postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream().Write(postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
            {
                LoginCompleted(this, new LoginEventArgs(data, cookies));
            }
        }
Пример #3
0
        private void LoginTwitch(string username, string password, string data, ref CookieContainer cookies)
        {
            //POST login data
            Dictionary <string, string> postData = new Dictionary <string, string> ();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://api.twitch.tv/kraken/oauth2/login");

            request.UserAgent       = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
            request.CookieContainer = cookies;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";

            postData.Add("utf8", "\u2713");
            postData.Add("authenticity_token", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name=\"authenticity_token\""), "value"));
            postData.Add("login_type", "login");
            postData.Add("client_id", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name='client_id'"), "value"));
            postData.Add("redirect_uri", "https://www.livecoding.tv/accounts/twitch/login/callback/");
            postData.Add("response_type", "code");
            postData.Add("scope", "user_read");
            postData.Add("state", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name='state'"), "value"));
            postData.Add("login", username);
            postData.Add("password", password);
            postData.Add("date[month]", "");
            postData.Add("date[day]", "");
            postData.Add("date[year]", "");
            postData.Add("email", "");
            postData.Add("g-recaptcha-response", "");
            byte[] postBuild = HttpHelper.CreatePostData(postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream().Write(postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
            {
                LoginCompleted(this, new LoginEventArgs(data, cookies));
            }
        }
Пример #4
0
        private void LoginLinkedIn(string username, string password, string data, ref CookieContainer cookies)
        {
            //POST login data
            Dictionary <string, string> postData = new Dictionary <string, string> ();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://www.linkedin.com/uas/oauth/authorize/submit");

            request.UserAgent       = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
            request.CookieContainer = cookies;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";

            postData.Add("isJsEnabled", "false");
            postData.Add("session_key", username);
            postData.Add("session_password", password);
            postData.Add("agree", "true");
            postData.Add("oauth_token", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input type=\"hidden\" name=\"oauth_token\""), "value"));
            postData.Add("csrfToken", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input type=\"hidden\" name=\"csrfToken\""), "value"));
            postData.Add("sourceAlias", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input type=\"hidden\" name=\"sourceAlias\""), "value"));
            //duration=0&authorize=Zugriff+erlauben&extra=&access=-3&agree=true&oauth_token=77--758ae117-ba0f-472e-b961-c05be8d12cc9&email=&appId=&csrfToken=ajax%3A3324717073940490783&sourceAlias=0_8L1usXMS_e_-SfuxXa1idxJ207ESR8hAXKfus4aDeAk&client_ts=1441384096141&client_r=%3A700951532%3A664704238%3A223863907&client_output=0&client_n=700951532%3A664704238%3A223863907&client_v=1.0.1
            postData.Add("return_to", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input id=\"return_to\" name=\"return_to\""), "value"));

            byte[] postBuild = HttpHelper.CreatePostData(postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream().Write(postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
            {
                LoginCompleted(this, new LoginEventArgs(data, cookies));
            }
        }
Пример #5
0
        private void LoginYahoo(string username, string password, string data, ref CookieContainer cookies)
        {
            //POST login data
            Dictionary <string, string> postData = new Dictionary <string, string> ();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create("https://www.yahooo.com" + HtmlHelper.Unescape(HtmlHelper.getAttribute(data, "action")));

            request.UserAgent       = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; .NET CLR 1.0.3705)";
            request.CookieContainer = cookies;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";

            postData.Add("username", username);
            postData.Add("passwd", password);
            postData.Add(".persistent", "y");
            postData.Add("signin", "");
            postData.Add("_crumb", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name=\"_crumb\""), "value"));
            postData.Add("_ts", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name=\"_ts\""), "value"));
            postData.Add("_uuid", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name=\"_uuid\""), "value"));
            postData.Add("_seqid", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input name=\"_seqid\""), "value"));
            //postData.Add ("return_to",HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data,"<input id=\"return_to\" name=\"return_to\""),"value"));

            byte[] postBuild = HttpHelper.CreatePostData(postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream().Write(postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
            {
                LoginCompleted(this, new LoginEventArgs(data, cookies));
            }
        }
Пример #6
0
        private void LoginWinLive(string username, string password, string data, ref CookieContainer cookies)
        {
            string urlPost, PPSX, Referer;
            int    starti, endi;

            starti = data.IndexOf("urlPost:'");
            if (starti < 0)
            {
                throw new NotImplementedException("urlPost not found");
            }
            starti += "urlPost:'".Length;
            endi    = data.IndexOf("'", starti);
            if (endi < 0)
            {
                throw new NotImplementedException("urlPost not found");
            }
            urlPost = data.Substring(starti, endi - starti);

            starti = data.IndexOf("O:'");
            if (starti < 0)
            {
                throw new NotImplementedException("PPSX not found");
            }
            starti += "O:'".Length;
            endi    = data.IndexOf("'", starti);
            if (endi < 0)
            {
                throw new NotImplementedException("PPSX not found");
            }
            PPSX = data.Substring(starti, endi - starti);

            starti = data.IndexOf("AV:'");
            if (starti < 0)
            {
                throw new NotImplementedException("AV:' not found");
            }
            starti += "AV:'".Length;
            endi    = data.IndexOf("&mkt", starti);
            if (endi < 0)
            {
                throw new NotImplementedException("AV:' not found");
            }
            Referer = data.Substring(starti, endi - starti);


            //POST login data

            Dictionary <string, string> postData = new Dictionary <string, string>();
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(urlPost);

            request.UserAgent       = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.85 Safari/537.36";
            request.CookieContainer = cookies;
            request.Method          = "POST";
            request.ContentType     = "application/x-www-form-urlencoded";
            request.Referer         = Referer;
            request.Accept          = "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8";

            postData.Add("loginfmt", username);
            postData.Add("passwd", password);
            postData.Add("KMSI", "1");
            postData.Add("SI", "Anmelden");
            postData.Add("login", username.ToLower());
            postData.Add("type", "11");
            postData.Add("PPFT", HtmlHelper.getAttribute(HtmlHelper.getSingleElement(data, "<input type=\"hidden\" name=\"PPFT\""), "value"));
            postData.Add("PPSX", PPSX);
            postData.Add("idsbho", "1");
            postData.Add("sso", "0");
            postData.Add("NewUser", "1");
            postData.Add("LoginOptions", "1");
            postData.Add("i1", "0");
            postData.Add("i2", "1");
            postData.Add("i3", "1000"); //LoginTime
            postData.Add("i4", "0");
            postData.Add("i7", "0");
            postData.Add("i12", "1");
            postData.Add("i13", "0");
            postData.Add("i14", "64"); // RenderTime
            postData.Add("i17", "0");
            postData.Add("i18", "__Login_Strings|1,__Login_Core|1,");
            byte[] postBuild = HttpHelper.CreatePostData(postData);
            request.ContentLength = postBuild.Length;
            request.GetRequestStream().Write(postBuild, 0, postBuild.Length);

            HttpWebResponse response = (HttpWebResponse)request.GetResponse();

            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream()))
            {
                data = sr.ReadToEnd();
            }

            if (LoginCompleted != null)
            {
                LoginCompleted(this, new LoginEventArgs(data, cookies));
            }
        }