I found a good method to completely clear DLL backdoors.

Source: Internet
Author: User

Backdoor! I believe this term will not be unfamiliar to you, but it will not be harmful to you. However, as people's security awareness gradually increases, the "strong support" of anti-virus software is added ", so that traditional webshells cannot hide themselves. Anyone with a little knowledge about computers knows how to "Check ports" and "view processes" to discover some "clues ". In this way, the process and port are hidden. This article takes "DLL principle" "DLL cleanup" "DLL prevention" as the topic and discusses it in an aim to allow everyone to "get started" with DLL backdoors without fear of DLL backdoors. Now, go to our topic.

1. DLL principles

1. Dynamic Link Library

The dynamic Link Library, short for ynamic Link Library, is used to provide extended functions for applications. To call a DLL file, an application needs to perform a "Dynamic Link" with it. From the programming point of view, the application needs to know the API function exported from the DLL file before calling. It can be seen that the DLL file itself cannot be run and needs to be called by the application. It is because the DLL file must be inserted into the memory module of the application during running, which means that the LL file cannot be deleted. This is caused by the internal mechanism of Windows: running programs cannot be closed. So the DLL backdoor is born from this!

2. DLL backdoor principles and features

Write a code that implements the backdoor function as a DLL file and insert it into an EXE file so that it can be executed. In this way, no process is required, and no corresponding PID Number exists, you can also hide it in the task manager. The DLL file itself is not much different from the EXE file, but must be called by the Program (EXE) to execute the DLL file. To execute a DLL file, you need to load the EXE file, but to load the DLL file, you need to know the entry function of a DLL file (both the export function of the DLL file). Therefore, according to the DLL file writing standard: EXE must execute the DLLMain () in the DLL file as the loading condition (like the mian () of EXE ()). There are basically two types of DLL backdoors: 1) Implement all functions in the DLL file; 2) Make the DLL into a Startup File and start a common EXE backdoors as needed.

Common compiling methods:

(1) There is only one DLL file

Enabled. What is Rundll32.exe? "Execute a 32-bit DLL file ". The internal implementation is the internal implementation of the dllfile. In this process, only rundll32.exe is available, and no DLL backdoor process is available. In this way, process hiding is realized. If you see multiple rundll32.exefiles in the system, you do not need to be alarmed. This shows how many DLL files are started with rundll32.exe. Of course, we can find all the DLL files executed by rundll32.exe from the locations where the system automatically loads them.

Now, I will introduce the rundll32.exe file, which means that the function is to call the dynamic link library through the command line. There is also a rundll.exe file in the system, which means to execute a 16-bit DLL file. Pay attention to it here. For more information, see the function prototype used by rundll32.exe:

Void CALLBACK FunctionName (

HWND hwnd,

HINSTANCE hinst,

LPTSTR lpCmdLine,

Int nCmdShow

);

The command line uses Rundll32.exe DLLname and Functionname [Arguments].
DLLname is the name of the DLL file to be executed, Functionname is the specific extraction function of the DLL file to be executed on the front, and [Arguments] is the specific parameter of the extraction function.

(2) Replace the DLL file in the system

This type of backdoor is more advanced than above. It makes the code that implements the backdoor function into a DLL file that matches the system, and changes the original DLL file name. When an application requests the original DLL file, the DLL backdoor starts a forwarding function and passes the "parameter" to the original DLL file; if you encounter a special request (such as a client), the DLL backdoor starts, starts, and runs. For such backdoors, all the operations are implemented in the DLL file to be the most secure, but there is a lot of programming knowledge and it is very difficult to write. Therefore, these types of backdoors generally make DLL files into a "start" file. In special cases (such as client requests), they start a common EXE backdoor; after the client ends the connection, stop the EXE backdoor, and then the DLL file enters the "break" status. It will not be started until the next client connection. However, with the introduction of Microsoft's "Digital Signature" and "file recovery" functions, such backdoors have gradually declined.

Tip:

In the WINNT \ system32 directory, there is a dllcache folder containing a large number of DLL files (including some important EXE files). After the DLL file is illegally modified, the system will recover the modified DLL file from here. If you want to modify a DLL file, you must first delete or rename the DLL file under the dllcache directory. Otherwise, the system automatically recovers.

(3) Dynamic embedded

This is the most common method for DLL backdoors. The significance is to embed the DLL file into the running system process. In Windows, each process has its own private memory space, but there are still various ways to enter the private memory space of its process to implement dynamic embedded. Because the key processes of the system cannot be terminated, such backdoors are very hidden and difficult to detect and kill. Common dynamic embedded systems include: "hook api", "Global HOOK", and "remote thread.

Remote thread technology refers to the process's memory address space by creating a remote thread in a process. When the exe (or rundll32.exe) creates a remote thread in the inserted process and commands it to execute a DLL file, our DLL backdoor will be mounted for execution, and no new process will be generated here, to stop the DLL backdoor, only the process linked to the DLL backdoor is terminated. However, if you are connected to key processes of some systems, you cannot terminate them. If you terminate the system processes, Windows will be terminated !!!

3. DLL backdoor startup features

The carrier EXE that starts the DLL backdoor is indispensable and important. It is called Loader. If no Loader is available, how can we start the DLL backdoor? Therefore, a good DLL backdoor will try its best to protect its Loader from being scanned and killed. The entity of the DLL backdoor still exists. 3721 network real name is an example, although it is not a "real" backdoor.
Ii. DLL cleanup

This section uses three well-known DLL backdoor examples: "SvchostDLL. dll" "BITS. dll" "QoServer. dll ". The manual cleanup method is described in detail. I hope that you will be able to use these three DLL backdoors flexibly without fear of DLL backdoors. In fact, it is relatively simple to manually clear the DLL backdoor. It is nothing more than making an article in the registry. For more information, see the following.

1, PortLess BackDoor

This is a very powerful DLL backdoor program, in addition to the Shell that can obtain the Local System permission, it also supports a series of functions such as "detecting clone accounts" "installing Terminal Services" (For details, refer to program help), applicable to systems such as Windows2000, xp, and 2003. The program starts up with svchost.exe. Normally, the port is not opened and you can perform reverse connections (the biggest feature). For hosts with firewalls, this function is far better.

Before introducing the cleanup, let's briefly introduce the key services of the system svchost.exe:

Svchost serves only as the service host and does not implement any functions. If Svchost is required to start the service, a service is implemented in the form of DLL. The Loader of the DLL directs to svchost. Therefore, when starting a service, svchost calls the DLL of the Service to start the service. The DLL file for starting a service using svchost is determined by the Parameters in the registry. There is a Parameters subkey under the service to be started, serviceDll indicates which DLL file is responsible for the service, and this DLL file must export a ServiceMain () function to support service tasks.

Haha! After reading the above theory, is it a bit blind (I am almost asleep)? Don't worry. Let's take a look at the specific content. First, let's take a look at the Parameters sub-keys in the Registry HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ RpcSs. The key value is % SystemRoot % \ system32 \ rpcss. dll. This indicates that when the RpcSs Service is started. Svchost calls rpcss. dll under the WINNT \ system32 directory.

Let's look at another example. The HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Svchost in the registry stores the groups started by Svchost and various services in the group, the netsvcs group has the most services. To start a service using Svchost, the service name will appear in HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Svchost. There are four methods to achieve this:

1. Add a new group and add the service name to the group.

2. Add a service name to an existing group.

3. directly use a service name in the existing group, but the service is not installed on the local machine

4. Modify the existing service in the existing group and point its ServiceDll to its own DLL backdoor.

The third method used by PortLess BackDoor I tested.
Now, after reading the above principles, I think we can think of our method of clearing PortLess BackDoor. Okay. Let's start now.

The Loader of the backdoor calls SvchostDLL. dll is inserted into the Svchost process. Therefore, we first open Windows Process Management 2.5 in the Windows optimization master to view the module information in the Svchost process. We can see that SvchostDLL. the dll has been inserted into the Svchost process. We can conclude that, there will be a new service in "Administrative Tools"-"services. The service name is IPRIP, started by Svchost, and-k netsvcs indicates that the service is included in the netsvcs Service Group.

Stop the service, open the Registry Editor (START-run -- regedit), and go to HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ IPRIP to view its Parameters sub-key. The key value svchostdll.exe of programkey is the Loader of the backdoor; the key value C: \ WINNT \ system32 \ svchostdll. dll of ServiceDll is the called DLL file, which is the DLL file of the backdoor. Now let's Delete the IPRIP subkey (or use SC to delete it), and then edit the netsvcs Service Group under HKEY_LOCAL_MACHINE \ SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Svchost, delete 49 00 70 00 72 00 69 00 70 00 00. Here the service name of IPRIP is used. Then exit and restart. After the restart, delete the backdoor file under the WINNT \ system32 directory.

2, BITS. dll

This is Rong GE's work, DLL backdoor, and SvchostDLL. the dll principle is basically the same, but here we use the fourth method described above, that is, "Modify the existing service in the existing group and point its ServiceDll to its own DLL backdoor ". To load. We still use Windows Process Management 2.5 to check whether bits. dll has been inserted into the Svchost process.

Okay. Now let's take a look at the specific clearing method. Because this backdoor is used to modify the existing service, but we don't know which service is modified, search for bits in the registry. dll, and finally found bits under HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ RasAuto. dll to view ServiceDll under the Parameters subkey. Its key value is C: \ WINNT \ system32 \ bits. dll. Originally, the backdoor replaced the original DLL file of the RasAuto service with bits. dll to implement automatic loading. Now, we can modify the ServiceDll key value to the original DLL file of the RasAuto service, that is, % SystemRoot % \ System32 \ rasauto. dll. Exit and restart. Then, delete bits. dll in the WINNT \ system32 directory.

3, NOIR--QUEEN

Slave is a key process of the system, so it cannot be terminated. Before introducing the cleanup, I will first introduce the lsass.exe process:

This is a local security authorization service, and it will generate a process for the authorized users using the Winlogon service. If the authorization is successful, Lsass will generate a user access token, use the token to start the initial Shell. Other user-initiated processes will inherit this token.

From the above introduction, we can see the importance of Lsass to the system. How can we clear it? See the following.

After the backdoor is successfully installed, a service named QoSserver is added to the service, and the QoSserver. dll backdoor file is inserted into the Lsass process, so that it can hide the process and start automatically. Now let's open the registry and go to HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ QoSserver, delete the QoSserver key directly, and restart. After the service is restarted, we will see that the QoSserver service is still running but not started. The category is automatic, when we change it to "disabled", we can see that the executable program of a service named appcpiis directed to qosserver.exe (I will discuss the cause later), as shown in Figure 11. Open the Registry again, go to HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ AppCPI, delete the AppCPI key, restart, delete the QoSserver, and finally Delete the backdoor file under the WINNT \ system32 directory.

This man and the backdoor "fought" for more than three hours and restarted N times. The reason is that, even if the QoSserver service is deleted, the backdoor is still running, and the QoSserver service in the service list is "Revived ". Later I learned the cause: After I deleted the QoSserver service and restarted it, I inserted it to the QoSserver In the Lsass process. the dll file restores the QoSserver service and generates another service, namely, AppCPI. Therefore, you must delete the AppCPI service in the Registry to clear the backdoor. From this we can see that the current backdoor protection measures are really a ring.

Note: After the QoSserver service is deleted and restarted, change the QoSserver startup category to "disabled". Otherwise, even if the AppCPI service is deleted, the QoSserver service runs again.
Iii. DLL prevention

After reading the above example, I think you have some knowledge about how to clear the DLL backdoor, but in reality, the DLL backdoor does not use the default file name, so you cannot be sure whether the DLL backdoor is in use. For DLL backdoors, the system32 directory is a good place, and most backdoors are the same, so pay attention to them here. Next I will introduce how to find the DLL backdoor. I hope it will help you.

1. After installing the system and all applications, back up the EXE and DLL files in the system32 directory: Open CMD, go to the WINNT \ system32 directory, and execute ir *. exe> exe.txt & dir *. dll> export), and use the: fc exe.txt exe0.txt> exedll.txt & fc dll.txt dll0.txt> export file. In this way, we can find multiple EXE and DLL files and determine whether the files are DLL backdoors Based on the file size and creation time.

2. Use a memory/module tool to view the DLL file called by the process, for example, Windows Process Management 2.5 in Windows optimization master. In this way, we can find out what DLL files are called by the process, and compare the results with the above FC command to further determine whether the DLL backdoor is in use. If you do not have an optimization master, you can use TaskList. This tool can also display the DLL file called by the process and the source code to facilitate modification.

3. for a common backdoor connection, you need to open a specific port, and the DLL backdoor is no exception. No matter how hidden it is, you need to open the port during the connection. We can use netstat-an to view all TCP/UDP port connections to find illegal connections. You usually need to know the port you open and understand the state attribute in netstat-. Of course, you can also use Fport to display the process corresponding to the port. In this way, you can see all the unknown connections and ports in the system.

4. regularly check the locations automatically loaded by the system, such as registry and Winstart. bat, Autoexec. bat, win. ini, system. ini, wininit. ini, Autorun. inf, Config. sys. The second step is to manage services and understand the default services of the system. You can use SC in Windows 2000 Server Resource Kit to delete problematic services. All of the above can be used to load the Loader of the DLL backdoor. If we delete the DLL backdoor Loader, how can this problem be solved? How does the DLL backdoor run ?!

By using the above method, I think most DLL backdoors can be "active". If we do more backups at ordinary times, it will get twice the result with half the effort in searching for DLL backdoors.

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.