static IRestResponse LoginToMoodle(string userName, string password)
        {
            RestClient client = new RestClient("https://courses.iitm.ac.in/login/index.php")
            {
                CookieContainer = new CookieContainer()
            };
            RestRequest request = new RestRequest(Method.POST);

            request.AddParameter("username", userName, ParameterType.GetOrPost);
            request.AddParameter("password", password, ParameterType.GetOrPost);
            request.AddHeader("HTTPonly", "true");
            IRestResponse response = client.Execute(request);
            string        xCookie  = client.CookieContainer.GetCookieHeader(new Uri("http://courses.iitm.ac.in"));

            string[] parsedStrings                        = xCookie.Split(new char[] { '=' });
            IList <RestResponseCookie> cookies            = response.Cookies;
            RestResponseCookie         restResponseCookie = new RestResponseCookie()
            {
                Name  = parsedStrings[0],
                Value = parsedStrings[1]
            };

            cookies.Add(restResponseCookie);
            return(response);
        }
        public RestResponseCookie Cookie;   //仅JSESSIONID字段

        public void GetURLs()
        {
            var client  = new RestClient(home_url);
            var request = new RestRequest(Method.GET);

            request.AddHeader("Host", "bkjw.whu.edu.cn");
            request.AddHeader("Connection", "keep-alive");
            request.AddHeader("Upgrade-Insecure-Requests", "1");
            request.AddHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36");
            request.AddHeader("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9");
            request.AddHeader("Accept-Language", "zh-CN,zh;q=0.9");
            var response         = client.Execute(request);
            var home_result_byte = response.RawBytes;

            Cookie = response.Cookies[0];   //JSESSIONID字段
            var home_result = Encoding.GetEncoding("GB2312").GetString(home_result_byte);
            //Console.WriteLine(home_result);

            var htmlDoc = new HtmlDocument();

            htmlDoc.LoadHtml(home_result);
            string action = htmlDoc.DocumentNode.SelectSingleNode("//div[@id='loginBox']/form").Attributes["action"].Value;

            login_url = home_url + action;

            //Console.WriteLine(login_url);
            var captcha = htmlDoc.DocumentNode.SelectSingleNode("//img[@name='sleep']").Attributes["src"].Value;

            captcha_url = home_url + captcha;


            //Console.WriteLine(captcha_url);
            //Console.ReadLine();
        }
Exemple #3
0
        private void login(string username, string password)
        {
            IRestRequest request = new RestRequest("arequest/login", Method.POST);

            request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            request.AddParameter("undefined", $"type=login" +
                                 $"&alias={username}" +
                                 $"&password={password}",
                                 ParameterType.RequestBody
                                 );
            IRestResponse response = client.Execute(request);

            if (!response.IsSuccessful)
            {
                Console.WriteLine($"failure to {nameof(login)}! with error {response.ErrorMessage} {response.Content} {response.StatusCode}");
            }

            foreach (RestResponseCookie restResponseCookie in response.Cookies) //
            {
                if (restResponseCookie.Name == "auth")
                {
                    authCookie = restResponseCookie;
                }
            }
        }
Exemple #4
0
 public static Cookie ToHttpCookie(this RestResponseCookie restResponseCookie)
 {
     return(new Cookie(restResponseCookie.Name, restResponseCookie.Value, RemoveTrailingSlash(restResponseCookie.Path), restResponseCookie.Domain)
     {
         Expires = restResponseCookie.Expires, Expired = restResponseCookie.Expired, HttpOnly = restResponseCookie.HttpOnly
     });
 }
Exemple #5
0
        public void Login(string username, string password, bool remember = false)
        {
            RestRequest request = Post("?login");

            request.AddParameter("user", username);
            request.AddParameter("pass", password);

            IRestResponse response = Execute(request);

            RestResponseCookie keyCookie = response.Cookies.SingleOrDefault(x => x.Name == "mcx_key");

            if (keyCookie == null)
            {
                throw new AuthenticationFailed();
            }
            secretKey = keyCookie.Value;

            RestResponseCookie sessionCookie = response.Cookies.SingleOrDefault(x => x.Name == "mcx_sess");

            if (sessionCookie == null)
            {
                throw new AuthenticationFailed();
            }
            session = sessionCookie.Value;

            if (remember)
            {
                this.password = password;
            }
        }
Exemple #6
0
 public void Add(RestResponseCookie cookie)
 {
     Add(new Cookie
     {
         Name    = cookie.Name,
         Value   = cookie.Value,
         Domain  = cookie.Domain,
         Expires = cookie.Expires
     });
 }
        public RestSenatApiClient_(string baseUrl)
        {
            ServicePointManager.ServerCertificateValidationCallback += (sender, cert, chain, sslPolicyErrors) => true;
            _baseUrl    = baseUrl;
            _restClient = new RestClient(_baseUrl);
            var request1 = new RestRequest("api/account/login", Method.POST);

            request1.AddJsonBody(new LoginDto());
            var response = _restClient.Post <Identific>(request1);

            _restResponseCookie = response.Cookies.First((x) => x.Name == authCookie);
        }
Exemple #8
0
        private static List <RestResponseCookie> CreateRestResponseCookies()
        {
            List <RestResponseCookie> restResponseCookies = new List <RestResponseCookie>();

            authenticationCookie = new RestResponseCookie()
            {
                Name = "foobar"
            };
            restResponseCookies.Add(authenticationCookie);

            return(restResponseCookies);
        }
Exemple #9
0
        private static bool IsAuthenticated()
        {
            var client  = new RestClient("https://www.octopus-hr.co.uk/portal/login.asp?ajax=t");
            var request = new RestRequest(Method.POST);

            request.AddHeader("content-type", "application/x-www-form-urlencoded");
            request.AddParameter("Username", "qaworkstest", ParameterType.GetOrPost);
            request.AddParameter("Password", "qaworks123456789", ParameterType.GetOrPost);

            var response = client.Execute(request);

            _cookie = response.Cookies.SingleOrDefault(x => x.Name == "ASPSESSIONIDAGSAARRB");
            return(!response.Content.Contains("Your username or password is not valid."));
        }
Exemple #10
0
 public static bool Equals(this RestResponseCookie cookie, RestResponseCookie other)
 {
     return(cookie.Comment == other.Comment &&
            cookie.CommentUri == other.CommentUri &&
            cookie.Discard == other.Discard &&
            cookie.Domain == other.Domain &&
            cookie.Expired == other.Expired &&
            cookie.Expires == other.Expires &&
            cookie.HttpOnly == other.HttpOnly &&
            cookie.Name == other.Name &&
            cookie.Path == other.Path &&
            cookie.Port == other.Port &&
            cookie.Secure == other.Secure &&
            cookie.TimeStamp == other.TimeStamp &&
            cookie.Value == other.Value &&
            cookie.Version == other.Version);
 }
Exemple #11
0
        /// <summary>
        /// 获取赔率  /ac_targetList.php   MarketOrder  /targetList.php
        /// </summary>
        /// <param name="head"></param>
        /// <returns></returns>
        public List <Info> GetInfo(Match head)
        {
            var request = new RestRequest($"ac_targetList.php", Method.POST);

            request.AddParameter("gameid", head.gameid);
            request.AddParameter("ga12", head.ga12);
            request.AddParameter("gametime", head.gametime);
            request.AddParameter("noCache", "");

            CookieContainer    _cookieJar = new CookieContainer();
            RestResponseCookie cookie     = cookies.FirstOrDefault();

            _cookieJar.Add(new Cookie(cookie.Name, cookie.Value, cookie.Path, cookie.Domain));
            restclient.CookieContainer = _cookieJar;
            var response = restclient.Execute(request);

            return(GetInfo(response.Content, head));
        }
        public void Login()
        {
            ApiLoginModel model = new ApiLoginModel()
            {
                Email = "*****@*****.**", Password = "******"
            };

            using (RESTClient restClient = new RESTClient(BaseUrl))
            {
                RestResult apiResult = restClient.Execute("Authorize/Login", RestSharp.Method.POST, jsonBody: model);

                Assert.True(apiResult.StatusCode == StatusCodes.Status200OK, "Logging in was not sucessful.");

                this.ApiToken  = apiResult.Headers.Find(h => h.Name == "ApiToken").Value.ToString();
                this.ApiCookie = apiResult.Cookies.Find(c => c.Name == AuthCookieName);

                Assert.True(this.ApiToken != string.Empty, "A token was not returned");
            }
        }
        private static Cookie convertRestSharpToSeleniumCookie(RestResponseCookie c)
        {
            //Cookie.FromDictionary allows us to set all cookie properties using a dictionary.
            //We create the raw cookie dictionary using the properties from the RestResponseCookie

            Dictionary <string, object> rawCookie = new Dictionary <string, object> {
            };

            if (c.Name != null)
            {
                rawCookie["name"] = c.Name;
            }
            if (c.Domain != null)
            {
                rawCookie["domain"] = c.Domain;
            }
            ;
            if (c.Value != null)
            {
                rawCookie["value"] = c.Value;
            }
            ;
            if (c.Path != null)
            {
                rawCookie["path"] = c.Path;
            }
            ;
            rawCookie["httpOnly"] = c.HttpOnly ? "true" : "false";
            rawCookie["secure"]   = c.Secure ? "true" : "false";
            if (c.Expires != null)
            {
                rawCookie["expiry"] = c.Expires;
            }
            ;

            Cookie cookie = Cookie.FromDictionary(rawCookie);


            return(cookie);
        }
Exemple #14
0
        public void LoadSessionCookie(string value)
        {
            if (IsLoggedIn)
            {
                return;
            }

            if (SessionCookie != null)
            {
                SessionCookie.Value = value;
            }
            else
            {
                var cookie = new RestResponseCookie();
                cookie.Name    = "me";
                cookie.Value   = value;
                cookie.Domain  = "pr0gramm.com";
                cookie.Path    = "/";
                cookie.Expires = DateTime.Now.AddYears(10);
                cookies.Add(cookie);
            }
        }
        public bool Login(ref char[] rollno, ref char[] password)
        {
            RestClient client = new RestClient(@"http://internship.iitm.ac.in/students/login.php")
            {
                FollowRedirects = false
            };
            RestRequest request = new RestRequest(Method.POST);

            request.AddParameter("rollno", new string (rollno), ParameterType.GetOrPost);
            request.AddParameter("pass", new string (password), ParameterType.GetOrPost);
            request.AddParameter("submit", "Login", ParameterType.GetOrPost);
            IRestResponse response = client.Execute(request);

            if (response.StatusCode != HttpStatusCode.Found)
            {
                return(false);
            }
            cookie = response.Cookies.First();
            WipeChar(ref rollno);
            WipeChar(ref password);
            return(true);
        }
        public bool CompleteSignup(string alias, string password, ref string status, bool addcsgo)
        {
            if (!HttpHandler.smethod_0(alias, ref status))
            {
                return(false);
            }
            if (!HttpHandler.smethod_1(password, alias, ref status))
            {
                return(false);
            }
            this.restClient_0.BaseUrl = HttpHandler.uri_7;
            if (this.mainForm_0.proxy)
            {
                this.restClient_0.Proxy = new WebProxy(this.mainForm_0.proxyval, this.mainForm_0.proxyport);
            }
            this.restRequest_0.Method = Method.POST;
            this.restRequest_0.AddParameter("accountname", alias);
            this.restRequest_0.AddParameter("password", password);
            this.restRequest_0.AddParameter("creation_sessionid", this.string_1);
            this.restRequest_0.AddParameter("count", "1");
            this.restRequest_0.AddParameter("lt", "0");
            IRestResponse      restResponse       = this.restClient_0.Execute(this.restRequest_0);
            RestResponseCookie restResponseCookie = restResponse.Cookies.SingleOrDefault(new Func <RestResponseCookie, bool>(HttpHandler.Class5.class5_0.method_0));

            if (restResponseCookie != null)
            {
                this._cookieJar.Add(new Cookie(restResponseCookie.Name, restResponseCookie.Value, restResponseCookie.Path, restResponseCookie.Domain));
            }
            this.restRequest_0.Parameters.Clear();
            object arg = JsonConvert.DeserializeObject(restResponse.Content);

            if (HttpHandler.Class4.callSite_2 == null)
            {
                HttpHandler.Class4.callSite_2 = CallSite <Func <CallSite, object, bool> > .Create(Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(HttpHandler), new CSharpArgumentInfo[]
                {
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                }));
            }
            Func <CallSite, object, bool> target = HttpHandler.Class4.callSite_2.Target;
            CallSite callSite_ = HttpHandler.Class4.callSite_2;

            if (HttpHandler.Class4.callSite_1 == null)
            {
                HttpHandler.Class4.callSite_1 = CallSite <Func <CallSite, object, string, object> > .Create(Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Equal, typeof(HttpHandler), new CSharpArgumentInfo[]
                {
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null),
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.Constant, null)
                }));
            }
            Func <CallSite, object, string, object> target2 = HttpHandler.Class4.callSite_1.Target;
            CallSite callSite_2 = HttpHandler.Class4.callSite_1;

            if (HttpHandler.Class4.callSite_0 == null)
            {
                HttpHandler.Class4.callSite_0 = CallSite <Func <CallSite, object, object> > .Create(Binder.GetMember(CSharpBinderFlags.None, "bSuccess", typeof(HttpHandler), new CSharpArgumentInfo[]
                {
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                }));
            }
            if (target(callSite_, target2(callSite_2, HttpHandler.Class4.callSite_0.Target(HttpHandler.Class4.callSite_0, arg), "true")))
            {
                status = "Account created";
                this.restClient_0.FollowRedirects = false;
                this.restClient_0.CookieContainer = this._cookieJar;
                this.restClient_0.BaseUrl         = new Uri("https://store.steampowered.com/twofactor/manage_action");
                if (this.mainForm_0.proxy)
                {
                    this.restClient_0.Proxy = new WebProxy(this.mainForm_0.proxyval, this.mainForm_0.proxyport);
                }
                this.restRequest_0.Method = Method.POST;
                this.restRequest_0.AddParameter("action", "actuallynone");
                this.restRequest_0.AddParameter("sessionid", this.string_1);
                IRestResponse restResponse2 = this.restClient_0.Execute(this.restRequest_0);
                string        value         = "";
                restResponseCookie = restResponse2.Cookies.SingleOrDefault(new Func <RestResponseCookie, bool>(HttpHandler.Class5.class5_0.method_1));
                if (restResponseCookie != null)
                {
                    this._cookieJar.Add(new Cookie(restResponseCookie.Name, restResponseCookie.Value, restResponseCookie.Path, restResponseCookie.Domain));
                    value = restResponseCookie.Value;
                }
                this.restRequest_0.Parameters.Clear();
                this.restClient_0.CookieContainer = this._cookieJar;
                this.restClient_0.BaseUrl         = new Uri("https://store.steampowered.com/twofactor/manage_action");
                if (this.mainForm_0.proxy)
                {
                    this.restClient_0.Proxy = new WebProxy(this.mainForm_0.proxyval, this.mainForm_0.proxyport);
                }
                this.restRequest_0.Method = Method.POST;
                this.restRequest_0.AddParameter("action", "actuallynone");
                this.restRequest_0.AddParameter("sessionid", value);
                this.restClient_0.Execute(this.restRequest_0);
                this.restClient_0.FollowRedirects = true;
                this.restRequest_0.Parameters.Clear();
                if (addcsgo)
                {
                    this.restClient_0.BaseUrl = new Uri("https://store.steampowered.com/checkout/addfreelicense");
                    if (this.mainForm_0.proxy)
                    {
                        this.restClient_0.Proxy = new WebProxy(this.mainForm_0.proxyval, this.mainForm_0.proxyport);
                    }
                    this.restRequest_0.Method = Method.POST;
                    this.restRequest_0.AddParameter("action", "add_to_cart");
                    this.restRequest_0.AddParameter("subid", 303386);
                    this.restRequest_0.AddParameter("sessionid", value);
                    this.restClient_0.Execute(this.restRequest_0);
                    this.restClient_0.FollowRedirects = true;
                }
                return(true);
            }
            if (HttpHandler.Class4.callSite_4 == null)
            {
                HttpHandler.Class4.callSite_4 = CallSite <Func <CallSite, object, string> > .Create(Binder.Convert(CSharpBinderFlags.None, typeof(string), typeof(HttpHandler)));
            }
            Func <CallSite, object, string> target3 = HttpHandler.Class4.callSite_4.Target;
            CallSite callSite_3 = HttpHandler.Class4.callSite_4;

            if (HttpHandler.Class4.callSite_3 == null)
            {
                HttpHandler.Class4.callSite_3 = CallSite <Func <CallSite, object, object> > .Create(Binder.GetMember(CSharpBinderFlags.None, "details", typeof(HttpHandler), new CSharpArgumentInfo[]
                {
                    CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null)
                }));
            }
            status = target3(callSite_3, HttpHandler.Class4.callSite_3.Target(HttpHandler.Class4.callSite_3, arg));
            return(false);
        }
 internal bool method_0(RestResponseCookie restResponseCookie_0)
 {
     return(restResponseCookie_0.Name == "steamLoginSecure");
 }
        public static string GetValueByName(this IList <RestResponseCookie> list, string name)
        {
            RestResponseCookie p = list.FirstOrDefault(parameter => parameter.Name == name);

            return(p != null ? p.Value : null);
        }
 internal bool method_1(RestResponseCookie restResponseCookie_0)
 {
     return(restResponseCookie_0.Name == "sessionid");
 }
        public static IList <RestResponseCookie> AddToCart(int ID, string size, string color, string profile, string proxy, string site)
        {
            RestResponseCookie ck = new RestResponseCookie();
            var FinalId           = GetProductInfo(ID, size, color, proxy);
            var s  = "";
            var st = "";

            if (FinalId.Split('|').Length > 1)
            {
                s  = FinalId.Split('|')[0];
                st = FinalId.Split('|')[1];
            }
            var url = "https://www.supremenewyork.com/shop/" + ID + "/add.json";
            //var csrf = "tdjOhyLywoot+7kYc2qywEga4cKVmTAgeOKZ1WL25TO5ZkfqRI8S+V4xLLu3QnyFiLta22JZk+MCw18drQNOOg==";

            RestClient restClient = new RestClient(url);


            RestRequest restRequest = new RestRequest(Method.POST);

            if (proxy != "" && proxy != "NA")
            {
                var plen = proxy.Split(':').Length;
                if (plen > 2)
                {
                    WebProxy proxy1 = new WebProxy(proxy.Split(':')[0] + ":" + proxy.Split(':')[1], true);
                    proxy1.Credentials = new NetworkCredential(proxy.Split(':')[2], proxy.Split(':')[3]);
                    //proxy1.UseDefaultCredentials = true;
                    WebRequest.DefaultWebProxy = proxy1;
                    restClient.Proxy           = proxy1; // new WebProxy(proxy.Split(':')[0] + ":" + proxy.Split(':')[1]);
                }
                else
                {
                    restClient.Proxy = new WebProxy(proxy.Split(':')[0] + ":" + proxy.Split(':')[1]);
                }
            }
            else
            {
                restClient.Proxy = new WebProxy();
            }
            //restRequest.AddParameter("utf-8", "%E2%9C%93");
            if (site.ToLower() == "supreme eu")
            {
                restRequest.AddParameter("size", s);
                restRequest.AddParameter("style", st);
            }
            else
            {
                restRequest.AddParameter("s", s);
                restRequest.AddParameter("st", st);
            }
            restRequest.AddParameter("qty", "1");
            //restRequest.AddParameter("X-CSRF-Token", csrf);
            //restRequest.AddParameter("h", "1");
            //restRequest.AddParameter("commit", "add to basket");

            restRequest.AddHeader("User-agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 13_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/80.0.3987.95 Mobile/15E148 Safari/604.1");
            restRequest.AddHeader("Accept-Language", "en-US,en;q=0.5");
            restRequest.AddHeader("X-Requested-With", "XMLHttpRequest");
            restRequest.AddHeader("If-None-Match", "'*'");
            restRequest.AddHeader("Content-Type", "application/x-www-form-urlencoded");
            restRequest.AddHeader("Origin", "https://www.supremenewyork.com");
            restRequest.AddHeader("DNT", "1");
            restRequest.AddHeader("Connection", "keep-alive");
            restRequest.AddHeader("Referer", "https://www.supremenewyork.com/mobile/");
            restRequest.AddHeader("Pragma", "no-cache");
            restRequest.AddHeader("Cache-Control", "no-cache");
            restRequest.AddHeader("TE", "Trailers");
            //Executing request to server and checking server response to the it
            IRestResponse restResponse = restClient.Execute(restRequest);

            if (FinalId == "Add to cart Failed!" || FinalId == "Color Not Found!" || FinalId == "Size Not Found!" || FinalId == "Not Found!")
            {
                ck.Expires = DateTime.Now.AddDays(1);
                ck.Name    = "Result";
                ck.Value   = FinalId;
                restResponse.Cookies.Add(ck);

                return(restResponse.Cookies);
            }
            if (FinalId == "Failed!")
            {
                ck.Expires = DateTime.Now.AddDays(1);
                ck.Name    = "Result";
                ck.Value   = FinalId;
                restResponse.Cookies.Add(ck);
                return(restResponse.Cookies);
            }
            string response = restResponse.Content;

            dynamic dynJson = JsonConvert.DeserializeObject(response);

            foreach (var item in dynJson)
            {
                if (site.ToLower() == "supreme eu")
                {
                    try
                    {
                        if (item["size_id"] != null || item[0] != "")
                        {
                            var sizes = item["size_id"].ToString();
                            ck.Expires = DateTime.Now.AddDays(1);
                            ck.Name    = "Result";
                            ck.Value   = "Added to cart";
                            restResponse.Cookies.Add(ck);

                            RestResponseCookie ck1 = new RestResponseCookie();
                            ck1.Expires = DateTime.Now.AddDays(1);
                            ck1.Name    = "Size";
                            ck1.Value   = sizes;
                            restResponse.Cookies.Add(ck1);

                            //var result =  ProceedToCheckOut(restResponse.Cookies, profile);
                            return(restResponse.Cookies);
                        }
                        else
                        {
                        }
                    }
                    catch
                    {
                    }
                }
                else
                {
                    if (item.Name == "success")
                    {
                        if (item.Value == "True")
                        {
                            ck.Expires = DateTime.Now.AddDays(1);
                            ck.Name    = "Result";
                            ck.Value   = "Added to cart";
                            restResponse.Cookies.Add(ck);

                            RestResponseCookie ck1 = new RestResponseCookie();
                            ck1.Expires = DateTime.Now.AddDays(1);
                            ck1.Name    = "Size";
                            ck1.Value   = s;
                            restResponse.Cookies.Add(ck1);

                            //var result =  ProceedToCheckOut(restResponse.Cookies, profile);
                            return(restResponse.Cookies);
                        }
                        else
                        {
                            ck.Expires = DateTime.Now.AddDays(1);
                            ck.Name    = "Result";
                            ck.Value   = "Sold Out!";
                            restResponse.Cookies.Add(ck);
                            return(restResponse.Cookies);
                        }
                    }
                }
            }
            ck.Expires = DateTime.Now.AddDays(1);
            ck.Name    = "Result";
            ck.Value   = "Add to cart Failed!";
            restResponse.Cookies.Add(ck);
            return(restResponse.Cookies);
        }