Browse Source

first commit

root 3 years ago
commit
70c2809624
9 changed files with 16583 additions and 0 deletions
  1. BIN
      ai-bolit/AIBOLIT-BINMALWARE.db
  2. 14747 0
      ai-bolit/ai-bolit-hoster.php
  3. 813 0
      changelog.txt
  4. 79 0
      readme.txt
  5. 159 0
      tools/ai-bolit-bl.php
  6. 178 0
      tools/ai-bolit-wl.php
  7. 497 0
      tools/ai-design.html
  8. 31 0
      tools/handler.php
  9. 79 0
      tools/vps_docroot.php

BIN
ai-bolit/AIBOLIT-BINMALWARE.db


File diff suppressed because it is too large
+ 14747 - 0
ai-bolit/ai-bolit-hoster.php


File diff suppressed because it is too large
+ 813 - 0
changelog.txt


File diff suppressed because it is too large
+ 79 - 0
readme.txt


+ 159 - 0
tools/ai-bolit-bl.php

@@ -0,0 +1,159 @@
+<?php
+
+// Enable logging
+define('LOG', true);
+define('LOG_FILE', 'aibolit-bl-generator.log');
+
+date_default_timezone_set('Europe/Moscow');
+
+define('DB_FILE', 'AIBOLIT-BINMALWARE.db');
+
+define('MAX_SIZE_TO_SCAN', 600 * 1000);
+
+if ($argc != 2) {
+    die("Usage: php $argv[0] <root_folder>\n\n");
+}
+
+
+$db = load_db(DB_FILE);
+
+if (LOG) _log_("\nStart " . date("d/m/Y H:i:s", time()));
+
+scan_directory_recursively($argv[1]);
+
+save_db($db, DB_FILE);
+
+if (LOG) _log_("Finish " . date("d/m/Y H:i:s", time()), true);
+
+exit;
+
+
+
+function scan_directory_recursively($directory, $filter = FALSE)
+{
+    echo "Scan: " . $directory . "\n";
+
+    $handle = @opendir($directory);
+
+    if ($handle === false) return;
+
+    while (false !== ($file = readdir($handle)))
+    {
+        if ($file == '.' || $file == '..') continue;
+
+        $path = $directory . '/' . $file;
+
+        $type = filetype($path);
+
+        if ($type == 'dir') scan_directory_recursively($path);
+
+        if ($type == 'file') {
+            if (filesize($path) > MAX_SIZE_TO_SCAN) continue;
+
+            $hash = _hash_($path);
+
+            $ok = insert_into_db(pack("H*", $hash));
+
+            if (LOG) _log_( ($ok ? "new" : "dup") . " $hash|$path" );
+        }
+    }
+
+    closedir($handle);
+}
+
+
+function _hash_($file)
+{
+    $content = file_get_contents($file);
+    return sha1($content);
+}
+
+
+function insert_into_db($item)
+{
+    global $db;
+
+    $str =& $db[ord($item[0])];
+
+    $item_size = strlen($item);
+
+    if ( $item_size == 0 ) return false;
+
+    $first = 0;
+
+    $last = floor(strlen($str)/$item_size);
+
+    /* Если просматриваемый участок непустой, first < last */
+    while ($first < $last) {
+        $mid = $first + (($last - $first) >> 1);
+        $b = substr($str, $mid * $item_size, $item_size);
+        if (strcmp($item, $b) <= 0)
+            $last = $mid;
+        else
+            $first = $mid + 1;
+    }
+
+    $b = substr($str, $last * $item_size, $item_size);
+    if ($b == $item) {
+        /* Искомый элемент уже добавлен. */
+        return false;
+    } else {
+        /* Искомый элемент не найден.
+         * Вставляем со сдвигом в позицию - last.
+         */
+        $str = substr_replace($str, $item, $last * $item_size, 0);
+        return true;
+    }
+}
+
+
+function load_db($file)
+{
+    $db = array_fill(0, 256, '');
+
+    $fp = fopen($file, 'rb');
+
+    if (false === $fp) return $db;
+
+    $header = unpack('V256', fread($fp, 1024));
+
+    foreach ($header as $key => $size) {
+        if ($size > 0) $db[$key-1] = fread($fp, $size);
+    }
+
+    fclose($fp);
+
+    return $db;
+}
+
+
+function save_db($db, $file)
+{
+    $header = array();
+    foreach ($db as $key => $value) {
+        $header[$key] = pack('V', strlen($value));
+    }
+
+    $fp = fopen($file, 'wb') or die("Cannot create $file.");
+
+    fwrite($fp, implode($header));
+    foreach ($db as $s) {
+        fwrite($fp, $s);
+    }
+
+    fclose($fp);
+}
+
+
+function _log_($line, $flush = false)
+{
+    static $l_Buffer = '';
+
+    $l_Buffer .= $line . "\n";
+
+    if ($flush || strlen($l_Buffer) > 32000)
+    {
+        file_put_contents(LOG_FILE, $l_Buffer, FILE_APPEND);
+        $l_Buffer = '';
+    }
+}

+ 178 - 0
tools/ai-bolit-wl.php

@@ -0,0 +1,178 @@
+<?php
+
+// Enable logging
+define('LOG', true);
+define('LOG_FILE', 'aibolit-wl-generator.log');
+
+date_default_timezone_set('Europe/Moscow');
+
+define('DB_FILE', 'AIBOLIT-WHITELIST.db');
+
+define('MAX_SIZE_TO_SCAN', 600 * 1000);
+
+$extensions_list = array('php', 'php5', 'php7', 'phtml', 'htm', 'html', 'htaccess', 'cgi', 'js', 'css', 'pl', 'py', 'sh', 'shtml', 'txt', 'inc', 'tpl', 'dat');
+
+if ($argc != 2) {
+	die("Usage: php $argv[0] <root_folder>\n\n");
+}
+
+
+$db = load_db(DB_FILE);
+
+if (LOG) _log_("\nStart " . date("d/m/Y H:i:s", time()));
+
+scan_directory_recursively($argv[1]);
+
+save_db($db, DB_FILE);
+
+if (LOG) _log_("Finish " . date("d/m/Y H:i:s", time()), true);
+
+exit;
+
+
+
+function scan_directory_recursively($directory, $filter = FALSE)
+{
+	global $extensions_list;
+
+	echo "Scan: " . $directory . "\n";
+
+	$handle = @opendir($directory);
+	
+	if ($handle === false) return;
+	
+	while (false !== ($file = readdir($handle)))
+	{
+		if ($file == '.' || $file == '..') continue;
+
+		$path = $directory . '/' . $file;
+		
+		$type = filetype($path);
+		
+		if ($type == 'dir') scan_directory_recursively($path);
+
+		if ($type == 'file') {
+			$extension = pathinfo($path, PATHINFO_EXTENSION);
+
+			if (!in_array($extension, $extensions_list)) continue;
+
+			if (filesize($path) > MAX_SIZE_TO_SCAN) continue;
+
+			$hash = _hash_($path);
+			
+			$ok = insert_into_whitelist(pack("H*", $hash));
+			
+			if (LOG) _log_( ($ok ? "new" : "dup") . " $hash|$path" );
+		}
+	}
+
+	closedir($handle);
+}
+
+
+function _hash_($file)
+{
+	static $r;
+	
+	if (empty($r)) {
+		for ($i = 0; $i < 256; $i++) {
+			if ($i < 33 OR $i > 127 ) $r[chr($i)] = '';
+		}
+	}
+
+	$content = @php_strip_whitespace($file);
+
+	$content = strtr($content, $r);
+
+	return sha1($content);
+}
+
+
+function insert_into_whitelist($item)
+{
+	global $db;
+
+	$str =& $db[ord($item[0])];
+	
+	$item_size = strlen($item);
+	
+	if ( $item_size == 0 ) return false;
+	
+	$first = 0;
+
+	$last = floor(strlen($str)/$item_size);
+	
+	/* Если просматриваемый участок непустой, first < last */
+	while ($first < $last) {
+		$mid = $first + (($last - $first) >> 1);
+		$b = substr($str, $mid * $item_size, $item_size);
+		if (strcmp($item, $b) <= 0)
+			$last = $mid;
+		else
+			$first = $mid + 1;
+	}
+
+	$b = substr($str, $last * $item_size, $item_size);
+	if ($b == $item) {
+        /* Искомый элемент уже добавлен. */
+		return false;
+	} else {
+        /* Искомый элемент не найден.
+         * Вставляем со сдвигом в позицию - last.
+         */
+		$str = substr_replace($str, $item, $last * $item_size, 0);
+		return true;
+	}
+}
+
+
+function load_db($file)
+{
+	$db = array_fill(0, 256, '');
+
+	$fp = fopen($file, 'rb');
+	
+	if (false === $fp) return $db;
+
+	$header = unpack('V256', fread($fp, 1024));
+
+	foreach ($header as $key => $size) {
+		if ($size > 0) $db[$key-1] = fread($fp, $size);
+	}
+
+	fclose($fp);
+
+	return $db;
+}
+
+
+function save_db($db, $file)
+{
+	$header = array();
+	foreach ($db as $key => $value) {
+		$header[$key] = pack('V', strlen($value));
+	}
+	
+	$fp = fopen($file, 'wb') or die("Cannot create $file.");
+	
+	fwrite($fp, implode($header));
+	foreach ($db as $s) {
+		fwrite($fp, $s);
+	}
+	
+	fclose($fp);
+}
+
+
+function _log_($line, $flush = false)
+{
+	static $l_Buffer = '';
+	
+	$l_Buffer .= $line . "\n";
+	
+	if ($flush || strlen($l_Buffer) > 32000)
+	{
+		file_put_contents(LOG_FILE, $l_Buffer, FILE_APPEND);
+		$l_Buffer = '';
+	}
+}

+ 497 - 0
tools/ai-design.html

@@ -0,0 +1,497 @@
+<html>
+<head>
+<!-- https://revisium.com/ai/ -->
+<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
+<META NAME="ROBOTS" CONTENT="NOINDEX,NOFOLLOW">
+<title>@@HEAD_TITLE@@</title>
+<style type="text/css" title="currentStyle">
+	@import "http://revisium.com/extra/media/css/demo_page2.css";
+	@import "http://revisium.com/extra/media/css/jquery.dataTables2.css";
+</style>
+
+<script type="text/javascript" language="javascript" src="http://yandex.st/jquery/2.1.0/jquery.min.js"></script>
+<script type="text/javascript" language="javascript" src="https://datatables.net/download/build/jquery.dataTables.js"></script>
+
+<style type="text/css">
+ body 
+ {
+   font-family: Tahoma;
+   color: #5a5a5a;
+   background: #FFFFFF;
+   font-size: 14px;
+   margin: 20px;
+   padding: 0;
+ }
+
+.header
+ {
+   font-size: 34px;
+   margin: 0 0 10px 0;
+ }
+
+ .hidd
+ {
+    display: none;
+ }
+ 
+ .ok
+ {
+    color: green;
+ }
+ 
+ .line_no
+ {
+   -webkit-border-radius: 6px;
+   -moz-border-radius: 6px;
+   border-radius: 6px;
+
+   background: #DAF2C1;
+   padding: 2px 5px 2px 5px;
+   margin: 0 5px 0 5px;
+ }
+ 
+ .credits_header 
+ {
+  -webkit-border-radius: 6px;
+   -moz-border-radius: 6px;
+   border-radius: 6px;
+
+   background: #F2F2F2;
+   padding: 10px;
+   font-size: 11px;
+    margin: 0 0 10px 0;
+ }
+ 
+ .marker
+ {
+    color: #FF0090;
+	font-weight: 100;
+	background: #FF0090;
+	padding: 2px 0px 2px 0px;
+	width: 2px;
+ }
+ 
+ .title
+ {
+   font-size: 24px;
+   margin: 20px 0 10px 0;
+   color: #9CA9D1;
+}
+
+.summary 
+{
+  float: left;
+  width: 500px;
+}
+
+.summary TD
+{
+  font-size: 12px;
+  border-bottom: 1px solid #F0F0F0;
+  font-weight: 700;
+  padding: 10px 0 10px 0;
+}
+ 
+.crit, .vir
+{
+  color: #D84B55;
+}
+
+.spacer
+{
+   margin: 0 0 50px 0;
+   clear:both;
+}
+
+.warn
+{
+  color: #F6B700;
+}
+
+.clear
+{
+   clear: both;
+}
+
+.offer
+{
+  -webkit-border-radius: 6px;
+   -moz-border-radius: 6px;
+   border-radius: 6px;
+
+   width: 500px;
+   background: #ECF7DE;
+   color: #747474;
+   font-size: 11px;
+   font-family: Arial;
+   padding: 20px;
+   margin: 20px 0 0 500px;
+   
+   font-size: 16px;
+}
+ 
+.flist
+{
+   font-family: Arial;
+}
+
+.flist TD
+{
+   font-size: 11px;
+   padding: 5px;
+}
+
+.flist TH
+{
+   font-size: 12px;
+   height: 30px;
+   padding: 5px;
+   background: #CEE9EF;
+}
+
+
+.it
+{
+   font-size: 14px;
+   font-weight: 100;
+   margin-top: 10px;
+}
+
+.crit .it A {
+   color: #E50931; 
+   line-height: 25px;
+   text-decoration: none;
+}
+
+.warn .it A {
+   color: #F2C900; 
+   line-height: 25px;
+   text-decoration: none;
+}
+
+
+
+.details
+{
+   font-family: Calibri;
+   font-size: 12px;
+   margin: 10px 10px 10px 0px;
+}
+
+.crit .details
+{
+   color: #A08080;
+}
+
+.warn .details
+{
+   color: #808080;
+}
+
+.details A
+{
+  color: #FFF;
+  font-weight: 700;
+  text-decoration: none;
+  padding: 2px;
+  background: #E5CEDE;
+  -webkit-border-radius: 7px;
+   -moz-border-radius: 7px;
+   border-radius: 7px;
+}
+
+.details A:hover
+{
+   background: #A0909B;
+}
+
+.ctd
+{
+   margin: 10px 0px 10px 0;
+   align:center;
+}
+
+.ctd A 
+{
+   color: #0D9922;
+}
+
+.disclaimer
+{
+   color: darkgreen;
+   margin: 10px 10px 10px 0;
+}
+
+.note_vir
+{
+   margin: 10px 0 10px 0;
+   //padding: 10px;
+   color: #FF4F4F;
+   font-size: 15px;
+   font-weight: 700;
+   clear:both;
+  
+}
+
+.note_warn
+{
+   margin: 10px 0 10px 0;
+   color: #F6B700;
+   font-size: 15px;
+   font-weight: 700;
+   clear:both;
+}
+
+.updateinfo
+{
+  color: #FFF;
+  text-decoration: none;
+  background: #E5CEDE;
+  -webkit-border-radius: 7px;
+   -moz-border-radius: 7px;
+   border-radius: 7px;
+
+  margin: 10px 0 10px 0px;   
+  padding: 10px;
+}
+
+
+.caution
+{
+  color: #EF7B75;
+  text-decoration: none;
+  margin: 20px 0 0px 0px;   
+  font-size: 12px;
+}
+
+.footer
+{
+  color: #303030;
+  text-decoration: none;
+  background: #F4F4F4;
+  -webkit-border-radius: 7px;
+   -moz-border-radius: 7px;
+   border-radius: 7px;
+
+  margin: 80px 0 10px 0px;   
+  padding: 10px;
+}
+
+.rep
+{
+  color: #303030;
+  text-decoration: none;
+  background: #94DDDB;
+  -webkit-border-radius: 7px;
+   -moz-border-radius: 7px;
+   border-radius: 7px;
+
+  margin: 10px 0 10px 0px;   
+  padding: 10px;
+  font-size: 12px;
+}
+
+</style>
+
+</head>
+<body>
+
+<div class="header">@@MAIN_TITLE@@ @@PATH_URL@@ (@@MODE@@)</div>
+<div class="credits_header">@@CREDITS@@</div>
+<div class="details_header">
+   @@STAT@@<br/>
+   @@SCANNED@@ @@MEMORY@@.
+ </div>
+
+ @@WARN_QUICK@@
+ 
+ <div class="summary">
+@@SUMMARY@@
+ </div>
+ 
+ <div class="offer">
+@@OFFER@@
+ </div>
+  
+ <div class="clear"></div>
+ 
+ @@MAIN_CONTENT@@
+ 
+	<div class="footer">
+	@@FOOTER@@
+	</div>
+	
+<script language="javascript">
+
+function hsig(id) {
+  var divs = document.getElementsByTagName("tr");
+  for(var i = 0; i < divs.length; i++){
+     
+     if (divs[i].getAttribute('o') == id) {
+        divs[i].innerHTML = '';
+     }
+  }
+
+  return false;
+}
+
+
+$(document).ready(function(){
+    $('#table_crit').dataTable({
+       "aLengthMenu": [[100 , 500, -1], [100, 500, "All"]],
+       "aoColumns": [
+                                     {"iDataSort": 7, "width":"70%"},
+                                     {"iDataSort": 5},
+                                     {"iDataSort": 6},
+                                     {"bSortable": true},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false}
+                     ],
+		"paging": true,
+       "iDisplayLength": 500,
+		"oLanguage": {
+			"sLengthMenu": "Отображать по _MENU_ записей",
+			"sZeroRecords": "Ничего не найдено",
+			"sInfo": "Отображается c _START_ по _END_ из _TOTAL_ файлов",
+			"sInfoEmpty": "Нет файлов",
+			"sInfoFiltered": "(всего записей _MAX_)",
+			"sSearch":       "Поиск:",
+			"sUrl":          "",
+			"oPaginate": {
+				"sFirst": "Первая",
+				"sPrevious": "Предыдущая",
+				"sNext": "Следующая",
+				"sLast": "Последняя"
+			},
+			"oAria": {
+				"sSortAscending":  ": активировать для сортировки столбца по возрастанию",
+				"sSortDescending": ": активировать для сортировки столбцов по убыванию"			
+			}
+		}
+
+     } );
+
+});
+
+$(document).ready(function(){
+    $('#table_vir').dataTable({
+       "aLengthMenu": [[100 , 500, -1], [100, 500, "All"]],
+		"paging": true,
+       "aoColumns": [
+                                     {"iDataSort": 7, "width":"70%"},
+                                     {"iDataSort": 5},
+                                     {"iDataSort": 6},
+                                     {"bSortable": true},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false}
+                     ],
+       "iDisplayLength": 500,
+		"oLanguage": {
+			"sLengthMenu": "Отображать по _MENU_ записей",
+			"sZeroRecords": "Ничего не найдено",
+			"sInfo": "Отображается c _START_ по _END_ из _TOTAL_ файлов",
+			"sInfoEmpty": "Нет файлов",
+			"sInfoFiltered": "(всего записей _MAX_)",
+			"sSearch":       "Поиск:",
+			"sUrl":          "",
+			"oPaginate": {
+				"sFirst": "Первая",
+				"sPrevious": "Предыдущая",
+				"sNext": "Следующая",
+				"sLast": "Последняя"
+			},
+			"oAria": {
+				"sSortAscending":  ": активировать для сортировки столбца по возрастанию",
+				"sSortDescending": ": активировать для сортировки столбцов по убыванию"			
+			}
+		},
+
+     } );
+
+});
+
+if ($('#table_warn0')) {
+    $('#table_warn0').dataTable({
+       "aLengthMenu": [[100 , 500, -1], [100, 500, "All"]],
+		"paging": true,
+       "aoColumns": [
+                                     {"iDataSort": 7, "width":"70%"},
+                                     {"iDataSort": 5},
+                                     {"iDataSort": 6},
+                                     {"bSortable": true},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false}
+                     ],
+       "iDisplayLength": 500,
+		"paging": true,
+		"oLanguage": {
+			"sLengthMenu": "Отображать по _MENU_ записей",
+			"sZeroRecords": "Ничего не найдено",
+			"sInfo": "Отображается c _START_ по _END_ из _TOTAL_ файлов",
+			"sInfoEmpty": "Нет файлов",
+			"sInfoFiltered": "(всего записей _MAX_)",
+			"sSearch":       "Поиск:",
+			"sUrl":          "",
+			"oPaginate": {
+				"sFirst": "Первая",
+				"sPrevious": "Предыдущая",
+				"sNext": "Следующая",
+				"sLast": "Последняя"
+			},
+			"oAria": {
+				"sSortAscending":  ": активировать для сортировки столбца по возрастанию",
+				"sSortDescending": ": активировать для сортировки столбцов по убыванию"			
+			}
+		}
+
+     } );
+}
+
+if ($('#table_warn1')) {
+    $('#table_warn1').dataTable({
+       "aLengthMenu": [[100 , 500, -1], [100, 500, "All"]],
+		"paging": true,
+       "aoColumns": [
+                                     {"iDataSort": 7, "width":"70%"},
+                                     {"iDataSort": 5},
+                                     {"iDataSort": 6},
+                                     {"bSortable": true},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false},
+                                     {"bVisible": false}
+                     ],
+       "iDisplayLength": 500,
+		"oLanguage": {
+			"sLengthMenu": "Отображать по _MENU_ записей",
+			"sZeroRecords": "Ничего не найдено",
+			"sInfo": "Отображается c _START_ по _END_ из _TOTAL_ файлов",
+			"sInfoEmpty": "Нет файлов",
+			"sInfoFiltered": "(всего записей _MAX_)",
+			"sSearch":       "Поиск:",
+			"sUrl":          "",
+			"oPaginate": {
+				"sFirst": "Первая",
+				"sPrevious": "Предыдущая",
+				"sNext": "Следующая",
+				"sLast": "Последняя"
+			},
+			"oAria": {
+				"sSortAscending":  ": активировать для сортировки столбца по возрастанию",
+				"sSortDescending": ": активировать для сортировки столбцов по убыванию"			
+			}
+		}
+
+     } );
+}
+
+
+</script>
+ </body>
+</html>

+ 31 - 0
tools/handler.php

@@ -0,0 +1,31 @@
+<?php
+
+// when scanning process starts
+function aibolit_onStart() {
+   // TODO...
+}
+
+// when scanning process ends
+function aibolit_onComplete($exit_code, $stat) {
+   // TODO...
+}
+
+// when progress updates
+function aibolit_onProgressUpdate($data) {
+   // TODO...
+}
+
+// error when reading file
+function aibolit_onReadError($path, $type) {
+   // TODO...
+}
+
+// when skips big file
+function aibolit_onBigFile($path) {
+   // TODO...
+}
+
+// when some fatal error occurs
+function aibolit_onFatalError($errstr) {
+   // TODO...
+}

+ 79 - 0
tools/vps_docroot.php

@@ -0,0 +1,79 @@
+<?php
+///////////////////////////////////////////////////////////////////////////
+// Created and developed by Greg Zemskov, Revisium Company
+// Email: ai@revisium.com, http://revisium.com/ai/, skype: greg_zemskov
+// For non-commercial usage only
+///////////////////////////////////////////////////////////////////////////
+
+$found_dirs = array();
+
+// exclude from scan list
+$exclude_dirs = array(
+    '/usr/share', 
+    '/var/www',
+	'/usr'
+                );
+
+// add extra dirs to scan list
+$include_dirs = array(
+    '/tmp', 
+    '/home/bitrix', 
+    '/var/www/bitrix', 
+    '/var/tmp'
+                );
+
+
+////////////////////////////////////////////////////////////////////////////////////////////////////////
+function scan_configs($path, $recurs) {
+	global $found_dirs;
+	if (!file_exists($path)) {
+           return; 
+        }
+		
+	if ($dir = opendir($path)) {
+		while($file = readdir($dir)) {
+			if (($file == '.') or ($file == '..'))
+				continue;
+			
+			$name = $file;
+			$file = $path . '/' . $file;
+			
+			if (is_dir($file) && $recurs)  {
+				scan_configs($file, true);
+			}
+
+			if (is_file($file) && filesize($file) < 5000000) {
+                           $content = file_get_contents($file);
+                           if ((preg_match_all('~DocumentRoot\s+[\'"]?(/[^\s\'"]+)~mi', $content, $out, PREG_PATTERN_ORDER)) ||
+			       (preg_match_all('~DocumentRoot\s+(/.+)~mi', $content, $out, PREG_PATTERN_ORDER)) ||
+                               (preg_match_all('~root_path\s+(/.+);~mi', $content, $out, PREG_PATTERN_ORDER)) ||
+                               (preg_match_all('~root\s+(/.+);$~mi', $content, $out, PREG_PATTERN_ORDER))) {
+				foreach ($out[1] as $index => $docroot) {
+                   $docroot = "/" . trim(trim($docroot), "/");
+				   $found_dirs[$docroot] = 1;
+                                }
+                           }
+                        }
+		}  
+
+		closedir($dir);
+ 	}
+}
+
+scan_configs('/etc/apache2', true);
+scan_configs('/etc/httpd', true);
+scan_configs('/usr/local/nginx/conf', true);
+scan_configs('/etc/nginx', true);
+scan_configs('/usr/local/etc/nginx', true);
+scan_configs('/usr/local/directadmin/data', true);
+scan_configs('/home/admin/conf/', true);
+
+$result_list = array_merge(array_diff(array_keys($found_dirs), $exclude_dirs), $include_dirs);
+sort($result_list);
+
+foreach ($result_list as $dir) {
+   if (file_exists($dir)) {
+      echo $dir . "\n";
+   }
+}
+