Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php //parse out server, port, channel from files w/ string "class pbot"
- if ($handle = opendir('.'))
- {
- echo "[+] --------------------------- [+]\n";
- while(false !== ($file = readdir($handle)))
- {
- if($file != "." && $file != "..") { findBOT($file); }
- }
- closedir($handle);
- }
- function findBOT($rfi)
- {
- $bot_str = "class pbot";
- if($handle = fopen($rfi, "r"))
- {
- $buffer = fgets($handle, 4096);
- do
- {
- if(false !== stripos($buffer, $bot_str))
- {
- parse_data($rfi);
- //echo "Bot => $rfi\n";
- return;
- }
- }
- while($buffer = fgets($handle, 4096));
- fclose($handle);
- }
- }
- function parse_data($filename)
- {
- //The file you're trying to parse
- $filedir = $filename;
- //get the contents of the file for later parsing
- $filecontents = file_get_contents($filedir);
- //find the string 'class pBot' in the file.
- $isbot = strstr($filecontents, 'class pBot');
- //if the string exists, continue, otherwise tell us it's not found
- if($isbot === FALSE)
- {
- echo "\n not found \n";
- }
- else
- {
- echo $filename . "\n";
- //vars for data
- $bad_chars = array('"', ',', '>', '\n', '=', '\r');
- $server = '';
- $port = '';
- $channel = '';
- $key = '';
- $password = '';
- $end_of_server = '';
- /*************************
- *****Find the Server*****
- *************************/
- //get the position of 'server' in the file
- $pos_server = stripos($filecontents, 'server"=>');
- //echo "Position of 'server' in string: ". $pos_server . "\n";
- //pull the ip of the server
- $tmpserver = substr($filecontents, $pos_server + 10, 100);
- $server = substr($tmpserver, 0, stripos($tmpserver, '"'));
- //clean all non-ip data
- $server = str_replace($bad_chars, '', $server);
- echo "the ip addy (or hostname: " . $server . "\n";
- /*************************
- *****Find the Port*******
- *************************/
- //get the position of 'port' in the file
- $pos_port = stripos($filecontents, 'port"=>');
- //echo "Position of 'port' in string: ". $pos_port . "\n";
- //pull the port number
- $tmpport = substr($filecontents, $pos_port + 4, 100);
- $port = substr($tmpport, 0, stripos($tmpport, ','));
- //clean up all non-port data
- $port = str_replace($bad_chars, '', $port);
- echo "the server's port is: " . $port . "\n";
- /*************************
- *****Find the key********
- *************************/
- //get the position of 'key' in the file
- $pos_key = stripos($filecontents, 'key"=>');
- //echo "\n Position of 'key' in string: ". $pos_key . "\n";
- //pull the portnum
- $tmpkey = substr($filecontents, $pos_key + 7, 100);
- $key = substr($tmpkey, 0, stripos($tmpkey, ','));
- //clean up all non-port data
- $key = str_replace($bad_chars, '', $key);
- echo "the server's key is: " . $key . "\n";
- /*************************
- *****Find the channel*****
- *************************/
- //get the position of 'channel' in the file
- $pos_channel = stripos($filecontents, 'chan"=>');
- //echo "\n Position of 'channel' in string: ". $pos_channel . "\n";
- //pull the portnum
- $tmpchannel = substr($filecontents, $pos_channel + 7, 100);
- $channel = substr($tmpchannel, 0, stripos($tmpchannel, ','));
- //clean up all non-port data
- $channel = str_replace($bad_chars, '', $channel);
- echo "the server's channel is: " . $channel . "\n";
- /*************************
- *****Find the Password****
- *************************/
- //get the position of 'channel' in the file
- $pos_password = stripos($filecontents, 'password"=>"');
- //echo "\n Position of 'password' in string: ". $pos_password . "\n";
- //pull the portnum
- $tmppassword = substr($filecontents, $pos_password + 12, 100);
- $password = substr($tmppassword, 0, stripos($tmppassword, ','));
- //clean up all non-port data
- $password = str_replace($bad_chars, '', $password);
- echo "the server's password is: " . $password . "\n";
- //echo $password;
- //end of else bracket
- }
- //end of function bracket
- }
- ?>
Add Comment
Please, Sign In to add comment