Guest User

Untitled

a guest
Jun 20th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.57 KB | None | 0 0
  1. <?php //parse out server, port, channel from files w/ string "class pbot"
  2.  
  3. if ($handle = opendir('.'))
  4. {
  5. echo "[+] --------------------------- [+]\n";
  6.  
  7. while(false !== ($file = readdir($handle)))
  8. {
  9. if($file != "." && $file != "..") { findBOT($file); }
  10. }
  11.  
  12. closedir($handle);
  13. }
  14.  
  15. function findBOT($rfi)
  16. {
  17. $bot_str = "class pbot";
  18.  
  19. if($handle = fopen($rfi, "r"))
  20. {
  21. $buffer = fgets($handle, 4096);
  22.  
  23. do
  24. {
  25. if(false !== stripos($buffer, $bot_str))
  26. {
  27. parse_data($rfi);
  28. //echo "Bot => $rfi\n";
  29. return;
  30. }
  31. }
  32. while($buffer = fgets($handle, 4096));
  33.  
  34. fclose($handle);
  35. }
  36. }
  37.  
  38.  
  39.  
  40.  
  41. function parse_data($filename)
  42. {
  43.  
  44.  
  45. //The file you're trying to parse
  46. $filedir = $filename;
  47.  
  48. //get the contents of the file for later parsing
  49. $filecontents = file_get_contents($filedir);
  50.  
  51. //find the string 'class pBot' in the file.
  52. $isbot = strstr($filecontents, 'class pBot');
  53.  
  54.  
  55. //if the string exists, continue, otherwise tell us it's not found
  56. if($isbot === FALSE)
  57. {
  58. echo "\n not found \n";
  59.  
  60. }
  61. else
  62. {
  63.  
  64. echo $filename . "\n";
  65.  
  66. //vars for data
  67. $bad_chars = array('"', ',', '>', '\n', '=', '\r');
  68. $server = '';
  69. $port = '';
  70. $channel = '';
  71. $key = '';
  72. $password = '';
  73. $end_of_server = '';
  74.  
  75. /*************************
  76. *****Find the Server*****
  77. *************************/
  78.  
  79. //get the position of 'server' in the file
  80. $pos_server = stripos($filecontents, 'server"=>');
  81. //echo "Position of 'server' in string: ". $pos_server . "\n";
  82.  
  83. //pull the ip of the server
  84. $tmpserver = substr($filecontents, $pos_server + 10, 100);
  85. $server = substr($tmpserver, 0, stripos($tmpserver, '"'));
  86.  
  87. //clean all non-ip data
  88. $server = str_replace($bad_chars, '', $server);
  89. echo "the ip addy (or hostname: " . $server . "\n";
  90.  
  91.  
  92. /*************************
  93. *****Find the Port*******
  94. *************************/
  95.  
  96. //get the position of 'port' in the file
  97. $pos_port = stripos($filecontents, 'port"=>');
  98. //echo "Position of 'port' in string: ". $pos_port . "\n";
  99.  
  100. //pull the port number
  101. $tmpport = substr($filecontents, $pos_port + 4, 100);
  102. $port = substr($tmpport, 0, stripos($tmpport, ','));
  103.  
  104. //clean up all non-port data
  105. $port = str_replace($bad_chars, '', $port);
  106. echo "the server's port is: " . $port . "\n";
  107.  
  108. /*************************
  109. *****Find the key********
  110. *************************/
  111.  
  112. //get the position of 'key' in the file
  113. $pos_key = stripos($filecontents, 'key"=>');
  114. //echo "\n Position of 'key' in string: ". $pos_key . "\n";
  115.  
  116. //pull the portnum
  117. $tmpkey = substr($filecontents, $pos_key + 7, 100);
  118. $key = substr($tmpkey, 0, stripos($tmpkey, ','));
  119.  
  120. //clean up all non-port data
  121. $key = str_replace($bad_chars, '', $key);
  122. echo "the server's key is: " . $key . "\n";
  123.  
  124.  
  125.  
  126. /*************************
  127. *****Find the channel*****
  128. *************************/
  129.  
  130. //get the position of 'channel' in the file
  131. $pos_channel = stripos($filecontents, 'chan"=>');
  132. //echo "\n Position of 'channel' in string: ". $pos_channel . "\n";
  133.  
  134. //pull the portnum
  135. $tmpchannel = substr($filecontents, $pos_channel + 7, 100);
  136. $channel = substr($tmpchannel, 0, stripos($tmpchannel, ','));
  137.  
  138. //clean up all non-port data
  139. $channel = str_replace($bad_chars, '', $channel);
  140. echo "the server's channel is: " . $channel . "\n";
  141.  
  142.  
  143.  
  144. /*************************
  145. *****Find the Password****
  146. *************************/
  147.  
  148. //get the position of 'channel' in the file
  149. $pos_password = stripos($filecontents, 'password"=>"');
  150. //echo "\n Position of 'password' in string: ". $pos_password . "\n";
  151.  
  152. //pull the portnum
  153. $tmppassword = substr($filecontents, $pos_password + 12, 100);
  154. $password = substr($tmppassword, 0, stripos($tmppassword, ','));
  155.  
  156. //clean up all non-port data
  157. $password = str_replace($bad_chars, '', $password);
  158. echo "the server's password is: " . $password . "\n";
  159. //echo $password;
  160.  
  161.  
  162. //end of else bracket
  163. }
  164. //end of function bracket
  165. }
  166. ?>
Add Comment
Please, Sign In to add comment