static void Main(string[] args) { // Each ngs 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"); // This portal uses basic authorization: // We need to create auth string var authString = $"{user}:{password}".ToBase64(); var getRequest = new GetRequest() { Address = "https://ngs.ru/", Accept = "text/html, application/xhtml+xml, image/jxr, */*", Host = "ngs.ru", KeepAlive = true, Proxy = proxy }; getRequest.AddHeader("Authorization", $"Basic {authString}"); getRequest.Run(ref cookies); // Auth request doesn't need, only adding an auth header var postRequest = new PostRequest() { Data = "", Address = $"https://newsapi.ngs.ru/v1/public/account/?regionId=54", Accept = "vnd.news.v1.jtnews+json", Host = "newsapi.ngs.ru", Referer = "https://ngs.ru/", KeepAlive = true, Proxy = proxy }; postRequest.AddHeader("Origin", "https://ngs.ru"); postRequest.AddHeader("Authorization", $"Basic {authString}"); postRequest.Run(ref cookies); var validIndex = getRequest.Response.Contains("userId\":"); if (validIndex) { Config.Instance.AddLogInfo($"Auth result: successful"); } else { Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong"); } }
static void Main(string[] args) { // Each invest-idei.ru 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://invest-idei.ru/", Accept = "text/html, application/xhtml+xml, */*", Host = "invest-idei.ru", Proxy = proxy, KeepAlive = true }; getRequest.Run(ref cookies); try { var postRequest = new PostRequest() { Data = $"{{\"email\":\"{user}\",\"password\":\"{password}\"}}", Address = $"https://invest-idei.ru/auth/login", Accept = "application/json, text/plain, */*", ContentType = "application/json;charset=UTF-8", Host = "invest-idei.ru", Referer = "https://invest-idei.ru/auth/login", KeepAlive = true, Proxy = proxy }; postRequest.AddHeader("X-Requested-With", "XMLHttpRequest"); postRequest.AddHeader("Sec-Fetch-Dest", "empty"); postRequest.AddHeader("Origin", "https://invest-idei.ru"); postRequest.AddHeader("Sec-Fetch-Mode", "cors"); postRequest.AddHeader("Sec-Fetch-Site", "same-origin"); postRequest.Run(ref cookies); if (postRequest.Response.Contains("{\"result\":\"ok\"}")) { Config.Instance.AddLogInfo($"Auth result: ok"); } } catch (Exception ex) { Config.Instance.AddLogInfo($"Auth result: bad, {ex.Message}"); } }
public static void Main(string[] args) { var settings = new HttpClientSettings { Authenticator = new BasicAuthenticator("guest", "guest") }; const string root = "http://localhost:55672/api/"; settings.Configure<JsonDotNetSerializer>(s => s.ConfigureSettings(c => { c.ContractResolver = new RabbitContractResolver(); })); var client = HttpClient.Create(root, settings); var options = new { vhost = "integration", name = "ErrorQueue", count = "1", requeue = "true", encoding = "auto", truncate = "50000" }; var resource = client.BuildRelativeResource("queues/:vhost/:queue/get", new { vhost = "integration", queue = "ErrorQueue" }); var request = new PostRequest( resource, new ObjectRequestBody(options)); request.AddHeader("Accept", string.Empty); var messages = client.Run(request) .OnOk() .As<List<Message>>(); Console.WriteLine(messages.Count); Console.ReadLine(); }
public static string GetToken(string code, string state) { PostRequest req = new PostRequest( "https://api.twitch.tv/kraken/oauth2/token"); UrlParams param = new UrlParams(); param.Add("client_id", Config.TwitchOAuth.ClientId); param.Add("client_secret", Config.TwitchOAuth.Secret); param.Add("code", code); param.Add("grant_type", "authorization_code"); param.Add("redirect_uri", Config.OAuthRedirect); param.Add("state", state); req.AddHeader(HttpRequestHeader.ContentType, "application/x-www-form-urlencoded"); req.BodyString = param.ToPostString(); JObject resp = req.GetResponseJson(); return((string)resp["access_token"]); }
static void Main(string[] args) { // Each roblox 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://www.roblox.com/", Accept = "text/html, application/xhtml+xml, image/jxr, */*", Host = "www.roblox.com", KeepAlive = true, Proxy = proxy }; getRequest.Run(ref cookies); var tokenStart = getRequest.Response.IndexOf("setToken") + 10; var tokenEnd = getRequest.Response.IndexOf("'", tokenStart); var token = getRequest.Response.Substring(tokenStart, tokenEnd - tokenStart); getRequest = new GetRequest() { Address = "https://www.roblox.com/login", Accept = "text/html, application/xhtml+xml, image/jxr, */*", Host = "www.roblox.com", KeepAlive = true, Referer = "https://www.roblox.com/", Proxy = proxy }; getRequest.Run(ref cookies); // Auth request var data = $"{{\"cvalue\":\"{WebUtility.UrlEncode(user)}\",\"ctype\":\"Username\",\"password\":\"{WebUtility.UrlEncode(password)}\"}}"; var postRequest = new PostRequest() { Data = data, Address = $"https://auth.roblox.com/v2/login", Accept = "application/json, text/plain, */*", Host = "auth.roblox.com", ContentType = "application/json;charset=utf-8", Referer = "https://www.roblox.com/login", KeepAlive = true, Proxy = proxy }; postRequest.AddHeader("X-CSRF-TOKEN", token); postRequest.AddHeader("Origin", "https://www.roblox.com"); postRequest.Run(ref cookies); // Use Json parser. I dont want to use other libraries to make my code more difficult. var idStart = postRequest.Response.IndexOf("id") + 4; var idEnd = postRequest.Response.IndexOf(",", idStart); var id = postRequest.Response.Substring(idStart, idEnd - idStart); // This request isn't needed //getRequest = new GetRequest() //{ // Address = "https://web.roblox.com/home?nl=true", // Accept = "text/html, application/xhtml+xml, image/jxr, */*", // Host = "www.roblox.com", // KeepAlive = true, // Referer = "https://www.roblox.com/login", // Proxy = proxy //}; //getRequest.Run(ref cookies); getRequest = new GetRequest() { Address = $"https://economy.roblox.com/v1/users/{id}/currency", Accept = "application/json, text/plain, */*", Host = "economy.roblox.com", KeepAlive = true, Referer = "https://web.roblox.com/home?nl=true", Proxy = proxy }; getRequest.Run(ref cookies); // Write to log the response of robux count request Config.Instance.AddLogInfo(getRequest.Response); }
static void Main(string[] args) { // Each blablacar 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"); ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; var getRequest = new GetRequest() { Address = "https://www.blablacar.ru/", Accept = "text/html, application/xhtml+xml, image/jxr, */*", Host = "www.blablacar.ru", KeepAlive = true, UserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko", Proxy = proxy }; getRequest.Run(ref cookies); // We should to find visitor value var visitorStart = getRequest.Response.IndexOf("visitorId") + 12; var visitorEnd = getRequest.Response.IndexOf("\"", visitorStart); var visitor = getRequest.Response.Substring(visitorStart, visitorEnd - visitorStart); // Random value var xCorrelationId = "b4a8fe14-7a1c-4de6-8c13-9edbb6f7c1a5"; // Auth request var data = $"{{\"login\":\"{user}\",\"password\":\"{password}\",\"rememberMe\":true,\"grant_type\":\"password\"}}"; var postRequest = new PostRequest() { Data = data, Address = $"https://auth.blablacar.ru/secure-token", Accept = "application/json", Host = "auth.blablacar.ru", ContentType = "application/json", Referer = "https://www.blablacar.ru/login/email", KeepAlive = true, Proxy = proxy }; postRequest.AddHeader("x-client", "SPA|1.0.0"); postRequest.AddHeader("x-correlation-id", xCorrelationId); postRequest.AddHeader("x-currency", "RUB"); postRequest.AddHeader("x-forwarded-proto", "https"); postRequest.AddHeader("x-locale", "ru_RU"); postRequest.AddHeader("x-visitor-id", visitor); postRequest.AddHeader("Origin", "https://www.blablacar.ru"); postRequest.Run(ref cookies); // Finding this cookie value from all the headers var bearerCookieValue = string.Empty; var headers = postRequest.ResponseHeaders; for (int i = 0; i < headers.Count; ++i) { string header = headers.GetKey(i); if (header == "Set-Cookie") { var headerValue = headers.GetValues(i)[0]; headerValue = WebUtility.UrlDecode(headerValue); var accessTokenStart = postRequest.Response.IndexOf("access_token") + 15; var accessTokenEnd = postRequest.Response.IndexOf("\"", accessTokenStart); bearerCookieValue = postRequest.Response.Substring(accessTokenStart, accessTokenEnd - accessTokenStart); } } // For example we want to know all the trips from this account getRequest = new GetRequest() { Address = "https://edge.blablacar.ru/bookings-and-tripoffers?active=false", Accept = "application/json", Host = "edge.blablacar.ru", KeepAlive = true, ContentType = "application/json", Referer = "https://www.blablacar.ru/rides/history", Proxy = proxy }; getRequest.AddHeader("x-blablacar-accept-endpoint-version", "2"); getRequest.AddHeader("x-client", "SPA|1.0.0"); getRequest.AddHeader("x-correlation-id", xCorrelationId); getRequest.AddHeader("x-currency", "RUB"); getRequest.AddHeader("x-forwarded-proto", "https"); getRequest.AddHeader("x-locale", "ru_RU"); getRequest.AddHeader("x-visitor-id", visitor); getRequest.AddHeader("authorization", $"Bearer {bearerCookieValue}"); getRequest.AddHeader("Origin", "https://www.blablacar.ru"); getRequest.Run(ref cookies); // Write to log the json response with all the account trips Config.Instance.AddLogInfo(getRequest.Response); }
static void Main(string[] args) { // Each dns account has two parameters: User, Password var user = "******"; // !!! rewrite value from your account !!! Example: 7913xxxxxxx 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://www.dns-shop.ru/", Accept = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", Host = "www.dns-shop.ru", KeepAlive = true, Proxy = proxy }; getRequest.Run(ref cookies); var tokenStart = getRequest.Response.IndexOf("csrf-token") + 21; var tokenEnd = getRequest.Response.IndexOf("\"", tokenStart); var token = getRequest.Response.Substring(tokenStart, tokenEnd - tokenStart); // This parameter differs in different browsers, but i didn't see the problem with it var key = "------WebKitFormBoundaryazod1ayqWxHQOUrv"; // Auth request var postRequest = new PostRequest() { Data = $"{key}\r\n" + "Content-Disposition: form-data; name=\"LoginPasswordAuthorizationLoadForm[login]\"\r\n" + "\r\n" + $"{user}\r\n" + $"{key}\r\n" + "Content-Disposition: form-data; name=\"LoginPasswordAuthorizationLoadForm[password]\"\r\n" + "\r\n" + $"{password}\r\n" + $"{key}\r\n" + "Content-Disposition: form-data; name=\"LoginPasswordAuthorizationLoadForm[token]\"\r\n" + "\r\n" + "\r\n" + $"{key}\r\n", Address = $"https://www.dns-shop.ru/auth/auth/login-password-authorization/", Accept = "*/*", ContentType = $"multipart/form-data; boundary={key}", Host = "www.dns-shop.ru", Referer = "https://www.dns-shop.ru/no-referrer", KeepAlive = true, Proxy = proxy }; postRequest.AddHeader("X-Requested-With", "XMLHttpRequest"); postRequest.AddHeader("X-CSRF-Token", token); postRequest.AddHeader("Origin", "https://www.dns-shop.ru"); postRequest.AddHeader("Sec-Fetch-Dest", "empty"); postRequest.AddHeader("Sec-Fetch-Mode", "cors"); postRequest.AddHeader("Sec-Fetch-Site", "same-origin"); postRequest.Run(ref cookies); var validIndex = postRequest.Response.Contains("\"result\":true"); if (validIndex) { Config.Instance.AddLogInfo($"Auth result: successful"); } else { Config.Instance.AddLogInfo($"Auth result: unknown, something was wrong"); } }