
إخفاء واجهات برمجة تطبيقات Windows محددة باستخدام واجهات برمجة تطبيقات مختلفة
تعتيم (إخفاء) واردات PE عن أدوات التحليل الثابتة/الديناميكية.
هذا واضح، لنقل أنني استخدمت VirtualProtect وأريد تعتيمه باستخدام Sleep، ستقوم الأداة بالتلاعب بـ IAT بحيث يشير الثنك الذي يشير إلى VirtualProtect بدلاً من ذلك إلى Sleep. الآن عند تنفيذ الملف، سيقوم محمل ويندوز بتحميل Sleep بدلاً من VirtualProtect، وينقل التنفيذ إلى نقطة الدخول، ومن هناك سيتم إعادة توجيه التنفيذ إلى شيل كود الذي وضعته الأداة مسبقًا، للعثور على عنوان VirtualProtect واستخدامه لاستبدال عنوان Sleep الذي تم تعيينه مسبقًا بواسطة المحمل.
#include <cobf.hpp>
int main() {
cobf obf_file = cobf("sample.exe");
obf_file.load_pe();
obf_file.obf_sym("kernel32.dll", "SetLastError", "Beep");
obf_file.obf_sym("kernel32.dll", "GetLastError", "GetACP");
obf_file.generate("sample_obfuscated.exe");
obf_file.unload_pe();
return 0;
};
config.ini).cobf.exe <input file> <out file> [config file]; Template for the config file:
; * Sections can be written as:
; [dll_name]
; old_sym=new_sym
; * The dll name is case insensitive, but
; the old and the new symbols are not.
; * You can use the wildcard on both the
; dll name and the old symbol.
; * You can use '#' at the start of
; the old or the new symbol to flag
; an ordinal.
; * The new symbol should be exported
; by the dll so the windows loader can resolve it.
; For example:
; * Obfuscating all of the symbols
; imported from user32.dll with ordinal 1600.
[user32.dll]
*=#1600
; * Obfuscating symbols imported from both
; kernel32.dll and kernelbase.dll with Sleep.
[kernel*.dll]
*=Sleep
; * Obfuscating fprintf with exit.
[*]
fprintf=exit
قم ببناء نموذج الكود هذا
#include <windows.h>
#include <stdio.h>
int main() {
SetLastError(5);
printf("Last error is %d\n", GetLastError());
return 0;
};
بعد بنائه، هكذا تبدو واردات kernel32

الآن دعنا نعمي كلاً من SetLastError و GetLastError باستخدام Beep و GetACP (في الواقع أي api من kernel32 سيكون مقبولاً حتى لو لم يتم استيراده على الإطلاق).
التهيئات المستخدمة هي
[kernel32.dll]
SetLastError=Beep
GetLastError=GetACP
إليك الناتج (يمكنك أيضًا استخدام المكتبة مباشرة كما هو موضح أعلاه).

مرة أخرى دعنا نلقي نظرة على واردات kernel32

لا وجود لـ SetLastError أو GetLastError
تأكيد أن الملفين سيعملان بشكل صحيح

مفكك HexRays الخاص بـ IDA

مصحح IDA

Ghidra

ApiMonitor

ذلك لأن جميع أدوات التحليل الثابتة تعتمد على اسم API المكتوب في IAT والذي يمكن التلاعب به كما هو موضح.
بالنسبة لـ ApiMonitor، بسبب استخدام ربط IAT، توجد نفس المشكلة.
على الجانب الآخر، بالنسبة لأدوات مثل x64dbg، فإن أسماء API المعروضة ستعتمد فقط على ما يتم استدعاؤه فعليًا (وليس ما هو مكتوب في IAT).

.cobf لاحتواء الشيل كود والبيانات الأخرى المطلوبة.git clone https://github.com/d35ha/CallObfuscator.