Advertisement
johnburn

gaybot ;D

Jul 1st, 2011
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.05 KB | None | 0 0
  1. <?php
  2. /**
  3.  * $ Bot TBDShoutBox v1
  4.  * $ by Ahlspiess
  5.  **/
  6. $bot = new TBDShout;
  7. $bot->username = 'ion';
  8. $bot->password = 'QWE!@#';
  9. $bot->host = 'http://w3.tbd.my';
  10. $bot->path = '/';
  11. $bot->Login();
  12. $bot->GetPostKey();
  13. $bot->FetchChat();
  14.  
  15. class TBDShout {
  16.  
  17.     var $username, $password, $post_key;
  18.     var $host, $path, $data;
  19.     var $url, $post, $postfields;
  20.     var $last_shout, $shouted;
  21.     var $chat = array();
  22.     var $nick = array();
  23.     var $login_post = 'username=%s&password=%s&remember=yes&submit=Login&action=do_login&url=%s';
  24.     var $add_shout = 'shout_data=%s&shout_key=%s';
  25.    
  26.     function Login() {
  27.         $this->url = $this->host.$this->path.'/member.php';
  28.         $this->post = 1;
  29.         $this->postfields = sprintf($this->login_post, $this->username, $this->password, $this->host.$this->path);
  30.         $this->Connect();
  31.         $this->post = 0;
  32.         $this->postfields = null;
  33.         if(!preg_match("/You\ have\ entered\ an\ invalid\ username/", $this->data))
  34.             {
  35.                 $this->e("[+] Login Successful!");
  36.             }
  37.             else
  38.             {
  39.                 $this->e("[-] Login Failed!");
  40.                 exit;
  41.             }
  42.     }
  43.        
  44.     function SendShout($text) {
  45.         $this->url = $this->host.$this->path.'/xmlhttp.php?action=add_shout';
  46.         $this->post = 1;
  47.         $this->postfields = sprintf($this->add_shout, urlencode($text), $this->post_key);
  48.         $this->Connect();
  49.         $this->post = 0;
  50.         $this->postfields = null;
  51.         sleep(1);
  52.     }
  53.    
  54.     function FetchChat() {
  55.         #print $shouted."\n";
  56.         #print $last_shout."\n";
  57.         $this->url = $this->host.$this->path.'/xmlhttp.php?action=show_shouts';
  58.         $this->Connect();
  59.         #print $this->data;
  60.         if(preg_match("/Content\-Length\:\ 0/", $this->data))
  61.             {
  62.                 $this->FetchChat();
  63.             }
  64.         preg_match_all("/\<a\ href\=\"member\.php\?action\=profile\&uid\=(.+?)\"\>(.+?)\<\/a\>\ \-\ (.+?)\ --\ (.+?)\<br\>/", $this->data, $var);
  65.         #print_r($var);
  66.         for($i=0;$i<count($var[1]);$i++)
  67.             {
  68.                 //$var[2][$i] = preg_replace("/\<span\ style\=\"(.+)\"\>\<strong\>\<img\ src\=\"(.+)\"\/\>(.+?)\<\/strong\>\<\/span\>/", "$3", $var[2][$i]);
  69.                 //$var[4][$i] = preg_replace("/\<img\ src\=\"images\/smilies\/(.+?)\"\ style\=\"vertical\-align\:\ middle\;\"\ border\=\"0\"\ alt\=\"(.+?)\"\ title\=\"(.+?)\"\ \/\>/", ":$2:", $var[4][$i]);
  70.                 $var[2][$i] = preg_replace("/\<span\ style\=\"(.+)\"\>\<strong\>\<img\ src\=\"(.+)\"\/\>(.+?)\<\/strong\>\<\/span\>/", "$3", $var[2][$i]);
  71.                 $var[2][$i] = preg_replace("/\<span\ style\=\"(.+)\"\>\<strong\>(.+?)\<\/strong\>\<\/span\>/", "$2", $var[2][$i]);
  72.                 $var[4][$i] = preg_replace("/\<img\ src\=\"images\/smilies\/(.+?)\"\ style\=\"vertical\-align\:\ middle\;\"\ border\=\"0\"\ alt\=\"(.+?)\"\ title\=\"(.+?)\"\ \/\>/", ":$2:", $var[4][$i]);
  73.             }
  74.         if(!isset($this->shouted))
  75.             {
  76.                 $this->e("[" . $var[3][9] . "] ". $var[2][9] . " - " . $this->unhtmlspecialchars($var[4][9]));
  77.                 $this->e("[" . $var[3][8] . "] ". $var[2][8] . " - " . $this->unhtmlspecialchars($var[4][8]));
  78.                 $this->e("[" . $var[3][7] . "] ". $var[2][7] . " - " . $this->unhtmlspecialchars($var[4][7]));
  79.                 $this->e("[" . $var[3][6] . "] ". $var[2][6] . " - " . $this->unhtmlspecialchars($var[4][6]));
  80.                 $this->e("[" . $var[3][5] . "] ". $var[2][5] . " - " . $this->unhtmlspecialchars($var[4][5]));
  81.                 $this->e("[" . $var[3][4] . "] ". $var[2][4] . " - " . $this->unhtmlspecialchars($var[4][4]));
  82.                 $this->e("[" . $var[3][3] . "] ". $var[2][3] . " - " . $this->unhtmlspecialchars($var[4][3]));
  83.                 $this->e("[" . $var[3][2] . "] ". $var[2][2] . " - " . $this->unhtmlspecialchars($var[4][2]));
  84.                 $this->e("[" . $var[3][1] . "] ". $var[2][1] . " - " . $this->unhtmlspecialchars($var[4][1]));
  85.                 $this->e("[" . $var[3][0] . "] ". $var[2][0] . " - " . $this->unhtmlspecialchars($var[4][0]));
  86.                 #for($ii=0;$ii<count($var[2]);$ii++)
  87.                 #   {
  88.                 #       if($this->msg[$ii] != $var[4][$ii])
  89.                 #           {
  90.                 #               $this->e($var[2][$ii] . " - " . $this->unhtmlspecialchars($var[4][$ii]));
  91.                 #           }
  92.                 #       $this->msg[$ii] = $var[4][$ii];
  93.                 #       $this->nick[$ii] = $var[2][$ii];
  94.                 #   }
  95.                 $this->shouted = 1;
  96.             }
  97.         if($this->last_shout != $var[4][0])
  98.             {
  99.                 if($var[2][0] != 'loljohnburn') //ini saja2 jgn tnya kenapa ;D
  100.                     {
  101.                     if(preg_match("/^\!help/", $var[4][0])) {
  102.                         $this->help();
  103.                         } else if(preg_match("/^\!md5 ([a-zA-Z0-9]{32})$/", $var[4][0],$match)) {
  104.                             $this->decrypt($match[1]);
  105.                         } else if(preg_match("/^\!revIP ((1?\d{1,2}|2([0-4]\d|5[0-5]))(\.(1?\d{1,2}|2([0-4]\d|5[0-5]))){3})$/", $var[4][0],$match)) {
  106.                             $this->reverseip($match[1]);
  107.                         } else if(preg_match("/^\!c (.+)$/", $var[4][0],$match)) {
  108.                             $this->chatting($match[1],$var[2][0]);
  109.                         }
  110.                         // ko cuba la tukar jd switch mcm serabai je if byk2 aku dh try mcm2 tp xjd mklmla noob ;D
  111.                         /*switch($var[4][0])
  112.                             {
  113.                                 case '!help':
  114.                                     $this->help();
  115.                                     break;
  116.                                 case '!md5':
  117.                                     $this->help();
  118.                                     break;
  119.                             }*/
  120.                     }
  121.                 $this->e("[" . $var[3][0] . "] ". $var[2][0]." - ".$this->unhtmlspecialchars($var[4][0]));
  122.                 $this->last_shout = $var[4][0];
  123.                 $this->shouted = 1;
  124.             }
  125.         sleep(2);
  126.         $this->FetchChat();
  127.     }
  128.    
  129.     function help() {
  130.         $this->SendShout('+----------------------------------------------------+');
  131.         $this->SendShout('[+] !c <blabla> - untk chat ngan bot');
  132.         $this->SendShout('[+] !revIP <ip> - reverse ip lookup');
  133.         $this->SendShout('[+] !md5 <hash> - utk decrypt md5');
  134.         $this->SendShout('[+] !help - utk print bende ni la');
  135.         $this->SendShout('+----------------------------------------------------+');
  136.     }
  137.    
  138.     function GetPostKey() {
  139.         preg_match_all("/var\ my_post_key\ =\ \"(.+?)\"\;/", $this->data, $post_key);
  140.         $this->post_key = $post_key[1][0];
  141.         $this->e("[+] Post Key :" .$this->post_key);
  142.     }
  143.    
  144.     function Connect() {
  145.         $ch = curl_init();
  146.         curl_setopt($ch, CURLOPT_HEADER, 1);
  147.         curl_setopt($ch, CURLOPT_TIMEOUT, 15);
  148.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  149.         curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  150.         curl_setopt($ch, CURLOPT_URL, $this->url);
  151.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6 ( .NET CLR 3.5.30729; .NET4.0E)");
  152.         curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');
  153.         curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
  154.         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  155.         if($this->post > 0) {
  156.             curl_setopt($ch, CURLOPT_POST, 1);
  157.             curl_setopt($ch, CURLOPT_POSTFIELDS, $this->postfields);
  158.         }
  159.         $data = curl_exec($ch);
  160.         if($data) {
  161.             $this->data = $data;
  162.         } else {
  163.             $this->data = 0;
  164.         }
  165.     }
  166.    
  167.     function unhtmlspecialchars($string) {
  168.         $string = str_replace('&amp;', '&', $string);
  169.         $string = str_replace('&#039;', '\'', $string);
  170.         $string = str_replace('&quot;', '\"', $string);
  171.         $string = str_replace('&lt;', '<', $string);
  172.         $string = str_replace('&gt;', '>', $string);
  173.         return $string;
  174.     }
  175.    
  176.     function e($r) {
  177.         print $r."\n";
  178.     }
  179.     function decrypt($md5){
  180.         $url="http://md5.my-addr.com/md5_decrypt-md5_cracker_online/md5_decoder_tool.php";
  181.         $md5=trim($md5);
  182.         if(strlen($md5)!=32){ die("Invalid MD5 Hash");}
  183.         $parameters="md5=$md5";
  184.         $res=$this->postDataViaCurl($url,$parameters);
  185.        
  186.         $returnArray=array();
  187.         $pattern='/Hashed string\<\/span\>: (.*)\<\/div\>/Uis';
  188.         preg_match_all($pattern, $res, $returnArray, PREG_SET_ORDER);
  189.         $nt=strip_tags(@$returnArray[0][1]);
  190.         $nt=trim($nt);
  191.         $result = (empty($nt)) ? '<not found>' : $nt;
  192.         $this->SendShout($md5.':'.$result);
  193.     }
  194.     function reverseip($ip){
  195.         $url="http://networktools.nl/reverseip/";
  196.         $ip=trim($ip);
  197.         $var = file_get_contents($url.$ip);
  198.         if(preg_match("/\<\/b\>:(.*)(\<\/pre\>)/Us", $var,$match)) {
  199.             $list = '';
  200.             $domains = preg_split( '/\r\n|\r|\n/', trim($match['1']) );
  201.             foreach($domains as $domain){
  202.                 $list .= $domain.', ';
  203.             }
  204.         }
  205.         $list = rtrim($list, ', ');
  206.         if (empty($list)) {
  207.             $this->SendShout('<Domain not found lol>');
  208.         } else {
  209.         $this->SendShout('Domain hosted on '.$ip.': '.$list);
  210.         }
  211.     }
  212.     function chatting($chat,$who){
  213.         $chat = escapeshellcmd($chat);
  214.         $response = exec("python chat.py $chat");
  215.         $this->SendShout("@".$who.": ".$response);
  216.     }
  217.     function postDataViaCurl($url,$parameters){
  218.         $ch = curl_init() or die("Sorry you need to have cURL extension Enabled");     
  219.         $header[0] = "Accept: text/xml,application/xml,application/xhtml+xml,";
  220.         $header[0] .= "text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5";
  221.         $header[] = "Cache-Control: max-age=0";
  222.         $header[] = "Connection: keep-alive";
  223.         $header[] = "Keep-Alive: 300";
  224.         $header[] = "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7";
  225.         $header[] = "Accept-Language: en-us,en;q=0.5";
  226.         curl_setopt($ch, CURLOPT_URL, $url);
  227.         curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  228.         curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12");
  229.         curl_setopt($ch, CURLOPT_REFERER, $url);
  230.         curl_setopt($ch, CURLOPT_POST, 1 );
  231.         curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters);
  232.         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  233.         $postResult = curl_exec($ch);
  234.         if (curl_errno($ch)) {
  235.             return false;
  236.         }
  237.         curl_close($ch);
  238.         return $postResult;
  239.     }
  240. }
  241.  
  242. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement