• XSS.stack #1 – первый литературный журнал от юзеров форума

Bypass AV/EDR with Safe Mode

blackhunt

(L2) cache
Пользователь
Регистрация
10.05.2023
Сообщения
334
Решения
8
Реакции
337
Guess what might not be running in safe mode? An AV/EDR. Also, attackers do NOT need to be physically in front of the machine to run in safe mode. I learned about this technique reading about snatch ransomware. Here is the article. I learn a lot from reading malware walkthroughs.

Here is I check if a security product is running in safe mode.

Github Source

to c:\users\public

1698089806985.png


Here is a quick look at the code. In main it checks if it is running in safe mode. If it is then it will try to figure out the security product and check if it is running.

1698089838710.png


After that, it writes the output to a file in c:\users\public and removes safeboot and restart the machine.

1698089874177.png


Here is how I Compile/Run it. I find my csc.exe so I can compile the code (under c:\windows\microsoft.net). In my case, it is under the 4.0.30319. Yes, I need to upgrade my lab 😊

1698089952759.png

Once the file is compiled I run the Doit.bat file as admin. I need to run Doit.bat file as ADMIN to create the service, modify the registry keys that are needed to run the service in safe mode and boot it into safe mode.

It is hard coded to look in the C:\users\public folder. All this does is creates a service and modifies the registry keys needed for the service to run in safe mode then reboots the machine in safe mode.

1698089976676.png


When I run the batch file, here is the output. I am a little lazy with this screen shot I did not delete my service before I took it 😊. Here is the batch file running.

1698090000348.png


It then tells the machine to boot into safe mode and restarts

1698090034385.png


When it comes up, I let it sit there a moment. It runs the exe I created to check if the security tools are running, removes safeboot option and then restarts. It takes about 30 seconds on my machine.

1698090060749.png


After it reboots out of safe mode, I log back in and I see the file it wrote here. This lets me know what security product I have and if it is running. The results below are for defender. EDR vendor results are much more interesting.

1698090159874.png


Finally, I run undoit.bat so I can remove the service I created and remove the registry key.

1698090204027.png


I have used this technique to dump LSASS in safe mode. If I remember correctly, I ran lazagne in safeboot with this technique too. It could be used to hide anything.

Detection:

· Look for these any change to these registry keys below this.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SafeBoot

· Keep an eye on BCDEdit and other ways of programmatically booting a machine into safe mode

· Consider checking if your EDR runs in safe mode. If it doesn’t, check with your vendor to see what they recommend to detect this technique.
 

Вложения

  • 1698089901206.png
    1698089901206.png
    21.5 КБ · Просмотры: 16
  • 1698090128109.png
    1698090128109.png
    66.7 КБ · Просмотры: 16


Напишите ответ...
  • Вставить:
Прикрепить файлы
Верх