Shameless driver Loading Method

Source: Internet
Author: User

From: http: // www.debugman.com/read.php? Tid = 614

Method 1: replace win32k. sys
In the 2k3 system, ZwSetSystemInformation disables driver loading in user mode and only allows SMSS. exe to load win32k. sys. So we can use this feature:
1. SMSS. EXE Injection
2. Enable the SeLoadDriverPrivilege permission
3. Rename the original win32k. sys.
4. copy our driver to systemrootsystem32.
5. Load \ SystemRoot \ System32 \ win32k. sys in SMSS. EXE
6. Rename \ SystemRoot \ System32 \ win32k. sys
7. Rename the original win32k. sys file.

Method 2: exploit the vulnerability of a third-party driver
There should be a lot of such drivers. We can choose some drivers with large installation capacity to do this. For example, a famous anti-virus software has a local privilege escalation vulnerability... Once you get the ring0 permission and load it with ZwSetSystemInformation, everything is fine.

Method 3: infect the driver started with the System
This method is similar to virus infection, but it takes some PE knowledge to get control after the system restarts next time. I will not say much about it.

By the way, ZwSetSystemInformation can also be used to create a Device. Because the DriverObject pointer sent to DriverEntry when ZwSetSystemInformation is loaded is incorrect, we cannot use it to create a Device, however, we can assign a DriverObject to create it, as shown below:

NTSTATUS
DriverEntry (
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
NTSTATUS ntStatus = STATUS_SUCCESS;
UNICODE_STRING ntUnicodeString;
UNICODE_STRING ntWin32NameString;
PDEVICE_OBJECT deviceObject = NULL;
ULONG I;

DriverObject = ExAllocatePoolWithTag (NonPagedPool, sizeof (DRIVER_OBJECT), clAS); // allocate DriverObject

RtlZeroMemory (DriverObject, sizeof (DRIVER_OBJECT ));

RtlInitUnicodeString (& ntUnicodeString, NT_DEVICE_NAME );

NtStatus = IoCreateDevice (
DriverObject,
0,
& NtUnicodeString,
0x8800, // The device type must be custom
FILE_DEVICE_SECURE_OPEN,
TRUE,
& DeviceObject );

If (! NT_SUCCESS (ntStatus ))
{
Dbuplint ("Couldnt create the device object ");
Return ntStatus;
}

// Note that you need to clear the INITIALIZING flag by yourself. Otherwise, the setting cannot be enabled.
ClearFlag (deviceObject-> Flags, DO_DEVICE_INITIALIZING );

DriverObject-> MajorFunction [IRP_MJ_CREATE] = CreateClose;
DriverObject-> MajorFunction [IRP_MJ_CLOSE] = CreateClose;

// Note: You must assign a DispathRoutine to IRP_MJ_CLEANUP; otherwise, the device will be suspended when it is disabled.
DriverObject-> MajorFunction [IRP_MJ_CLEANUP] = CreateClose;

DriverObject-> MajorFunction [IRP_MJ_DEVICE_CONTROL] = DeviceControl;

// Note that the connection must be a Global symbolic connection; otherwise, the connection will disappear after the program exits.
RtlInitUnicodeString (& ntWin32NameString, L "\ DosDevices \ Global \ RkrTest ");

NtStatus = IoCreateSymbolicLink (
& NtWin32NameString, & ntUnicodeString );

If (! NT_SUCCESS (ntStatus ))
{
Dbuplint ("Couldnt create symbolic link "));
IoDeleteDevice (deviceObject );
}

Return ntStatus;
}

If you are happy, allocate more space and compress the OBJECT_HEADER. This prevents some software from failing to scan the DriverObject object header.

When using CreateFile, you should specify "\. \ Global \ SymbolLink" as follows"

What other shameless methods can we discuss?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.