mirror of
https://github.com/horsicq/Detect-It-Easy.git
synced 2026-06-24 01:54:08 +00:00
Add Max heuristic, resource DB, renamer script
Add heuristic to detect 'Max' product in PE heuristics: push a "Max Spyware" verdict when ProductName equals "Max" in db/PE/__GenericHeuristicAnalysis_By_DosX.7.sg. Add a new binary DB file dbs_special/db_view_resource_names.db. Add ren_files_by_dosx.js: a Node.js utility that recursively finds .sg files, extracts the first argument passed to meta(), and renames files by prefixing that value (underscores in names are used to skip renaming). The script includes logging, safety checks for existing target names, and accepts a start directory argument (defaults to current dir).
This commit is contained in:
parent
e0b391f1fa
commit
e2b5b3d975
3 changed files with 173 additions and 0 deletions
|
|
@ -6561,6 +6561,21 @@ function scanForMaliciousCode_NET_and_Native() {
|
|||
|
||||
|
||||
|
||||
// https://max.ru/
|
||||
|
||||
if (verdicts.length === 0 && (
|
||||
PE.getVersionStringInfo("ProductName") === "Max"
|
||||
)) {
|
||||
verdicts.push({
|
||||
type: "Max Spyware",
|
||||
version: String(),
|
||||
details: String()
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Many not-so-smart virus writers use base64 to pack
|
||||
// or hide malicious code, but do not realize that this
|
||||
// is very easily detected by heuristic analysis.
|
||||
|
|
|
|||
BIN
dbs_special/db_view_resource_names.db
Normal file
BIN
dbs_special/db_view_resource_names.db
Normal file
Binary file not shown.
158
ren_files_by_dosx.js
Normal file
158
ren_files_by_dosx.js
Normal file
|
|
@ -0,0 +1,158 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
/**
|
||||
* Рекурсивно находит все .sg файлы в директории
|
||||
* @param {string} dir - Путь к директории
|
||||
* @param {string[]} fileList - Массив найденных файлов
|
||||
* @returns {string[]} Массив путей к .sg файлам
|
||||
*/
|
||||
function findSgFiles(dir, fileList = []) {
|
||||
try {
|
||||
const files = fs.readdirSync(dir);
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = path.join(dir, file);
|
||||
|
||||
try {
|
||||
const stat = fs.statSync(filePath);
|
||||
|
||||
if (stat.isDirectory()) {
|
||||
// Рекурсивный обход директорий
|
||||
findSgFiles(filePath, fileList);
|
||||
} else if (path.extname(file).toLowerCase() === '.sg') {
|
||||
fileList.push(filePath);
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`Ошибка доступа к файлу ${filePath}:`, err.message);
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
console.error(`Ошибка чтения директории ${dir}:`, err.message);
|
||||
}
|
||||
|
||||
return fileList;
|
||||
}
|
||||
|
||||
/**
|
||||
* Извлекает первый аргумент из вызова функции meta()
|
||||
* @param {string} content - Содержимое файла
|
||||
* @returns {string|null} Первый аргумент meta() или null
|
||||
*/
|
||||
function extractMetaPrefix(content) {
|
||||
// Проверяем наличие " DosX"
|
||||
// if (!content.includes(' DosX')) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// if (!content.includes('BJNFNE')) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// Ищем вызов meta() с помощью регулярного выражения
|
||||
// Поддерживает различные варианты форматирования
|
||||
const metaRegex = /meta\s*\(\s*["']([^"']*)["']\s*,/;
|
||||
const match = content.match(metaRegex);
|
||||
|
||||
if (match && match[1] && match[1].trim() !== '') {
|
||||
return match[1].trim();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Переименовывает файл, добавляя префикс
|
||||
* @param {string} filePath - Путь к файлу
|
||||
* @param {string} prefix - Префикс для добавления
|
||||
* @returns {boolean} true если успешно, false если ошибка
|
||||
*/
|
||||
function renameFileWithPrefix(filePath, prefix) {
|
||||
try {
|
||||
const dir = path.dirname(filePath);
|
||||
const fileName = path.basename(filePath);
|
||||
|
||||
// Проверяем, не начинается ли уже файл с этого префикса
|
||||
//if (fileName.startsWith(`${prefix}_`)) {
|
||||
if (fileName.includes(`_`)) { // Если в имени файла уже есть символ "_", пропускаем переименование
|
||||
console.log(`⏭️ Пропускаю ${fileName} - префикс уже есть`);
|
||||
return false;
|
||||
}
|
||||
|
||||
const newFileName = `${prefix.replace(/ /g, '_')}_${fileName}`;
|
||||
const newFilePath = path.join(dir, newFileName);
|
||||
|
||||
// Проверяем, не существует ли уже файл с новым именем
|
||||
if (fs.existsSync(newFilePath)) {
|
||||
console.warn(`⚠️ Файл ${newFileName} уже существует, пропускаю переименование`);
|
||||
return false;
|
||||
}
|
||||
|
||||
fs.renameSync(filePath, newFilePath);
|
||||
console.log(`✅ Переименован: ${fileName} → ${newFileName}`);
|
||||
return true;
|
||||
} catch (err) {
|
||||
console.error(`❌ Ошибка переименования ${filePath}:`, err.message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Основная функция обработки файлов
|
||||
* @param {string} startDir - Начальная директория для поиска
|
||||
*/
|
||||
function processFiles(startDir) {
|
||||
console.log(`🔍 Поиск .sg файлов в ${startDir}...\n`);
|
||||
|
||||
const sgFiles = findSgFiles(startDir);
|
||||
console.log(`📁 Найдено файлов: ${sgFiles.length}\n`);
|
||||
|
||||
if (sgFiles.length === 0) {
|
||||
console.log('Нет .sg файлов для обработки.');
|
||||
return;
|
||||
}
|
||||
|
||||
let processed = 0;
|
||||
let renamed = 0;
|
||||
let skipped = 0;
|
||||
|
||||
sgFiles.forEach(filePath => {
|
||||
try {
|
||||
const content = fs.readFileSync(filePath, 'utf8');
|
||||
const prefix = extractMetaPrefix(content);
|
||||
|
||||
if (prefix) {
|
||||
processed++;
|
||||
console.log(`\n📄 Обработка: ${path.basename(filePath)}`);
|
||||
console.log(` Префикс: "${prefix}"`);
|
||||
|
||||
if (renameFileWithPrefix(filePath, prefix)) {
|
||||
renamed++;
|
||||
} else {
|
||||
skipped++;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(`❌ Ошибка чтения ${filePath}:`, err.message);
|
||||
}
|
||||
});
|
||||
|
||||
console.log('\n' + '='.repeat(50));
|
||||
console.log(`📊 Статистика:`);
|
||||
console.log(` Всего файлов: ${sgFiles.length}`);
|
||||
console.log(` Обработано: ${processed}`);
|
||||
console.log(` Переименовано: ${renamed}`);
|
||||
console.log(` Пропущено: ${skipped}`);
|
||||
console.log('='.repeat(50));
|
||||
}
|
||||
|
||||
// Запуск скрипта
|
||||
const startDirectory = process.argv[2] || '.';
|
||||
|
||||
if (!fs.existsSync(startDirectory)) {
|
||||
console.error(`❌ Директория ${startDirectory} не существует!`);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
console.log('🚀 Запуск скрипта переименования .sg файлов\n');
|
||||
processFiles(startDirectory);
|
||||
Loading…
Add table
Add a link
Reference in a new issue