Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. <?php
  2. /*
  3.  *    SMF 2.0 RC4 remote utils
  4.  *           -anthony
  5.  * currently can; login,
  6.  */
  7. class SMF {
  8.     protected $site, $user, $pass, $ch, $logged_in = false;
  9.    
  10.     public function __construct($_site, $_user, $_pass $cookies_file) {
  11.         $this->site = $_site;
  12.         $this->user = $_user;
  13.         $this->pass = $_pass;
  14.         $this->ch = curl_init();
  15.         curl_setopt($this->ch, CURLOPT_USERAGENT, "Opera/9.6 (Windows NT 5.1; U; pl)");
  16.         curl_setopt($this->ch, CURLOPT_TIMEOUT, '50');
  17.         curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
  18.         curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
  19.         curl_setopt($this->ch, CURLOPT_REFERER, $this->site);
  20.         curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookies_file);
  21.         curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookies_file);
  22.     }
  23.    
  24.     function SMF_login($user, $pass) {
  25.         curl_setopt($this->ch, CURLOPT_URL, $this->site . 'index.php?action=login');
  26.         curl_setopt($this->ch, CURLOPT_POST, 0);
  27.         $buffer = curl_exec($this->ch);
  28.         $sessionid =  substr($buffer, strpos($buffer, 'hashLoginPassword(this, ') + 25, 32);
  29.         if(!$sessionid) {
  30.             $this->SMF_login($user, $pass);
  31.         }
  32.         $sha_pass = sha1(sha1(strtolower($user) . $pass) . $sessionid);
  33.         $data = "user=$user&passwrd=&cookieneverexp=on&hash_passwrd=$sha_pass";
  34.         curl_setopt($this->ch, CURLOPT_URL, $this->site . 'index.php?action=login2');
  35.         curl_setopt($this->ch, CURLOPT_POST, 1);
  36.         curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data);
  37.         $buffer = curl_exec($this->ch);
  38.         $pos = strpos($buffer, "Hello $user");
  39.         if($pos === false) {
  40.             return 0;
  41.         } else {
  42.             $this->logged_in = true;
  43.             return 1;
  44.         }
  45.     }
  46. }
  47.  
  48. $test = new SMF('SMFSITEWITHTRAILINGSLASH', 'cookies.txt');
  49. if($test->SMF_login('user', 'pass')) {
  50.     echo 'logged in!';
  51. } else {
  52.     echo 'couldnt log in?';
  53. }
  54. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement