コード例 #1
0
        static void Main(string[] args)
        {
            // Each geely account has two parameters : User, Password
            var user     = "******";          // !!! rewrite value from your account !!!
            var password = "******";      // !!! rewrite value from your account !!!

            // We keep cookies here
            var cookies = new CookieContainer();

            // Any proxy, for example Fiddler
            var proxy = new WebProxy("127.0.0.1:8888");

            var getRequest = new GetRequest()
            {
                Address   = "https://igepc.geely.com/",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "igepc.geely.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // here we get a captcha
            getRequest = new GetRequest()
            {
                Address   = "https://igepc.geely.com/api/user:captcha",
                Accept    = "image/png",
                Host      = "igepc.geely.com",
                KeepAlive = true,
                UseUnsafeHeaderParsing = true,
                Referer = "https://igepc.geely.com/",
                Proxy   = proxy
            };
            getRequest.Run(ref cookies);

            // we should use any anticaptcha service to take a captcha text
            var captchaText = "";

            // Auth request
            var postRequest = new PostRequest()
            {
                Data        = $"{{\"loginName\":\"{WebUtility.UrlEncode(user)}\",\"password\":\"{WebUtility.UrlEncode(password)}\",\"verification\":\"{captchaText}\"}}",
                Address     = $"https://igepc.geely.com/api/login:pc?companyId=6",
                Accept      = "*/*",
                Host        = "igepc.geely.com",
                ContentType = "application/json",
                Referer     = "https://igepc.geely.com/",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);


            // we find all the new cookies in response headers and add them to cookie container
            var uri     = new Uri("http://igepc.geely.com/");
            var headers = postRequest.ResponseHeaders;

            for (int i = 0; i < headers.Count; ++i)
            {
                string header = headers.GetKey(i);
                foreach (string value in headers.GetValues(i))
                {
                    if (header == "Set-Cookie")
                    {
                        var value2         = value.Split(';')[0];
                        var preparedCookie = value2.Split('=');
                        if (preparedCookie.Length < 2)
                        {
                            continue;
                        }

                        cookies.Add(new Cookie(preparedCookie[0], preparedCookie[1])
                        {
                            Domain = uri.Host
                        });
                    }
                }
            }

            getRequest = new GetRequest()
            {
                Address   = "https://igepc.geely.com/api/onestep/base/epc/language/get_user_language?companyId=6",
                Accept    = "*/*",
                Host      = "igepc.geely.com",
                KeepAlive = true,
                Referer   = "https://igepc.geely.com/",
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address   = "https://igepc.geely.com/api/Menu/platformId/4?companyId=6",
                Accept    = "*/*",
                Host      = "igepc.geely.com",
                KeepAlive = true,
                Referer   = "https://igepc.geely.com/",
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            var validIndex = getRequest.Response.Contains("code\":\"success");

            if (validIndex)
            {
                Config.Instance.AddLogInfo($"Auth result: successful");
            }
            else
            {
                Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong");
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        static void Main(string[] args)
        {
            // Each workshop account has two parameters : User, Password
            var user     = "******";          // !!! rewrite value from your account !!!
            var password = "******";      // !!! rewrite value from your account !!!

            // We keep cookies here
            var cookies = new CookieContainer();

            // Any proxy, for example Fiddler
            var proxy = new WebProxy("127.0.0.1:8888");

            var getRequest = new GetRequest()
            {
                Address   = "https://workshopdata.com/touch/site/layout/wsdLogin?lang=ru",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "workshopdata.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // Auth request to kia portal
            var postRequest = new PostRequest()
            {
                Data        = $"username={user}&password={password}&submit=%D0%92%D1%85%D0%BE%D0%B4&=",
                Address     = $"https://workshopdata.com/touch/site/layout/wsdLogin",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "workshopdata.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = $"https://workshopdata.com/touch/site/layout/wsdLogin?lang=ru",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address   = "https://workshopdata.com/touch/site/layout/makesOverview?urlDownloadSvgViewer=http%3A%2F%2Fdownload.adobe.com%2Fpub%2Fadobe%2Fmagic%2Fsvgviewer%2Fwin%2F3.x%2F3.03%2Fru%2FSVGView.exe",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "workshopdata.com",
                KeepAlive = true,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            Config.Instance.AddLogInfo($"x: {getRequest.Response}");

            // comfortable cookies presentation
            var catalogCookies = cookies.GetCookieCollection().CatalogCookies();

            // writing cookies in log
            foreach (var cookie in catalogCookies)
            {
                Config.Instance.AddLogInfo($"cookie: {cookie}");
            }

            // SUZUKI - is part of all the presented brends here
            var validIndex = getRequest.Response.IndexOf("SUZUKI");

            if (validIndex >= 0)
            {
                Config.Instance.AddLogInfo($"Auth result: successful");
            }
            else
            {
                Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong");
                return;
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            // Each nissan account has two parameters : User, Password
            var user     = "******";          // !!! rewrite value from your account !!!
            var password = "******";      // !!! rewrite value from your account !!!

            // We keep cookies here
            var cookies = new CookieContainer();

            // Any proxy, for example Fiddler
            var proxy = new WebProxy("127.0.0.1:8888");

            var getRequest = new GetRequest()
            {
                Address   = "https://eu.nissan.biz/",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "eu.nissan.biz",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // Auth request
            var data        = $"option=credential&target=https%3A%2F%2Feu.nissan.biz%2F&Ecom_User_ID={WebUtility.UrlEncode(user)}&Ecom_Password={WebUtility.UrlEncode(password)}&submit1=Log+in";
            var postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"https://login.eu.nissan.biz/nidp/idff/sso?sid=0&sid=0",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "login.eu.nissan.biz",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "https://login.eu.nissan.biz/nidp/idff/sso?id=B2B&sid=0&option=credential&sid=0&target=https%3A%2F%2Feu.nissan.biz%2F",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            // check for a state
            getRequest = new GetRequest()
            {
                Address   = "https://eu.nissan.biz",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "eu.nissan.biz",
                KeepAlive = true,
                TimeOut   = 120000,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            var validIndex = getRequest.Response.Contains("nissan-user");

            if (validIndex)
            {
                Config.Instance.AddLogInfo($"Auth result: successful");
            }
            else
            {
                Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong");
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        static void Main(string[] args)
        {
            // Each daf account has two parameters : User, Password
            var user     = "******";          // !!! rewrite value from your account !!!
            var password = "******";      // !!! rewrite value from your account !!!

            // We keep cookies here
            var cookies = new CookieContainer();

            // Any proxy, for example Fiddler
            var proxy = new WebProxy("127.0.0.1:8888");

            var getRequest = new GetRequest()
            {
                Address   = "https://eportal.daf.com/",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "eportal.daf.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // Auth request
            var data        = $"curl=Z2F&flags=0&forcedownlevel=0&formdir=1&trusted=0&username={WebUtility.UrlEncode(user)}&password={WebUtility.UrlEncode(password)}&SubmitCreds=%D0%92%D1%85%D0%BE%D0%B4+%D0%B2+%D1%81%D0%B8%D1%81%D1%82%D0%B5%D0%BC%D1%83";
            var postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"https://eportal.daf.com/CookieAuth.dll?Logon",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "eportal.daf.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "https://eportal.daf.com/CookieAuth.dll?GetLogon?curl=Z2F&reason=0&formdir=1",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address   = "https://eportal.daf.com/",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "eportal.daf.com",
                KeepAlive = true,
                Referer   = "https://eportal.daf.com/CookieAuth.dll?GetLogon?curl=Z2F&reason=0&formdir=1",
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address   = "https://eportal.daf.com/ePortalMenu/default.aspx",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "eportal.daf.com",
                KeepAlive = true,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            var validIndex = getRequest.Response.IndexOf("<title>DAF ePortal</title>");

            if (validIndex >= 0)
            {
                Config.Instance.AddLogInfo($"Auth result: successful");
            }
            else
            {
                Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong");
                return;
            }

            // comfortable cookies presentation
            var catalogCookies = cookies.GetCookieCollection().CatalogCookies();

            // writing cookies in log
            foreach (var cookie in catalogCookies)
            {
                Config.Instance.AddLogInfo($"cookie: {cookie}");
            }
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        static void Main(string[] args)
        {
            // Each mercedes account has two parameters : User, Password
            var user     = "******";          // !!! rewrite value from your account !!!
            var password = "******";      // !!! rewrite value from your account !!!

            // We keep cookies here
            var cookies = new CookieContainer();

            // Any proxy, for example Fiddler
            var proxy = new WebProxy("127.0.0.1:8888");

            var getRequest = new GetRequest()
            {
                Address   = "https://aftersales.daimler.com/login",
                Accept    = "text/html, application/xhtml+xml, image/jxr, */*",
                Host      = "aftersales.daimler.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            #region a few needed parameters

            var csrfStart = getRequest.Response.IndexOf("_csrf") + 14;
            var csrfEnd   = getRequest.Response.IndexOf("\"", csrfStart);
            var csrf      = getRequest.Response.Substring(csrfStart, csrfEnd - csrfStart);

            var startPing = getRequest.Response.IndexOf("pingResume=") + 15;
            var endPing   = getRequest.Response.IndexOf("/", startPing);
            var ping      = getRequest.Response.Substring(startPing, endPing - startPing);

            #endregion

            var uri = new Uri("https://daimler.com");
            cookies.Add(new Cookie("ADRUM", $"s={DateTime.Now.ToUnixTime()}124&r=https%3A%2F%2Flogin.daimler.com%2F%3F{DateTime.Now.ToUnixTime()}")
            {
                Domain = uri.Host
            });

            // auth request
            var postRequest = new PostRequest()
            {
                Data        = $"_csrf={csrf}&username={WebUtility.UrlEncode(user)}&pingResume=%2Fas%2F{ping}%2Fresume%2Fas%2Fauthorization.ping&password={WebUtility.UrlEncode(password)}",
                Address     = $"https://login.daimler.com/",
                Accept      = "text/html, application/xhtml+xml, image/jxr, */*",
                Host        = "login.daimler.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = $"https://login.daimler.com/?brand=default&resume=%2Fas%2F{ping}%2Fresume%2Fas%2Fauthorization.ping&spentity=null",
                KeepAlive   = true,
                Proxy       = proxy
            };
            postRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address           = "https://aftersales.i.daimler.com/mb-webparts/",
                Accept            = "text/html, application/xhtml+xml, */*",
                Host              = "aftersales.i.daimler.com",
                KeepAlive         = true,
                Referer           = "https://aftersales.daimler.com/home/",
                AllowAutoRedirect = false,
                Proxy             = proxy
            };
            getRequest.Run(ref cookies);

            #region a few needed parameters

            var s1       = getRequest.Response.IndexOf("&client_id=") + 11;
            var e1       = getRequest.Response.IndexOf("'", s1);
            var clientId = getRequest.Response.Substring(s1, e1 - s1);

            var s2    = getRequest.Response.IndexOf("var csrfValue =") + 17;
            var e2    = getRequest.Response.IndexOf("'", s2);
            var state = getRequest.Response.Substring(s2, e2 - s2);

            #endregion

            var addr = $"https://sso.daimler.com/as/authorization.oauth2?response_type=code&client_id={clientId}&scope=openid%20email%20profile&state={state}&redirect_uri=https%3A%2F%2Faftersales.i.daimler.com%2Fmb-webparts-oidcclient1%2Fsignin_cb";

            getRequest = new GetRequest()
            {
                Address   = addr,
                Accept    = "text/html, application/xhtml+xml, image/jxr, */*",
                Host      = "sso.daimler.com",
                KeepAlive = true,
                Referer   = "https://aftersales.i.daimler.com/mb-webparts/",
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            postRequest = new PostRequest()
            {
                Data        = $"clientTimeZone=Asia/Bangkok&browserType=LT_IE9",
                Address     = $"https://aftersales.i.daimler.com/mb-webparts/Login.action",
                Accept      = "text/html, application/xhtml+xml, image/jxr, */*",
                Host        = "aftersales.i.daimler.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = $"https://aftersales.i.daimler.com/mb-webparts/preLogin.action",
                KeepAlive   = true,
                Proxy       = proxy
            };
            postRequest.Run(ref cookies);

            var loginTokenStart = postRequest.Response.IndexOf("loginToken=") + 11;
            var loginTokenEnd   = postRequest.Response.IndexOf("\"", loginTokenStart);
            var loginToken      = postRequest.Response.Substring(loginTokenStart, loginTokenEnd - loginTokenStart);

            getRequest = new GetRequest()
            {
                Address   = $"https://aftersales.i.daimler.com/mb-webparts/ng/customer?loginToken={loginToken}&startWizard=true",
                Accept    = "text/html, application/xhtml+xml, image/jxr, */*",
                Host      = "aftersales.i.daimler.com",
                Referer   = $"https://aftersales.i.daimler.com/mb-webparts/ng/customer?0&loginToken={loginToken}",
                KeepAlive = true,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address   = "https://aftersales.i.daimler.com/mb-webparts/ng/customer/epc/catalogue",
                Accept    = "text/html, application/xhtml+xml, image/jxr, */*",
                Host      = "aftersales.i.daimler.com",
                KeepAlive = true,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            var validIndex = getRequest.Response.Contains("Mercedes-Benz WebParts</title>");
            if (validIndex)
            {
                Config.Instance.AddLogInfo($"Auth result: successful");
            }
            else
            {
                Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong");
            }
        }
コード例 #6
0
        static void Main(string[] args)
        {
            // Each suzuki account has two parameters : User, Password
            var user     = "******";          // !!! rewrite value from your account !!!
            var password = "******";      // !!! rewrite value from your account !!!

            // We keep cookies here
            var cookies = new CookieContainer();

            // Any proxy, for example Fiddler
            var proxy = new WebProxy("127.0.0.1:8888");

            var getRequest = new GetRequest()
            {
                Address   = "https://suzuki.snaponepc.com/epc/#/",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "suzuki.snaponepc.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // password must be encoded into base64
            var passBase64 = password.ToBase64();
            var data       = $"user={user}&password={passBase64}";

            // auth request
            var postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"https://suzuki.snaponepc.com/epc-services/auth/login/",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "suzuki.snaponepc.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "https://suzuki.snaponepc.com/epc/#/",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            // we need to use try/catch. if auth is unsuccessful then we will catch an exception
            try
            {
                postRequest = new PostRequest()
                {
                    Data        = "",
                    Address     = $"https://suzuki.snaponepc.com/epc-services/auth/account",
                    Accept      = "text/html, application/xhtml+xml, */*",
                    Host        = "suzuki.snaponepc.com",
                    ContentType = "application/x-www-form-urlencoded",
                    Referer     = "https://suzuki.snaponepc.com/epc/",
                    KeepAlive   = true,
                    Proxy       = proxy
                };
                postRequest.Run(ref cookies);
            }
            catch (Exception exception)
            {
                Config.Instance.AddLogInfo($"Auth result: bad. {exception.Message}");
                return;
            }



            // if we here then auth is successful

            // comfortable cookies presentation
            var catalogCookies = cookies.GetCookieCollection().CatalogCookies();

            // writing cookies in log
            foreach (var cookie in catalogCookies)
            {
                Config.Instance.AddLogInfo($"cookie: {cookie}");
            }

            // writing Authentication result status in log
            Config.Instance.AddLogInfo($"Auth result: successful");
        }