Advertisement
Guest User

Untitled

a guest
Oct 25th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/usr/bin/env python
  2.  
  3. import requests
  4. import urllib
  5. from lxml import etree
  6.  
  7. session = requests.Session()
  8.  
  9. tokenRequest = session.get('http://localhost/Account/Login')
  10.  
  11. parser = etree.HTMLParser()
  12. tree = etree.fromstring(tokenRequest.text, parser)
  13. verificationToken = tree.xpath('//form//input[@name="__RequestVerificationToken"]/@value')[0]
  14.  
  15. sessionCookies = tokenRequest.cookies
  16.  
  17. payload = { 'Email' : 'somerandomemail@somedomain' , 'Password' : 'somerandompassword', '__RequestVerificationToken' : verificationToken}
  18.  
  19.  
  20. raw = urllib.urlencode(payload)
  21. headers = {'Content-Type': 'text/html; charset=utf-8','Origin':'http://localhost','Referer':'http://localhost/Account/Login'}
  22. plateRequest = session.post('http://localhost/Account/Login', data=raw, cookies=sessionCookies, headers=headers)
  23.  
  24. print plateRequest.text
  25.  
  26. #print sessionCookies
  27. #print raw
  28.  
  29. > <h1 class="text-danger">Error.</h1> <h2 class="text-danger">An error
  30. > occurred while processing your request.</h2> <h2
  31. > class="text-danger">Or maybe your session has ended, please <a
  32. > href="~/Account/Login">Login</a> again.</h2>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement