
استخراج وإزالة التعتيم عن وحدات ماكرو XLM (المعروفة أيضًا باسم ماكرو Excel 4.0)
يمكن استخدام XLMMacroDeobfuscator لفك تشفير وحدات الماكرو XLM المبهمة (المعروفة أيضًا باسم وحدات ماكرو Excel 4.0). يستخدم محاكي XLM داخليًا لتفسير وحدات الماكرو دون تنفيذ الكود بالكامل.
يدعم كلًا من تنسيقات xls و xlsm و xlsb.
يستخدم xlrd2 و pyxlsb2 ومحللًا خاصًا به لاستخراج الخلايا والمعلومات الأخرى من ملفات xls و xlsb و xlsm على التوالي.
يمكنك أيضًا العثور على قواعد XLM في xlm-macro-lark.template
pip install XLMMacroDeobfuscator --force
أو
pip install xlmmacrodeobfuscator[defusedxml] --force
pip install -U https://github.com/DissectMalware/XLMMacroDeobfuscator/archive/master.zip --force
لفك تشفير وحدات الماكرو في مستندات Excel:
xlmdeobfuscator --file document.xlsm
لاستخراج وحدات الماكرو فقط في مستندات Excel (بدون أي فك تشفير):
xlmdeobfuscator --file document.xlsm -x
للحصول فقط على وحدات الماكرو التي تم فك تشفيرها بدون أي مسافة بادئة:
xlmdeobfuscator --file document.xlsm --no-indent --output-formula-format "[[INT-FORMULA]]"
`
لتصدير المخرجات بتنسيق JSON:
xlmdeobfuscator --file document.xlsm --export-json result.json
لرؤية نموذج لمخرجات JSON، يرجى الاطلاع على [هذا الرابط](https://pastebin.com/bwmS7mi0).
لاستخدام ملف تكوين:
xlmdeobfuscator --file document.xlsm -c default.config `
يجب أن يكون ملف default.config ملف JSON صحيحًا، مثل:
{
"no-indent": true,
"output-formula-format": "[[CELL-ADDR]] [[INT-FORMULA]]",
"non-interactive": true,
"output-level": 1
}
_ _______
|\ /|( \ ( )
( \ / )| ( | () () |
\ (_) / | | | || || |
) _ ( | | | |(_)| |
/ ( ) \ | | | | | |
( / \ )| (____/\| ) ( |
|/ \|(_______/|/ \|
______ _______ _______ ______ _______ _______ _______ _______ _________ _______ _______
( __ \ ( ____ \( ___ )( ___ \ ( ____ \|\ /|( ____ \( ____ \( ___ )\__ __/( ___ )( ____ )
| ( \ )| ( \/| ( ) || ( ) )| ( \/| ) ( || ( \/| ( \/| ( ) | ) ( | ( ) || ( )|
| | ) || (__ | | | || (__/ / | (__ | | | || (_____ | | | (___) | | | | | | || (____)|
| | | || __) | | | || __ ( | __) | | | |(_____ )| | | ___ | | | | | | || __)
| | ) || ( | | | || ( \ \ | ( | | | | ) || | | ( ) | | | | | | || (\ (
| (__/ )| (____/\| (___) || )___) )| ) | (___) |/\____) || (____/\| ) ( | | | | (___) || ) \ \__
(______/ (_______/(_______)|/ \___/ |/ (_______)\_______)(_______/|/ \| )_( (_______)|/ \__/
XLMMacroDeobfuscator(v0.2.0) - https://github.com/DissectMalware/XLMMacroDeobfuscator
Error: --file is missing
usage: deobfuscator.py [-h] [-c FILE_PATH] [-f FILE_PATH] [-n] [-x]
[--sort-formulas] [--defined-names] [-2]
[--with-ms-excel] [-s] [-d DAY]
[--output-formula-format OUTPUT_FORMULA_FORMAT]
[--extract-formula-format EXTRACT_FORMULA_FORMAT]
[--no-indent] [--silent] [--export-json FILE_PATH]
[--start-point CELL_ADDR] [-p PASSWORD]
[-o OUTPUT_LEVEL] [--timeout N]
optional arguments:
-h, --help show this help message and exit
-c FILE_PATH, --config-file FILE_PATH
Specify a config file (must be a valid JSON file)
-f FILE_PATH, --file FILE_PATH
The path of a XLSM file
-n, --noninteractive Disable interactive shell
-x, --extract-only Only extract cells without any emulation
--sort-formulas Sort extracted formulas based on their cell address
(requires -x)
--defined-names Extract all defined names
-2, --no-ms-excel [Deprecated] Do not use MS Excel to process XLS files
--with-ms-excel Use MS Excel to process XLS files
-s, --start-with-shell
Open an XLM shell before interpreting the macros in
the input
-d DAY, --day DAY Specify the day of month
--output-formula-format OUTPUT_FORMULA_FORMAT
Specify the format for output formulas ([[CELL-ADDR]],
[[INT-FORMULA]], and [[STATUS]]
--extract-formula-format EXTRACT_FORMULA_FORMAT
Specify the format for extracted formulas ([[CELL-
ADDR]], [[CELL-FORMULA]], and [[CELL-VALUE]]
--no-indent Do not show indent before formulas
--silent Do not print output
--export-json FILE_PATH
Export the output to JSON
--start-point CELL_ADDR
Start interpretation from a specific cell address
-p PASSWORD, --password PASSWORD
Password to decrypt the protected document
-o OUTPUT_LEVEL, --output-level OUTPUT_LEVEL
Set the level of details to be shown (0:all commands,
1: commands no jump 2:important commands 3:strings in
important commands).
--timeout N stop emulation after N seconds (0: not interruption
N>0: stop emulation after N seconds)
يوضح المثال التالي كيفية استخدام XLMMacroDeobfuscator في مشروع بايثون لفك تشفير وحدات ماكرو XLM:
from XLMMacroDeobfuscator.deobfuscator import process_file
result = process_file(file='path/to/an/excel/file',
noninteractive= True,
noindent= True,
output_formula_format='[[CELL-ADDR]], [[INT-FORMULA]]',
return_deobfuscated= True,
timeout= 30)
for record in result:
print(record)
يرجى قراءة ملف requirements.txt للحصول على قائمة مكتبات بايثون التي يعتمد عليها XLMMacroDeobfuscator.
يمكن تشغيل xlmdeobfuscator على أي نظام تشغيل لاستخراج وفك تشفير وحدات الماكرو في ملفات xls و xlsm و xlsb. لا تحتاج إلى تثبيت MS Excel.
ملاحظة: إذا كنت تريد استخدام MS Excel (على ويندوز)، فستحتاج إلى تثبيت مكتبة pywin32 واستخدام المفتاح --with-ms-excel. إذا تم استخدام --with-ms-excel، سيحاول xlmdeobfuscator أولاً تحميل ملفات xls بواسطة MS Excel، وإذا فشل، سيستخدم مكتبة xlrd2.
تم اعتماد XLMMacroDeofuscator في المشاريع التالية:
يرجى الاتصال بي إذا قمت بدمج XLMMacroDeofuscator في مشروعك.
إذا وجدت خطأ أو ترغب في اقتراح تحسين، يرجى إنشاء مشكلة جديدة على صفحة المشكلات.
لا تتردد في المساهمة في المشروع عن طريق عمل fork للمشروع وتقديم طلب سحب (pull request).
يمكنك التواصل مع (@DissectMlaware) عبر تويتر عبر رسالة مباشرة.