Advertisement
Metts

FACEBOOK Friend Request worm.

Mar 29th, 2012
2,846
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 7.43 KB | None | 0 0
  1. <?php
  2.     // CODED BY Metts  / metts.blog.hu / da.metts@hotmail.com
  3.     // FACEBOOK Friend Request worm.
  4.     // A Kódért felelősséget nem vállalok!
  5.     set_time_limit(60);
  6.     $time = round(microtime(), 3); 
  7.     function fb_login($login_email, $login_pass)
  8.     {
  9.         $ch = curl_init();
  10.         curl_setopt($ch, CURLOPT_URL, 'http://login.facebook.com/login.php?login_attempt=1');
  11.         curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84');
  12.         curl_setopt($ch, CURLOPT_POST, 1);
  13.         curl_setopt($ch, CURLOPT_HEADER, 0);
  14.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  15.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  16.         curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
  17.         curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
  18.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  19.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
  20.         curl_exec($ch);
  21.         $err = 0;
  22.         $err = curl_errno($ch);
  23.         if ($err != 0){
  24.             curl_close($ch);
  25.             echo 'LOGIN: error='.$err."\n";
  26.             return(false);
  27.         }
  28.         else
  29.         {
  30.             echo " LOGIN: SUCESS<br/>";
  31.             echo " GET: http://m.facebook.com/findfriends.php ";
  32.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  33.             curl_setopt($ch, CURLOPT_TIMEOUT, '3');
  34.             curl_setopt($ch, CURLOPT_COOKIEFILE, 'fb_cookies.txt');
  35.             curl_setopt($ch, CURLOPT_URL, 'http://m.facebook.com/findfriends.php');
  36.             $content = curl_exec($ch);
  37.             return $content;
  38.         }
  39.     }
  40.  
  41.     function invite_friend($login_email,$login_pass,$f_id,$token)
  42.     {
  43.         $ch = curl_init();
  44.         curl_setopt($ch, CURLOPT_URL, 'http://login.facebook.com/login.php?login_attempt=1');
  45.         curl_setopt($ch, CURLOPT_POSTFIELDS,'charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84&locale=en_US&email='.urlencode($login_email).'&pass='.urlencode($login_pass).'&pass_placeholder=&charset_test=%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84');
  46.         curl_setopt($ch, CURLOPT_POST, 1);
  47.         curl_setopt($ch, CURLOPT_HEADER, 0);
  48.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  49.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  50.         curl_setopt($ch, CURLOPT_COOKIEJAR, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
  51.         curl_setopt($ch, CURLOPT_COOKIEFILE, str_replace('\\','/',dirname(__FILE__)).'/fb_cookies.txt');
  52.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  53.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
  54.         curl_exec($ch);
  55.         $err = 0;
  56.         $err = curl_errno($ch);
  57.         if ($err != 0){
  58.             curl_close($ch);
  59.             echo 'LOGIN: error='.$err."\n";
  60.             return(false);
  61.         }
  62.         else
  63.         {
  64.             $infos = curl_getinfo($ch);
  65.             $_ID    = iconv('ISO-8859-1','UTF-8',urlencode($f_id));
  66.             $_PL    = iconv('ISO-8859-1','UTF-8',urlencode('/find-friends/index.php'));
  67.             $_TOKEN = iconv('ISO-8859-1','UTF-8',urlencode($token));
  68.             $_SURI  = iconv('ISO-8859-1','UTF-8',urlencode('/findfriends.php?fr_id='.$_ID));
  69.             $_REFID = iconv('ISO-8859-1','UTF-8',urlencode('43'));
  70.             $_HF    = iconv('ISO-8859-1','UTF-8',urlencode('friend_browser'));
  71.             echo "LOGIN: SUCESS<br/>
  72.             SEND REQUEST: <br/>
  73.             ID   : ".$_ID." <br/>
  74.             TOKEN: ".$_TOKEN."<br/>
  75.             SURI : ".$_SURI."<br/>
  76.             PL   : ".$_PL."<br/>
  77.             REFID: ".$_REFID."<br/>
  78.             HF   : ".$_HF."<br/>";
  79.             echo 'URL: http://m.facebook.com/a/mobile/friends/add_friend.php?id='.$_ID.'&hf='.$_HF.'&pl='.$_PL.'&suri='.$_SURI.'&gfid='.$_TOKEN.'&refid='.$_REFID.'<br/>';
  80.  
  81.             curl_setopt($ch, CURLOPT_URL,'http://m.facebook.com/a/mobile/friends/add_friend.php?id='.$_ID.'&hf='.$_HF.'&pl='.$_PL.'&suri='.$_SURI.'&gfid='.$_TOKEN.'&refid='.$_REFID.'');
  82.             curl_setopt($ch,CURLOPT_BINARYTRANSFER, true);
  83.             curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  84.                 'Host: m.facebook.com',
  85.                 'User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:9.0.1) Gecko/20100101 Firefox/9.0.1',
  86.                 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
  87.                 'Accept-Language: hu-hu,hu;q=0.8,en-us;q=0.5,en;q=0.3',
  88.                 'Accept-Charset: utf-8;q=0.7,*;q=0.7',
  89.                 'Connection: keep-alive',
  90.                 'Accept-Language: hu-hu,hu;q=0.8,en-us;q=0.5,en;q=0.3',
  91.                 'Referer: https://m.facebook.com/findfriends.php'
  92.             ));
  93.             curl_setopt($ch, CURLOPT_POST, 0);
  94.             curl_setopt($ch, CURLOPT_HEADER, 0);
  95.             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  96.             curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  97.             curl_setopt($ch, CURLOPT_COOKIEFILE, 'fb_cookies.txt');
  98.             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  99.             curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
  100.             $err = 0;
  101.             $err = curl_errno($ch);
  102.             if ($err != 0){
  103.                 curl_close($ch);
  104.                 echo 'LOGIN: error='.$err."\n";
  105.             }
  106.             else {
  107.                 $c = curl_exec($ch);
  108.                 $string = "You sent a friend request to ";
  109.                 if(stristr(strip_tags($c), $string) === FALSE)   {
  110.                     echo("<b>ERROR: Can't sent a friend request</b>");
  111.                     $fail--;
  112.                 }  
  113.                 else
  114.                     echo "<b>You sent a friend request to ".$_ID."</b>";
  115.  
  116.                 curl_close($ch);
  117.             }
  118.         }
  119.     }
  120.        
  121.     echo "<h1>Facebook friend request worm - Coded by Metts</h1><br/>";
  122.     $login_email = 'e1730121222@rppkn.com'; //EMAIL
  123.     $login_pass  = 'pw';    //PW
  124.  
  125.     $pattern = '{<div\s+class="pymkName"\s*>((?:(?:(?!<div[^>]*>|</div>).)++|<div[^>]*>(?1)</div>)*)</div>}si';
  126.     $pattern_to_href = '#<a\s*(?:href=[\'"]([^\'"]+)[\'"])?\s*(?:title=[\'"]([^\'"]+)[\'"])?.*?>((?:(?!</a>).)*)</a>#i';
  127.     $pattern_to_hidden_form = '{<div\s+class="pymkAddButton"\s*>((?:(?:(?!<div[^>]*>|</div>).)++|<div[^>]*>(?1)</div>)*)</div>}si';
  128.     $pattern_to_hidden_input = "/input type=\"hidden\" name=\"gfid\" value=\".*?\"/i";
  129.  
  130.     $data = fb_login($login_email,$login_pass);
  131.     $array = array();
  132.  
  133.     $matchcount = preg_match_all($pattern, $data, $matches);
  134.     $matchcount2 = preg_match_all($pattern_to_hidden_form, $data, $matches_2);
  135.     $fail       = $matchcount;
  136.     if ($matchcount > 0)
  137.     {
  138.         echo "<h3>Friends:</h3>";
  139.         echo("$matchcount matches found.<br/>");
  140.         for($i = 0; $i < $matchcount ; $i++)
  141.         {
  142.             echo("<br/><br/>Match #" . ($i + 1) . ":<br/>");
  143.             echo($matches[1][$i]);
  144.             preg_match_all("/<a.*?href\s*=\s*['\"](.*?)['\"]/", $matches[1][$i], $res[$i]);
  145.             echo " URL: ".$res[$i][1][0];
  146.             $id = preg_replace("/[^0-9]/", '',$res[$i][1][0]);
  147.             $id = substr($id, 0, (strlen($id)-2));
  148.             echo " ID : ".$id; 
  149.             if(strlen($id) == 0) {
  150.                 // http://m.facebook.com/xxx.yyyy?
  151.                 print "<b>ERROR: He heavent not id!</b>";
  152.                 $fail--;
  153.             }
  154.             else {
  155.                 preg_match_all($pattern_to_hidden_input,$matches_2[1][$i],$out);
  156.                 $gfid =str_replace("input type=\"hidden\" name=\"gfid\" value=\"", "", $out[0][0]);
  157.                 $gfid =trim($gfid,'"');
  158.                 $token[$i] = $gfid;
  159.                 echo " TOKEN: ". $token[$i]."<br/><br/>";
  160.                 //invite_friend($login_email,$login_pass,$id,$token[$i]);
  161.             }
  162.         }
  163.     }
  164.     else {
  165.         echo('No matches');
  166.         echo($data);
  167.  
  168.     }
  169.    
  170.     $time2 = round(microtime(), 3);
  171.     $generation = $time2 - $time;
  172.     print "<br/>
  173.     STAT: (".$matchcount."/".$fail.")<br/>
  174.     TIME : ".$generation."";
  175.     echo "<h1>WORM END</h1>";
  176.  
  177.     // 22:10 kor inditottama botot.
  178.     // 10/8 at jelöl be a bot
  179.     // 1 perc alatt végez
  180.     // (8 * 3600) * 24 nap végére: 691200
  181.    
  182. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement