본문 바로가기
OffSec

[Blue Teams Academy] 모듈 22 - Azure Sentinel - 프로세스 중공(T1055.012) 분석

by 10th doctrine 2021. 3. 19.
728x90

이 글에서 우리는 프로세스 할로우닝이라는 기술을 탐구할 것이다.

검출 부분에 뛰어들기 전에 몇 가지 중요한 용어들을 탐구하는 것이 필수적이다.

MITRE에 따르면:

"프로세스 공동화(T1055.012)는 일반적으로 정지 상태에서 프로세스를 만든 다음 메모리를 매핑 해제/할로우하는 방식으로 수행되며, 이는 악성 코드로 대체될 수 있다. 프로세스 기본 스레드를 일시 중단하는 플래그를 포함하는 CreateProcess와 같은 기본 Windows API 호출을 사용하여 공격 대상자 프로세스를 만들 수 있다. 이 시점에서 프로세스는 ZwUnmapViewOfSection 또는 NtUnmapViewOfSection과 같은 API 호출을 사용하여 매핑 해제된 후 주입된 코드에 다시 할당하고 VirtualAllocEx, WriteProcessMemory, SetThreadContext를 통해 재개할 수 있다.각각 스레드"

프로세스 공동화에 대해 자세히 알아보려면 Elastic: https://www.elastic.co/blog/ten-process-injection-techniques-technical-survey-common-and-trending-process에서 이 작품을 확인해 보십시오.

이 기술은 듀크와 트릭봇과 같은 적들에 의해 널리 사용된다.

Specterops의 Jonathan Johnson David Polojac의 다음 작품들은 공정 공동화의 탐지 엔지니어링 측면에 깊이 파고든다.

탐지를 위해 우리는 Azure Sentinel과 sysmon을 사용할 것이다. Sysmon은 여기에서 다운로드할 수 있다.

https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon

설치하려면 관리자 권한으로 다음 명령을 실행하십시오.

sysmon.exe -accepteula -i <CONFIG_FILE_HERE>

ION-스톰에서 다음 구성 파일을 사용할 수 있다.

https://github.com/ion-storm/sysmon-config

sysmon 이벤트를 탐색하려면 Windows 이벤트 뷰어: 응용 프로그램 및 서비스 로그 -\> Microsoft -\> Windows -\] Sysmon -\> Operational을 사용하십시오.

Sysmon 이벤트를 Azure Sentinel로 보내려면 새 커넥터(보안 이벤트)를 배포하여 Windows 이벤트 로그로 시작하십시오.

에이전트를 설치하십시오.

이제 Settings -\] Workspace Settings -\] Advanced Settings -\] Data -\>Windows Event Logs로 이동하여 다음 이벤트 로그 이름을 추가하십시오. Microsoft-Windows-Sysmon/Operational

이벤트를 확인하려면 Azure Sentinel Logs 섹션으로 이동하여 다음 쿼리를 실행하십시오.

Event | where Source == "Microsoft-Windows-Sysmon"

EventData 필드는 구문 분석 및 필터링되지 않음. 따라서 Azure Sentinel sysmon 파서 중 하나를 사용하는 것이 좋다: https://github.com/Azure/Azure-Sentinel/tree/master/Parsers/Sysmon

파서를 사용하려면 파일 내용을 로그 분석에 복사하여 함수로 저장하십시오(예: Sysmon_Parser). 이제 이벤트의 구문 분석:

API와 Events의 상관 관계를 분석하려면, 더 나은 가시성을 위해 매핑 단계가 필요하다. 다행히도 다음 시트를 사용할 수 있다.

매핑에 대한 자세한 내용은 다음에서 확인하십시오. 알 수 없는 것들 찾기

이제 우리는 sysmon Event를 알게 되었다.볼 아이디

다음 poc를 이용하여 공정 공동화 기법을 수행해 봅시다: https://github.com/m0n0ph1/Process-Hollowing

Azure Sentinel 로그 콘솔로 이동

Sysmon_Parser | where EventID in ("1","10") | project SourceImage, TargetImage, EventID, GrantedAccess

  • EventID 1: 프로세스 생성
  • EventID 10: 프로세스 액세스
  • 프로젝트 운영자: 인수에 지정된 열만 결과에 포함된다.

우리의 경우 조나단 존슨의 연구과정에 따르면 공동화에는 다음의 권리만 필요하지만 POC가 사용하는 접근권은 0x1fffffff로 PROCH_ALL_Access이다.

프로세스_VM_WRITE

프로세스_VM_Operation

프로세스_SUSPEND_RESUME

프로세스_CREATE_프로세스

 

더보기

Azure Sentinel: Process Hollowing (T1055.012) Analysis

In this article, we are going to explore a technique called Process Hollowing.

Before jumping into the detection part, it is essential to explore some important terminologies.

According to MITRE:

"Process hollowing (T1055.012) is commonly performed by creating a process in a suspended state then unmapping/hollowing its memory, which can then be replaced with malicious code. A victim process can be created with native Windows API calls such as CreateProcess, which includes a flag to suspend the processes primary thread. At this point the process can be unmapped using APIs calls such as ZwUnmapViewOfSection or NtUnmapViewOfSection before being written to, realigned to the injected code, and resumed via VirtualAllocEx, WriteProcessMemory, SetThreadContext, then ResumeThread respectively"

To learn more about Process hollowing, i highly recommend you to check this piece from Elastic: https://www.elastic.co/blog/ten-process-injection-techniques-technical-survey-common-and-trending-process

This technique is widely used by adversaries such as Duqu and TrickBot

The following pieces by Jonathan Johnson and David Polojac from Specterops deep dive into the detection engineering aspects of process hollowing

For the detection we are going to use Azure Sentinel and sysmon. Sysmon can be downloaded from here:

https://docs.microsoft.com/en-us/sysinternals/downloads/sysmon

To install it, run the following command as an administrator:

sysmon.exe -accepteula -i <CONFIG_FILE_HERE>

You can use the following config file by ION-STORM:

https://github.com/ion-storm/sysmon-config

To explore sysmon events, use Windows Event Viewer: Applications and services logs -\> Microsoft -\> Windows -\> Sysmon -\> Operational

To send sysmon events to Azure sentinel, deploy a new connector (Security Events) to start with Windows Event logs

Install the agent.

Now go to Settings -\> Workspace Settings -\> Advanced settings -\> Data -\> Windows Event Logs and add the following event log name: Microsoft-Windows-Sysmon/Operational

To check the events go to Azure Sentinel Logs section and run the following query:

Event | where Source == "Microsoft-Windows-Sysmon"

As you will notice the EventData fields are not parsed and filtered. Thus, it is recommended to use one of Azure Sentinel sysmon parsers: https://github.com/Azure/Azure-Sentinel/tree/master/Parsers/Sysmon

To use the parser, copy the file content in log analytics and save it as a function (e.g Sysmon_Parser). Now the events are well parsed:

To correlate APIs with Events, a mapping phase is needed for a better visibility. Thankfully, you can use these sheets:

More details about mapping can be found here: Uncovering The Unknowns

Now we know what sysmon EventIDs to watch

Let's perform a process hollowing technique using the following poc: https://github.com/m0n0ph1/Process-Hollowing

Go to Azure Sentinel logs console

Sysmon_Parser | where EventID in ("1","10") | project SourceImage, TargetImage, EventID, GrantedAccess

  • EventID 1: Process Created
  • EventID 10: Process Accessed
  • The project operator: Only the columns specified in the arguments are included in the result.

In our case, the access rights used by the POC is 0x1fffff which is PROCESS_ALL_ACCESS even though according to Jonathan Johnson's research process hollowing only needs the following rights:

PROCESS_VM_WRITE

PROCESS_VM_OPERATION

PROCESS_SUSPEND_RESUME

PROCESS_CREATE_PROCESS

 

 

※ 출처 : Blue Teams Academy | www.blueteamsacademy.com/processhollowing/

반응형

댓글