diff --git a/src/server/cyberhex-code/api/php/database/compile_database.php b/src/server/cyberhex-code/api/php/database/compile_database.php index e7d0192..42b75e1 100644 --- a/src/server/cyberhex-code/api/php/database/compile_database.php +++ b/src/server/cyberhex-code/api/php/database/compile_database.php @@ -42,7 +42,7 @@ function sort_hashes($inputFile, $excluded) { } function download_files($excluded){ //download from virusshare - /*$file_count=485; + $file_count=485; for($i=0;$i<$file_count;$i++){ $fileNumber = sprintf('%05d', $i); $url="https://virusshare.com/hashfiles/VirusShare_$fileNumber.md5"; @@ -58,7 +58,7 @@ function download_files($excluded){ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $fileContents = curl_exec($ch); file_put_contents("/var/www/html/database_srv/buf.md5", $fileContents); - sort_hashes("/var/www/html/database_srv/buf.md5", $excluded);*/ + sort_hashes("/var/www/html/database_srv/buf.md5", $excluded); //download yara rules $url="https://jakach.duckdns.org/cyberhex/yara/yara.zip"; $ch = curl_init($url); @@ -154,7 +154,7 @@ $files = glob($directory . '/*'); foreach ($files as $file) { // Check if the file is a regular file (not a directory) if (is_file($file)) { - //unlink($file); + unlink($file); } } set_time_limit(0); diff --git a/src/server/cyberhex-code/system/secure_zone/php/database_settings.php b/src/server/cyberhex-code/system/secure_zone/php/database_settings.php index cc7e2f7..0d1a1a0 100644 --- a/src/server/cyberhex-code/system/secure_zone/php/database_settings.php +++ b/src/server/cyberhex-code/system/secure_zone/php/database_settings.php @@ -225,12 +225,59 @@ async function add_item(db,element_id1,field1,element_id2,field2){ //we have two diff --git a/src/server/cyberhex-code/system/secure_zone/php/database_settings_functions.php b/src/server/cyberhex-code/system/secure_zone/php/database_settings_functions.php index ad883e4..2263b67 100644 --- a/src/server/cyberhex-code/system/secure_zone/php/database_settings_functions.php +++ b/src/server/cyberhex-code/system/secure_zone/php/database_settings_functions.php @@ -58,4 +58,31 @@ function safe_settings($db){//load settings $conn->close(); } + +function list_yara_files($dir) { + $yar_files = []; + + // Open the directory + if ($handle = opendir($dir)) { + // Iterate over each entry in the directory + while (false !== ($entry = readdir($handle))) { + // Exclude current directory (.) and parent directory (..) + if ($entry != "." && $entry != "..") { + $path = $dir . '/' . $entry; + // If the entry is a directory, call the function recursively + if (is_dir($path)) { + $yar_files = array_merge($yar_files, list_yar_files($path)); + } + // If the entry is a file and ends with .yar extension, add it to the array + elseif (is_file($path) && pathinfo($path, PATHINFO_EXTENSION) === 'yar') { + $yar_files[] = $path; + } + } + } + // Close the directory handle + closedir($handle); + } + + return $yar_files; +} ?> \ No newline at end of file