Advertisement
Guest User

Untitled

a guest
Jul 4th, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.47 KB | None | 0 0
  1. <?php
  2.  
  3. class Nulogy{
  4.  
  5. public $u;
  6. public $s;
  7. public $url;
  8. public $post;
  9. public $resposta;
  10. public $cookie;
  11. public $token;
  12. public function __construct(){
  13. $this->u = 'usuario-aqui';
  14. $this->s = 'senha-aqui';
  15. $this->cookie = dirname(__FILE__) . '/cookie/' .'NULOGY[COOKIE]' . rand(0, 999999) . '.txt';
  16.  
  17. }
  18.  
  19. public function fazerLogin(){
  20. $this->url = 'https://packmanager.nulogy.net/sign_in';
  21. $this->loginPlayLoad();
  22. var_dump($this->resposta);
  23. }
  24.  
  25. public function loginPlayLoad(){
  26. $this->getTokenLogin();
  27. if($this->token){
  28. $data['utf8'] = '✓';
  29. $data['authenticity_token'] = $this->token;
  30. $data['return'] = '';
  31. $data['uv_login'] = '';
  32. $data['user[login]'] = $this->u;
  33. $data['user[password']= $this->s;
  34. $data['commit'] = 'Sign in';
  35. $data['authenticity_token'] = $this->token;
  36. $data['authenticity_token'] =$this->token;
  37. }else{
  38. return false;
  39. }
  40. $this->post = http_build_query($data);
  41. return true;
  42. }
  43.  
  44. public function getTokenLogin(){
  45. $this->url = 'https://packmanager.nulogy.net/sign_in';
  46. $this->get();
  47. preg_match_all('/meta content="(.*?)" name="csrf-token"/', $this->resposta, $matches, PREG_SET_ORDER, 0);
  48. $token = $matches[0][1];
  49. if($token){
  50. return $this->token = $token;
  51. }else{
  52. return array('status' => false,'resposta' => 'Não foi possível encontrar CSRF-TOKEN' );
  53.  
  54. }
  55. }
  56.  
  57. public function post(){
  58. $ch = curl_init();
  59. curl_setopt($ch, CURLOPT_URL, $this->url);
  60. curl_setopt($ch, CURLOPT_POST, 1);
  61. curl_setopt($ch, CURLOPT_POSTFIELDS, $this->post);
  62. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0');
  63. curl_setopt($ch, CURLOPT_REFERER, "https://packmanager.nulogy.net/sign_in");
  64. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
  65. curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
  66. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  67. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  68. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  69. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  70. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  71. curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
  72. curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
  73. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded"));
  74. curl_setopt($ch, CURLOPT_ENCODING, '');
  75. $this->resposta = curl_exec($ch);
  76. }
  77.  
  78. public function get(){
  79. $ch = curl_init();
  80. curl_setopt($ch, CURLOPT_URL, $this->url);
  81. curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:50.0) Gecko/20100101 Firefox/50.0');
  82. curl_setopt($ch, CURLOPT_REFERER, "https://packmanager.nulogy.net/sign_in");
  83. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  84. curl_setopt($ch, CURLOPT_MAXREDIRS, 0);
  85. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
  86. curl_setopt($ch, CURLOPT_TIMEOUT, 30);
  87. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  88. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  89. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
  90. curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookie);
  91. curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookie);
  92. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/x-www-form-urlencoded"));
  93. curl_setopt($ch, CURLOPT_ENCODING, '');
  94. $this->resposta = curl_exec($ch);
  95. }
  96.  
  97.  
  98. }
  99. $x = new Nulogy();
  100. var_dump( $x->fazerLogin());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement