コード例 #1
0
        static void Main(string[] args)
        {
            // Each vaz 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");

            // auth request
            var data        = $"id2_hf_0=&username={user}&password={password}&search=%D0%92%D0%BE%D0%B9%D1%82%D0%B8";
            var postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"http://portal-etc-auto.vaz.ru:7003/login?0-1.IFormSubmitListener-signIn-signInForm",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "portal-etc-auto.vaz.ru:7003",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "http://portal-etc-auto.vaz.ru:7003/login",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            // writing auth response in log
            Config.Instance.AddLogInfo($"vaz auth answer: {postRequest.Response}");

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

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

            var result = "unknown";

            if (postRequest.Response.Contains("news"))
            {
                result = "Authentication successful";
            }
            else
            {
                result = "Authentication failed";
            }

            // writing Authentication result status in log
            Config.Instance.AddLogInfo($"Auth result: {result}");
        }
コード例 #2
0
        public static Cookie GetCookieByName(this CookieContainer cookieJar, string key)
        {
            var collection = cookieJar.GetCookieCollection();

            foreach (Cookie cookie in collection)
            {
                if (cookie.ToString().Contains(key))
                {
                    return(cookie);
                }
            }
            return(null);
        }
コード例 #3
0
ファイル: Session.cs プロジェクト: battyone/Mail.Ru
        private static void Create()
        {
            try
            {
                // We keep cookies here
                var cookies = new CookieContainer();

                // Any proxy, for example Fiddler
                var proxy = new WebProxy(_proxy);

                // we need to create this request to get 'windowName' parameter. it requires for auth
                var getRequest = new GetRequest()
                {
                    Address   = "https://mail.ru/",
                    Accept    = "text/html, application/xhtml+xml, image/jxr, */*",
                    Host      = "mail.ru",
                    KeepAlive = true,
                    TimeOut   = 10000,
                    Proxy     = proxy
                };
                getRequest.Run(ref cookies);

                // find 'token' parameter
                var startIndex = getRequest.Response.IndexOf("CSRF:") + 6;
                var endIndex   = getRequest.Response.IndexOf("\"", startIndex);
                var token      = getRequest.Response.Substring(startIndex, endIndex - startIndex);

                // auth request
                var postRequest = new PostRequest()
                {
                    Data        = $"login={WebUtility.UrlEncode(_user)}&password={WebUtility.UrlEncode(_password)}&saveauth=1&token={token}&project=e.mail.ru&_={DateTime.Now.ToUnixTime()}",
                    Address     = @"https://auth.mail.ru/jsapi/auth",
                    Accept      = "*/*",
                    Host        = "auth.mail.ru",
                    ContentType = "application/x-www-form-urlencoded",
                    Referer     = "https://mail.ru/",
                    KeepAlive   = true,
                    Proxy       = proxy
                };
                postRequest.Run(ref cookies);

                _sessionCookies = cookies.GetCookieCollection().CatalogCookies();
            }
            catch (Exception)
            {
            }
        }
コード例 #4
0
ファイル: Methods.cs プロジェクト: battyone/Authorizations
        public static List <string> GetCookiesFromUri(Uri uri)
        {
            CookieContainer cookies = null;
            var             result  = new List <string>();
            // Determine the size of the cookie
            int           datasize   = 8192 * 16;
            StringBuilder cookieData = new StringBuilder(datasize);

            if (!InternetGetCookieEx(uri.ToString(), null, cookieData, ref datasize, InternetCookieHttponly, IntPtr.Zero))
            {
                if (datasize < 0)
                {
                    return(null);
                }
                // Allocate stringbuilder large enough to hold the cookie
                cookieData = new StringBuilder(datasize);
                if (!InternetGetCookieEx(
                        uri.ToString(),
                        null, cookieData,
                        ref datasize,
                        InternetCookieHttponly,
                        IntPtr.Zero))
                {
                    return(null);
                }
            }
            cookies = new CookieContainer();
            if (cookieData.Length > 0)
            {
                cookies.SetCookies(uri, cookieData.ToString().Replace(';', ','));
            }

            foreach (Cookie cookie in cookies.GetCookieCollection())
            {
                result.Add($"{cookie.Name}={cookie.Value}");
            }

            return(result);
        }
コード例 #5
0
        static void Main(string[] args)
        {
            // Each citroen 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");

            // we need to create this request to get 'windowName' parameter. it requires for auth
            var getRequest = new GetRequest()
            {
                Address   = "http://service.citroen.com/pages/index.jsp",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "service.citroen.com",
                KeepAlive = true,
                TimeOut   = 10000,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // find 'windowName' parameter
            var startIndex = getRequest.Response.IndexOf("window.name") + 14;
            var endIndex   = getRequest.Response.IndexOf("'", startIndex);
            var windowName = getRequest.Response.Substring(startIndex, endIndex - startIndex);

            // auth request
            var postRequest = new PostRequest()
            {
                Data        = $"userid={user}&password={password}&window={windowName}",
                Address     = @"http://service.citroen.com/do/login",
                Accept      = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
                Host        = "service.citroen.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "http://service.citroen.com/pages/index.jsp",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            // writing auth response in log
            Config.Instance.AddLogInfo($"citroen auth answer: {postRequest.Response}");

            getRequest = new GetRequest()
            {
                Address   = "http://service.citroen.com/do/newApvprStart",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "service.citroen.com",
                KeepAlive = true,
                Proxy     = proxy,
                Referer   = "http://service.citroen.com/pages/index.jsp"
            };
            getRequest.Run(ref cookies);

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

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

            var result = "unknown";

            if (postRequest.Response.Contains("loginForm"))
            {
                result = "Authentication failed";
            }
            else
            {
                result = "Authentication successful";
            }

            // writing Authentication result status in log
            Config.Instance.AddLogInfo($"Auth result: {result}");
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        static void Main(string[] args)
        {
            // Each bmw 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://etk-b2i.bmwgroup.com/?portal=OSMC&lang=ru_RU",
                Accept            = "text/html, application/xhtml+xml, */*",
                Host              = "etk-b2i.bmwgroup.com",
                AllowAutoRedirect = false,
                KeepAlive         = true,
                Proxy             = proxy
            };

            getRequest.Run(ref cookies);

            // we should find 'Location' parameter in response headers
            var location = "";
            var keys     = getRequest.ResponseHeaders.AllKeys;

            foreach (string key in keys)
            {
                if (key == "Location")
                {
                    location = getRequest.ResponseHeaders.Get(key);
                }
            }

            var smagentnameStart = location.IndexOf("SMAGENTNAME=") + 12;
            var smagentnameEnd   = location.IndexOf("&", smagentnameStart);
            var smagentname      = location.Substring(smagentnameStart, smagentnameEnd - smagentnameStart);
            var smSplitted       = smagentname.Split('$');

            smagentname = smSplitted[smSplitted.Length - 1];

            var typeStart = location.IndexOf("TYPE=") + 5;
            var typeEnd   = location.IndexOf("&", typeStart);
            var type      = location.Substring(typeStart, typeEnd - typeStart);

            var realmoidStart = location.IndexOf("REALMOID=") + 9;
            var realmoidEnd   = location.IndexOf("&", realmoidStart);
            var realmoid      = location.Substring(realmoidStart, realmoidEnd - realmoidStart);

            getRequest = new GetRequest()
            {
                Address   = location,
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "aos.bmwgroup.com",
                KeepAlive = true,
                Proxy     = proxy,
            };
            getRequest.Run(ref cookies);

            // Auth request
            var postRequest = new PostRequest()
            {
                Data        = $"target=HTTPS%3A%2F%2Fetk-b2i.bmwgroup.com%2F%3Fportal%3DOSMC%26lang%3Dru_RU&smauthreason=0&smagentname={smagentname}&smtryno=&USER={WebUtility.UrlEncode(user)}&PASSWORD={WebUtility.UrlEncode(password)}",
                Address     = location,
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "aos.bmwgroup.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = location,
                Proxy       = proxy,
                KeepAlive   = true
            };

            postRequest.Run(ref cookies);

            getRequest = new GetRequest()
            {
                Address           = $"https://etk-b2i.bmwgroup.com/etk-rest/api/version?_dc={DateTime.Now.ToUnixTime()}333", // Added milliseconds at the end
                Accept            = "*/*",
                Host              = "etk-b2i.bmwgroup.com",
                AllowAutoRedirect = false,
                KeepAlive         = true,
                Proxy             = proxy,
                Referer           = "https://etk-b2i.bmwgroup.com/?portal=OSMC&lang=ru_RU"
            };
            getRequest.Run(ref cookies);

            // Lets check our state
            getRequest = new GetRequest()
            {
                Address   = "https://etk-b2i.bmwgroup.com/?portal=OSMC&lang=ru_RU",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "etk-b2i.bmwgroup.com",
                KeepAlive = true,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            var validIndex = getRequest.Response.IndexOf("<title>ETK</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}");
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        static void Main(string[] args)
        {
            // Each hyundai 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://service.hyundai-motor.com/euro5/login.tiles",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "service.hyundai-motor.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // this is a kia feature to send login only in upcase
            //login and password we need to encode to base64
            var userBase64 = user.ToUpper().ToBase64();
            var passBase64 = password.ToBase64();
            var data       = "{\"userid\":\"" + userBase64 + "\",\"passwd\":\"" + passBase64 + "\",\"loginType\":\"RVVSTzU=\"}";

            // Auth request to kia portal
            var postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"https://service.hyundai-motor.com/common/chinalogin.action?",
                Accept      = "application/json, text/javascript, */*; q=0.01",
                Host        = "service.hyundai-motor.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "https://service.hyundai-motor.com/euro5/login.tiles",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

            if (postRequest.Response.Contains("result_code\":\"99"))
            {
                // Need to change password
                Config.Instance.AddLogInfo($"Auth isn't good");
                return;
            }

            getRequest = new GetRequest()
            {
                Address   = "http://service.hyundai-motor.com/manualV2/euro5/cnts/view/PARTS?euro5=1",
                Accept    = "application/json, text/javascript, */*; q=0.01",
                Host      = "service.hyundai-motor.com",
                KeepAlive = true,
                Referer   = "https://service.hyundai-motor.com/euro5/index.tiles",
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            #region sad part of finding data for post request

            var group_s = getRequest.Response.IndexOf("\"group\"") + 9;
            var group_e = getRequest.Response.IndexOf("\"", group_s);
            var group   = getRequest.Response.Substring(group_s, group_e - group_s);

            var id_s = getRequest.Response.IndexOf("\"wpcId\"") + 9;
            var id_e = getRequest.Response.IndexOf("\"", id_s);
            var id   = getRequest.Response.Substring(id_s, id_e - id_s);

            var key_s = getRequest.Response.IndexOf("\"wpcKey\"") + 10;
            var key_e = getRequest.Response.IndexOf("\"", key_s);
            var key   = getRequest.Response.Substring(key_s, key_e - key_s);

            var natcd_s = getRequest.Response.IndexOf("\"natCd\"") + 9;
            var natcd_e = getRequest.Response.IndexOf("\"", natcd_s);
            var natcd   = getRequest.Response.Substring(natcd_s, natcd_e - natcd_s);

            var uid_s  = getRequest.Response.IndexOf("\"userId\"") + 10;
            var uid_e  = getRequest.Response.IndexOf("\"", uid_s + 1);
            var userId = getRequest.Response.Substring(uid_s, uid_e - uid_s);

            var reg_s = getRequest.Response.IndexOf("\"reg\"") + 7;
            var reg_e = getRequest.Response.IndexOf("\"", reg_s + 1);
            var reg   = getRequest.Response.Substring(reg_s, reg_e - reg_s);

            #endregion

            data = $"cmd=Login&group={group}&id={id}&key={key}&natCd={natcd}&userid={userId}&reg={reg}";

            // Auth request to mobis portal
            postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"https://wpc.mobis.co.kr/SsoLogin",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "wpc.mobis.co.kr",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "https://service.hyundai-motor.com/euro5/index.tiles",
                KeepAlive   = true,
                TimeOut     = 60000,
                Proxy       = proxy
            };
            postRequest.Run(ref cookies);

            // we need cookies only from mobis.co
            var catalogCookies = cookies.GetCookieCollection().CatalogCookies("mobis.co");

            // let check our auth
            getRequest = new GetRequest()
            {
                Address   = "http://wpc.mobis.co.kr/Index/Index.jsp",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "wpc.mobis.co.kr",
                KeepAlive = true,
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            var validIndex = getRequest.Response.IndexOf("<title>TEPS - WPC</title>");
            if (validIndex >= 0)
            {
                Config.Instance.AddLogInfo($"Auth result: successful");
            }
            else
            {
                Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong");
                return;
            }

            // writing cookies in log
            foreach (var cookie in catalogCookies)
            {
                Config.Instance.AddLogInfo($"cookie: {cookie}");
            }
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        static void Main(string[] args)
        {
            // Each honda account has four parameters : Country, Business Unit, User, Password
            var country      = "country";
            var businessUnit = "businessUnit";
            var user         = "******";
            var password     = "******";

            // you may know the type of your honda account. for example for my accounts: if (country == 290) then isCorporative = true, if (country == 800) isCorporative = false
            bool isCorporative = true;

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

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

            // Creating a first get-request, saving cookies
            var getRequest = new GetRequest()
            {
                Address   = "https://www.ecom.honda-eu.com/logon/r_portal.html",
                Accept    = "text/html, application/xhtml+xml, */*",
                Host      = "www.ecom.honda-eu.com",
                KeepAlive = true,
                Proxy     = proxy,
                TimeOut   = 60000
            };

            getRequest.Run(ref cookies);

            // using in authorization
            var username = $"{country}-{businessUnit}-{user}";

            PostRequest postRequest;

            // we need to create an additional post-request for noncorporative account
            if (!isCorporative)
            {
                postRequest = new PostRequest()
                {
                    Data        = $"URL=&Username={username}&password={password}&requestedURL=%2Flogon%2Fr_portal.html&login-form-type=pwd&txtCountry={country}&txtDealer={businessUnit}&txtUser={user}&txtPassword={password}",
                    Address     = $"https://www.ecom.honda-eu.com/indep/independents/logon.jsp",
                    Accept      = "text/html, application/xhtml+xml, */*",
                    Host        = "www.ecom.honda-eu.com",
                    ContentType = "application/x-www-form-urlencoded",
                    Referer     = "https://www.ecom.honda-eu.com/logon/r_portal.html",
                    KeepAlive   = true,
                    Proxy       = proxy,
                    TimeOut     = 60000 // sometimes the portal slows down
                };
                postRequest.Run(ref cookies);
            }

            // different request Data for account type
            var data = isCorporative
                ? $"URL=&Username={username}&password={password}&requestedURL=%2Flogon%2Fr_portal.html&login-form-type=pwd&txtCountry={country}&txtDealer={businessUnit}&txtUser={user}&txtPassword={password}"
                : $"URL=&Username={username}&password={password}&requestedURL=%2Fpanex%2F&login-form-type=pwd";

            // different Referrer for account type
            var referer = isCorporative
                ? "https://www.ecom.honda-eu.com/logon/r_portal.html"
                : "https://www.ecom.honda-eu.com/indep/independents/logon.jsp";

            // creating authorization request
            postRequest = new PostRequest()
            {
                Data        = data,
                Address     = $"https://www.ecom.honda-eu.com/pkmslogin.form",
                Accept      = "text/html, application/xhtml+xml, */*",
                Host        = "www.ecom.honda-eu.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = referer,
                KeepAlive   = true,
                Proxy       = proxy,
                TimeOut     = 60000 // sometimes the portal slows down
            };
            postRequest.Run(ref cookies);

            // writing auth response in log
            Config.Instance.AddLogInfo($"honda auth answer: {postRequest.Response}");

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

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

            var result = "unknown";

            if (postRequest.Response.Contains("Authentication failed"))
            {
                result = "Authentication failed";
            }
            else if (postRequest.Response.Contains("Honda Login successful"))
            {
                result = "Authentication successful";
            }

            // writing Authentication result status in log
            Config.Instance.AddLogInfo($"Auth result: {result}");
        }
コード例 #9
0
ファイル: Program.cs プロジェクト: battyone/Authorizations
        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://iepc.geely.com/epc/login-input.jspx",
                Accept    = "text/html, application/xhtml+xml, image/jxr, */*",
                Host      = "iepc.geely.com",
                KeepAlive = true,
                Proxy     = proxy
            };

            getRequest.Run(ref cookies);

            // here we get captcha
            getRequest = new GetRequest()
            {
                Address   = "https://iepc.geely.com/epc/getRandomValidateCode.jspx",
                Accept    = "image/png, image/svg+xml, image/jxr, image/*;q=0.8, */*;q=0.5",
                Host      = "iepc.geely.com",
                KeepAlive = true,
                Referer   = "https://iepc.geely.com/epc/randomValidateCode.jspx",
                Proxy     = proxy
            };
            getRequest.Run(ref cookies);

            // coords of our mouse click on the auth button
            Random random = new Random();
            var    x      = random.Next(50);
            var    y      = random.Next(10);

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

            // auth request
            var postRequest = new PostRequest()
            {
                Data        = $"serialNumber=undefined&username={user}&validate_code={captchaText}&password={password}&.x={x}&.y={y}",
                Address     = $"https://iepc.geely.com/epc/Login.jspx",
                Accept      = "text/html, application/xhtml+xml, image/jxr, */*",
                Host        = "iepc.geely.com",
                ContentType = "application/x-www-form-urlencoded",
                Referer     = "https://iepc.geely.com/epc/login-input.jspx",
                KeepAlive   = true,
                Proxy       = proxy
            };

            postRequest.Run(ref cookies);

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

            // writing cookies in log
            foreach (var cookie in catalogCookies)
            {
                Config.Instance.AddLogInfo($"cookie: {cookie}");
            }
        }
コード例 #10
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;
            }
        }
コード例 #11
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}");
            }
        }
コード例 #12
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");
        }