Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(PHP_SAPI != 'cli') {
- die("Run this script ONLY iN CLI MODE!");
- }
- //header('Content-Type: text/plain');
- /* _____ _____ _ _____ _____ _____ _____ _____ _____
- ___| | __ |_| _ |_ _|___ ___|_ _| __| _ | |
- |_ -| --| -| | __| | | |- _|___| | | | __| | | | |
- |___|_____|__|__|_|__| |_| |___| |_| |_____|__|__|_|_|_|
- |s C R i P T z - T E A M . i N F O|----------------------------
- [PHP] SERVER LOG SEARCHER WiTH iPs EXTRACTOR
- USAGE:
- php /path_to_php_file/index.php /path_to_logs/logs/file-custom_log what_to_search
- $file -> in what file to search for $searchfor
- $searchfor -> what to search in $file
- */
- $file = $argv[1];
- $searchfor = $argv[2]; //Example can be %00 => NULLBYTE ATTACK or ../
- $do_not_show_ip = array(
- ""
- ); //Define if you want to remove IPs from Extracted IPs
- $contents = file_get_contents($file);
- $pattern = preg_quote($searchfor, '/');
- $pattern = "/^.*$pattern.*\$/m";
- function pretty($arr)
- {
- $retStr = '';
- if (is_array($arr)) {
- foreach ($arr as $key => $val) {
- if (is_array($val)) {
- $retStr .= '
- ' . pretty($val) . '
- ';
- } else {
- $retStr .= '' . $val . '
- ';
- /*$retStr .= '
- ' . $key . ' => ' . pretty($val) . '
- ';
- }else{
- $retStr .= '
- ' . $key . ' => ' . $val . '
- ';
- */
- }
- }
- }
- $retStr .= '';
- return $retStr;
- }
- if (preg_match_all($pattern, $contents, $matches)) {
- echo " _____ _____ _ _____ _____ _____ _____ _____ _____
- ___| | __ |_| _ |_ _|___ ___|_ _| __| _ | |
- |_ -| --| -| | __| | | |- _|___| | | | __| | | | |
- |___|_____|__|__|_|__| |_| |___| |_| |_____|__|__|_|_|_|
- |s C R i P T z - T E A M . i N F O|
- [PHP] SERVER LOG SEARCHER WiTH iPs EXTRACTOR
- Search results => Results for \$searchfor
- Extracted IPs => Extracted IPs from Search results
- _______________________________________________________________
- /**************
- Search results:
- ***************/
- ";
- echo implode("\n", $matches[0]);
- echo "\n\n";
- if (preg_match_all("/(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/", implode("\n", $matches[0]), $matches)) {
- echo "
- /**************
- Extracted IPs:
- ***************/
- ";
- echo str_replace($do_not_show_ip, "", pretty(array_unique($matches[0])));
- }
- } else {
- echo "No matches found";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment