Advertisement
Guest User

Untitled

a guest
Aug 27th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. csrfmiddlewaretoken "7e9001a3c0000f11099c11h119745e30"
  2. username "логин"
  3. password "пароль"
  4. next "/about/"
  5.  
  6. WebResponse Response;
  7. HttpWebRequest Request;
  8. Uri url = new Uri("http://00.00.00.000:0000/accounts/login/");
  9. CookieContainer cookieContainer = new CookieContainer();
  10.  
  11. Request = (HttpWebRequest)WebRequest.Create(url);
  12. Request.Method = "GET";
  13. Request.CookieContainer = cookieContainer;
  14. Response = Request.GetResponse(); //1 раз получил csrfmiddlewaretoken
  15.  
  16. string Parametros = "csrfmiddlewaretoken=" + cookieContainer.GetCookies(url)["csrftoken"].Value + "&username=логин&password=пароль&next=/about/";
  17.  
  18. Request = (HttpWebRequest)WebRequest.Create(url);
  19. //вот тут получается мне выдадут потом новый токен, а без использования этого я не знаю как сформировать новый запрос
  20. Request.Method = "POST";
  21. Request.ContentType = "application/x-www-form-urlencoded";
  22. Request.CookieContainer = cookieContainer;
  23. Request.Headers.Add("Cookie", Response.Headers.Get("Set-Cookie"));
  24. byte[] byteArray = Encoding.UTF8.GetBytes(Parametros);
  25. Request.ContentLength = byteArray.Length;
  26. Response = Request.GetResponse();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement