Advertisement
Guest User

Untitled

a guest
Mar 17th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. $username = "testuser";
  2. $password = "testpass";
  3.  
  4. $path = "c:\test\";
  5. $url="http://itw.me/login";
  6.  
  7. $field='_csrf';
  8. $html=file_get_contents( $url );
  9.  
  10. libxml_use_internal_errors( true );
  11. $dom=new DOMDocument;
  12. $dom->validateOnParse=false;
  13. $dom->recover=true;
  14. $dom->formatOutput=false;
  15. $dom->loadHTML( $html );
  16. libxml_clear_errors();
  17. $xpath=new DOMXPath( $dom );
  18. $col=$xpath->query('//input[@name="'.$field.'"]');
  19. foreach( $col as $node ) $csrftoken=$node->getAttribute('value');
  20. echo "-".$csrftoken."-";
  21.  
  22. $postinfo = "email=".$username."&password=".$password."&_csrf=".$csrftoken;
  23. $cookie_file_path = $path."/cookie.txt";
  24.  
  25. $ch = curl_init();
  26. curl_setopt($ch, CURLOPT_HEADER, false);
  27. curl_setopt($ch, CURLOPT_NOBODY, false);
  28. curl_setopt($ch, CURLOPT_URL, $url);
  29. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  30. curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file_path);
  31. curl_setopt($ch, CURLOPT_COOKIE, "cookiename=0");
  32. curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7.12) Gecko/20050915 Firefox/1.0.7");
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34. curl_setopt($ch, CURLOPT_REFERER, $_SERVER['REQUEST_URI']);
  35. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  36. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  37. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  38. curl_setopt($ch, CURLOPT_POST, 1);
  39. curl_setopt($ch, CURLOPT_POSTFIELDS, $postinfo);
  40. curl_exec($ch);
  41.  
  42. curl_setopt($ch, CURLOPT_URL, "http://itw.me");
  43. $html = curl_exec($ch);
  44. print($html);
  45. curl_close($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement