Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private async static void getsessionToken()
- {
- //logindaten
- string euserver = "virgon";
- string username = "bieg";
- string password = "bug";
- //"roh"-sessionstuff
- //was zum f** ist der pattern
- string pattern_authuser_and_token = @"r'.*action="+ @"https://sas.bpsecure.com/Sas/Authentication/Bigpoint\?authUser=(\d+)&token=([a-zA-Z0-9-_]*)'";
- string mainrequest = $"https://{euserver}.bsgo.com/";
- //webrequest
- HttpClient client = new HttpClient();
- HttpResponseMessage response = await client.GetAsync(mainrequest);
- HttpContent content = response.Content;
- string mycontent = await content.ReadAsStringAsync();
- foreach (string line in mycontent.Split('\n'))
- {
- if (line.Contains("token"))
- {
- Match matches = Regex.Match(pattern_authuser_and_token, line);
- Group authUser = matches.Groups[1];
- Group token = matches.Groups[2];
- using (StreamWriter sw = new StreamWriter(@"mytest.txt", true))
- sw.WriteLine(line);
- var headers = "Content-Type" + "application/x-www-form-urlencoded";
- string url = $"https://sas.bpsecure.com/Sas/Authentication/Bigpoint?authUser={authUser}&token={token}";
- List<KeyValuePair<string, string>> queries = new List<KeyValuePair<string, string>>()
- {
- new KeyValuePair<string, string>($"username{username}",$"password{password}")
- };
- HttpContent loginrequest = new FormUrlEncodedContent(queries);
- using(HttpClient client2 = new HttpClient())
- {
- using (HttpResponseMessage login = await client2.PostAsync(url, loginrequest))
- {
- using(HttpContent content2 = login.Content)
- {
- string mycontent2 = await content2.ReadAsStringAsync();
- using (StreamWriter sw = new StreamWriter(@"mytest.txt", true))
- sw.WriteLine(mycontent2);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement