Пример #1
0
function scan_dir($dir)
{
    if (!is_dir($dir)) {
        return;
    }
    foreach (glob("{$dir}/*") as $file) {
        if (is_dir($file)) {
            if (basename($file) != "CVS") {
                scan_dir($file);
            }
        } else {
            if (fnmatch("*.h", $file)) {
                scan_file($file);
            }
        }
    }
}
Пример #2
0
/**
 * List files recursivly and scan them
 *
 * @return bool
 */
function list_files($prefix, $path, &$userdata)
{
    if (is_dir($prefix . $path) && is_resource($handle = @opendir($prefix . $path))) {
        while ($name = readdir($handle)) {
            if (strpos($name, ".xml") !== false) {
                scan_file($prefix, $path . $name, $userdata);
            } else {
                if (is_dir($prefix . $path . $name) && $name !== 'CVS' && $name !== '.' && $name !== '..') {
                    list_files($prefix, $path . $name . DIRECTORY_SEPARATOR, $userdata);
                }
            }
        }
        closedir($handle);
        return true;
    } else {
        return false;
    }
}
/**
 * Get the list of the files in rootdir and all subdirs<br>
 * 
 * @global string $ignoreDirs   directories to be ignored
 * @param string $dir   directory to scan for files
 * @return array    array with found files 
 */
function get_filelist($dir)
{
    global $ignoreDirs;
    $ignoreArr = explode('|', $ignoreDirs);
    $path = '';
    $toResolve = array($dir);
    while ($toResolve) {
        $thisDir = array_pop($toResolve);
        if ($dirContent = scandir($thisDir)) {
            foreach ($dirContent as $content) {
                if (!in_array($content, $ignoreArr)) {
                    // skipping ignored dirs
                    $thisFile = "{$thisDir}/{$content}";
                    if (is_file($thisFile)) {
                        //$path[$thisFile] = md5_file($thisFile);
                        scan_file($thisFile);
                    } else {
                        $toResolve[] = $thisFile;
                    }
                }
            }
        }
    }
    //return $path;
}
Пример #4
0
if ($paramsHastable->size() != 2 || '--help' == $paramsHastable->get(1)) {
    help();
} else {
    $path = $paramsHastable->get(1);
    if (!SysDirectory::exists($path)) {
        error('Le répertoire ' . $path . ' est inaccessible !');
    } else {
        $files =& new Queue();
        find_files($path, $files);
        if (0 == $files->size()) {
            error('Aucun fichier php a scanner');
        } else {
            $shell->set('scan_results', new Queue());
            $iterator =& $files->getIterator();
            while ($iterator->hasNext()) {
                $entry =& $iterator->next();
                scan_file($entry, $shell);
            }
            unset($files);
            $iterator =& $shell->get('scan_results')->getIterator();
            while ($iterator->hasNext()) {
                $filepath = System::find_class_filepath($iterator->next());
                scan_file(new SysFile($filepath), $shell);
            }
            $iterator =& $shell->get('scan_results')->getIterator();
            while ($iterator->hasNext()) {
                echo $iterator->next() . System::crlf;
            }
        }
    }
}
Пример #5
0
$retval = '';
$op = COM_applyFilter($_REQUEST['op']);
$showheader = true;
switch ($op) {
    case 'scan':
        echo COM_siteHeader('none');
        $scan_id = intval($_REQUEST['sid']);
        echo scan_css($scan_id);
        echo COM_siteFooter();
        break;
    case 'scanfile':
        header("Cache-Control: no-store, no-cache, must-revalidate");
        header("content-type: application/xml");
        $scan_id = intval($_REQUEST['scan_id']);
        $scan_num = intval($_REQUEST['scan_num']);
        echo scan_file($scan_id, $scan_num);
        $retval = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n";
        $retval .= "<result>\n";
        $retval .= "<retval>hello world</retval>\n";
        $retval .= "</result>\n";
        //echo $retval;
        exit;
    case 'preview':
        $file = $_REQUEST['filename'];
        $class = $_REQUEST['class'];
        echo preview_file($file, $class);
        break;
    case 'delete':
        $scan_id = intval($_REQUEST['sid']);
        DB_query("DELETE FROM {$_TABLES['nxscan_options']} WHERE scan_id={$scan_id} AND user_id={$_USER['uid']}");
        DB_query("DELETE FROM {$_TABLES['nxscan_cssscan']} WHERE scan_id={$scan_id} AND user_id={$_USER['uid']}");
/**
 * Get the list of the files in rootdir and all subdirs<br>
 *
 * @global string $ignoreDirs   directories to be ignored
 * @param string $dir   directory to scan for files
 * @return array    array with found files
 */
function get_filelist($dir)
{
    global $ignoreDirs;
    global $wp_md5;
    $ignoreArr = explode('|', $ignoreDirs);
    $path = '';
    $toResolve = array($dir);
    while ($toResolve) {
        $thisDir = array_pop($toResolve);
        if ($dirContent = scandir($thisDir)) {
            foreach ($dirContent as $content) {
                if (!in_array($content, $ignoreArr)) {
                    // skipping ignored dirs
                    $thisFile = "{$thisDir}/{$content}";
                    if (is_file($thisFile)) {
                        if (@$_GET['get_hash'] === 1) {
                            // if requested through URL
                            $path[$thisFile] = hash_file('sha256', $thisFile);
                        }
                        if (defined('ABSPATH')) {
                            $wprootPath = substr($thisFile, strlen(ABSPATH));
                            if (isset($wp_md5[$wprootPath]) && $wp_md5[$wprootPath] === md5_file($thisFile)) {
                                continue;
                            }
                        }
                        scan_file($thisFile);
                    } else {
                        $toResolve[] = $thisFile;
                    }
                }
            }
        }
    }
    // saving hashes to file (if requested)
    if ($_GET['get_hash'] === 1) {
        file_put_contents('jamss_hashes', json_encode($path));
    }
}
Пример #7
0
function get_filelist($dir)
{
    global $ignoreDirs;
    $ignoreArr = explode('|', $ignoreDirs);
    $path = '';
    $toResolve = array($dir);
    while ($toResolve) {
        $thisDir = array_pop($toResolve);
        if (@($dirContent = scandir($thisDir))) {
            foreach ($dirContent as $content) {
                if (!in_array($content, $ignoreArr)) {
                    $thisFile = "{$thisDir}/{$content}";
                    if (is_file(@$thisFile)) {
                        scan_file($thisFile);
                    } else {
                        $toResolve[] = $thisFile;
                    }
                }
            }
        }
    }
}