Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * SMF 2.0 RC4 remote utils
- * -anthony
- * currently can; login,
- */
- class SMF {
- protected $site, $user, $pass, $ch, $logged_in = false;
- public function __construct($_site, $_user, $_pass $cookies_file) {
- $this->site = $_site;
- $this->user = $_user;
- $this->pass = $_pass;
- $this->ch = curl_init();
- curl_setopt($this->ch, CURLOPT_USERAGENT, "Opera/9.6 (Windows NT 5.1; U; pl)");
- curl_setopt($this->ch, CURLOPT_TIMEOUT, '50');
- curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, 1);
- curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($this->ch, CURLOPT_REFERER, $this->site);
- curl_setopt($this->ch, CURLOPT_COOKIEJAR, $cookies_file);
- curl_setopt($this->ch, CURLOPT_COOKIEFILE, $cookies_file);
- }
- function SMF_login($user, $pass) {
- curl_setopt($this->ch, CURLOPT_URL, $this->site . 'index.php?action=login');
- curl_setopt($this->ch, CURLOPT_POST, 0);
- $buffer = curl_exec($this->ch);
- $sessionid = substr($buffer, strpos($buffer, 'hashLoginPassword(this, ') + 25, 32);
- if(!$sessionid) {
- $this->SMF_login($user, $pass);
- }
- $sha_pass = sha1(sha1(strtolower($user) . $pass) . $sessionid);
- $data = "user=$user&passwrd=&cookieneverexp=on&hash_passwrd=$sha_pass";
- curl_setopt($this->ch, CURLOPT_URL, $this->site . 'index.php?action=login2');
- curl_setopt($this->ch, CURLOPT_POST, 1);
- curl_setopt($this->ch,CURLOPT_POSTFIELDS, $data);
- $buffer = curl_exec($this->ch);
- $pos = strpos($buffer, "Hello $user");
- if($pos === false) {
- return 0;
- } else {
- $this->logged_in = true;
- return 1;
- }
- }
- }
- $test = new SMF('SMFSITEWITHTRAILINGSLASH', 'cookies.txt');
- if($test->SMF_login('user', 'pass')) {
- echo 'logged in!';
- } else {
- echo 'couldnt log in?';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement