1 730
Singularity - Stealthy Linux Kernel Rootkit
https://blog.kyntra.io/Singularity-A-final-boss-linux-kernel-rootkit
https://github.com/MatheuZSecurity/Singularity?tab=readme-ov-file#installation
12 Dek 2025, 16:03
Evade behavioral analysis by executing malicious code within trusted Microsoft call stacks Uses hardware breakpoints + VEH to hijack legitimate functions and spoof module origins │ 1. Target Function Call │ ↓ │ 2. CPU Debug Register Triggers (DR0-DR3) │ │ ↓ │ 3. EXCEPTION_SINGLE_STEP Raised │ │ ↓ │ 4. VEH Handler Intercepts Exception │ │ ↓ │ 5. Execution Redirected to Hook Function │ │ ↓ │ 6. CallOriginal() Temporarily Disables Breakpoint │ ↓ │ 7. Original Function Executes │ │ ↓ │ 8. Breakpoint Re-enabled#callstackspoofing #edr
"A" * 524 + "BBBB"یا به شکل هگز:
0x42424242حالا این ورودی رو به برنامه میدید اگه همه چیز درست باشه توی debugger میبینید:
EIP = 0x42424242 (32 بیت)یا RIP شامل همون مقدار روی 64 بیت اگه کارایی که کردید درست بود کنترل EIP/RIP رو گرفتید چند حالت وجود داره: برنامه قبلش کرش میکنه احتمالاً: Offset اشتباهه یا یه چک امنیتی قبل از رسیدن به RIP فعال میشه مقدار RIP تغییر نکرد یعنی: داده ی شما به اون رجیستر نرسیده یا overflow روی یه بافر دیگه اتفاق افتاده فقط کرش بدون کنترل یعنی کرش دارید ولی کنترل ندارید این فرق داره با exploit واقعی تفاوت 32 بیت و 64 بیت اینجا مشخص میشه روی 32 بیت: EIP مستقیم با 4 بایت پر میشه کنترل گرفتن خیلی واضح تره روی 64 بیت: RIP معمولا کامل overwrite نمیشه باید با stack alignment RSP و sometimes partial overwrite کار کنید اینجا اکسپلویت نویسی جدیتر میشه چرا اینا مهمن: میتونید بپرید به: شلکد تابع system gadget های ROP یا حتی فقط اجرای یه تابع ساده رو تست کنید ولی بدون کنترل RIP/EIP هیچکدوم معنی نداره پیدا کردن Offset کافی نیست باید ثابت کنید که واقعا میتونی مقدار EIP یا RIP رو خودت تعیین کنید وقتی دیدید مقداری که میخاید داخل RIP نشسته یعنی CPU کاملا تحت کنترلتون قرار گرفته این فرق بین کرش ساده و اکسپلویت واقعیه Real EIP/RIP Control The moment you make sure the CPU is doing exactly what you want So far: You crashed the program You found the exact offset What is EIP/RIP control? That is, you can determine where the CPU will execute next If you can fill in the value of EIP on 32 bits or RIP on 64 bits yourself, that means you have control over the execution flow Simple control Let's assume Offset = 524 We create a simple payload:
"A" * 524 + "BBBB"Or in hex:
0x42424242Now you will see this input to the program If everything is correct, you will see in the debugger:
EIP = 0x42424242 (32 bits)Or RIP contains the same value on 64 bits If what you did was correct You have taken control of EIP/RIP There are several cases: The program crashes before Probably: The offset is wrong Or a security check is activated before reaching RIP The RIP value has not changed That is: The data You didn't reach that register Or an overflow occurred on another buffer Just an uncontrolled crash That means you have a crash but no control This is different from a real exploit The difference between 32-bit and 64-bit is clear here On 32-bit: EIP is filled directly with 4 bytes Taking control is much clearer On 64-bit: RIP usually cannot be completely overwritten You have to work with stack alignment RSP and sometimes partial overwrite Here is where exploit writing gets more serious Why these are important: You can jump to: Shellcode System function ROP gadgets Or even just test the execution of a simple function But without RIP/EIP control, none of that makes sense Finding Offset is not enough, you have to prove that you can actually set the EIP or RIP value yourself. When you see the value you want sitting in RIP, you have full control over the CPU Taken This is the difference between a simple crash and a real exploit @reverseengine
a + i آدرس a + i * sizeof(type)پس:
double arr[10];و:
arr + 1یعنی:
arr + (1 * 8)نه 1 بایت 8 بایت همین موضوع برای باگ های زیر مهمه:
Out-of-bounds read/write Heap corruption InfoLeakPointer Arithmetic The most important thing for Exploit:
a + i Address a + i * sizeof(type)So:
double arr[10];And:
arr + 1That is:
arr + (1 * 8)Not 1 byte, 8 bytes The same thing is important for the following bugs:
Out-of-bounds read/write Heap corruption InfoLeak@reverseengine

Ko'rish tajribangizni yaxshilash uchun cookie fayllaridan foydalanamiz.
«Hammasini qabul qilish» tugmasini bosib, siz cookie fayllaridan foydalanish siyosatiga rozilik bildirasiz.