IBM TechXchange Korean CyberSecurity User Group (한국 사이버보안 사용자 그룹)

 View Only

디스코드 C2(C&C) 위협여부 자가진단

By Gwibin Im posted Mon February 20, 2023 04:18 AM

  


디스코드 C2(C&C) 위협여부 자가진단 / Self-Checkout This Discord C2

2022년 11월 유럽의 셀프계산대에서 일어난 사고를 조사하는 과정에서, IBM Security X-Force 팀은 공격자들이 디스코드 메세지안 C2(Command&Control) 를 도입하는 새로운 기술이 사용되었음을 발견하였습니다. 디스코드는 유저들이 관심을 갖는 커뮤니티를 만들고, 참여할 수 있게 해주는 대화, 목소리, 영상 서비스입니다. 디스코드는 그 소프트웨어 자체가 악의적인 용도가 없을지라도, 공격자들이 멀웨어와 트로이원격접속 (RATs)와 같은 C2 를 피해자들에 심기 위해서 사용해 왔습니다. 디스코드 C2의 본래의 봇 기능을 이용하여 진행된 X-Force 팀의 첫번째 피해사례 케이스에 대해서 이야기 해보려 합니다.

In November 2022, during an incident investigation involving a self-checkout point-of-sale (POS) system in Europe, IBM Security X-Force identified a novel technique employed by an attacker to introduce a command and control (C2) channel built upon Discord channel messages. Discord is a chat, voice, and video service enabling users to join and create communities associated with their interests. While Discord and its related software are not malicious, Discord has been leveraged by threat actors to deliver malware and remote access trojans (RATs) as a command and control (C2) channel. This is the first instance X-Force has encountered a Discord C2 channel using the native Discord bot capabilities.



[ 최초 접근방식 / Initial Access ]

X-Force는 POS 네트워크에서 발견된 게이밍 트래픽이 증가하는 것에 대해 경고하는 것에서 처음 이 활동을 발견하였습니다. X-Force는 POS 시스템에 대한 분석을 하였고, C2와 연결하기 위해서 만들어진 자바기반의 디스코드 봇을 발견하였습니다. 이 봇은 시스템에서 데이터를 모아서 추출하는 것을 수행합니다. X-Force의 조사를 통해서, USB포트로 POS시스템에 연결되는 P4wnP1 USB 공격플랫폼을 구동하는 라스베리 PI Zero 디바이스를 이용하였으며, 이를 통해 POS 시스템에 처음 접근시도가 이루어 졌다는 사실을 발견하였습니다.

X-Force was first notified of the activity as part of an escalation of a network-based alert for gaming traffic detected on the POS network. X-Force performed an analysis of the POS system and discovered a JavaScript-based Discord bot designed to act as a command and control (C2) broker with capabilities to execute commands and collect and exfiltrate data from the system. Through X-Force’s investigation, it was discovered that initial access to the POS system was achieved through the introduction of a Raspberry PI Zero device running the P4wnP1 USB attack platform connected to the POS system via a USB port.





자바스크립트로 작성된 디스코드 봇은 node.js 모듈로 로봇이 자율적으로 API 키를 이용하는 디스코드 API와 통신을 할 수 있게 하였습니다. 시작할 때에는 로봇들이 API 키를 이용하여 디스코드 API에 연결을 설정하고, "guild id"와 "channel id"로 로봇들이 특정 채널의 새로운 메시지를 확인하도록 하였습니다.

디스코드 봇은 데이터 추출과 명령실행을 하기 위한 2개의 주요 기능을 보유하고 있습니다.

채널에 새로운 메시지가 포스팅 되면, 디스코드 봇은 메시지를 모아 처리를 합니다. 각 메시지는 암호화 되어서 포함된 명령들이 실행이 될 수 있는 커맨드 기능으로 보내집니다.

신규 메시지에 대한 디스코드 채널을 관찰하는 동시에, 로봇은 하드코드된 임시 폴더에서 ".dat" 확장자로 된 신규 파일이 있는지를 반복적으로 확인합니다. 신규 ".dat" 파일이 발견이 될 때, 로봇은 64기반으로 인코딩 및 암호화된 분리된 파일을 분리합니다. 이 나누어진 파일들은 개인 메시지로 디스코드에 보내어 집니다.



The Discord bot, written in JavaScript, leveraged a node.js module enabling the bot to communicate autonomously to the Discord API using an API key. Upon startup, the bot establishes a connection to the Discord API using the API key, ”guild id,” and “channel id” enabling the bot to monitor the specified channel for new messages.

The Discord bot contains two main functions leveraged for command execution and data exfiltration.

As new messages are posted to the channel, the Discord bot collects and processes the messages. Each message is decrypted and passed off to the command function where the instructions contained in the message will be executed.

In parallel to monitoring the Discord channel for new messages, the bot checks a hardcoded temp folder on a loop for new files with a “.dat” extension. When a new “.dat” file is detected, the bot chunks the file into base64 encoded and encrypted segments. The chunked files are then sent to the Discord channel as individual messages.


Node.js 를 통한 디스코드 봇 명령실행 / Discord Bot Command Execution via Node.js:




디스코드 봇의 데이터 추출 기능 / Discord Bot Data Exfiltration Function:




[ 정보탈취 이후 / Post-Exploitation ] 

일단 공격자들이 POS 시스템의 디스코드 봇으로 C2 를 실행하면, 공격자들은 신분정도를 획득하고 내부이동 활동을 하는데 이용이 되는 탈취이후의 툴들을 다운로드 하는데 봇을 활용합니다.

X-Force 는 공격자들이 원격 호스팅서비스로 WinRAR와 Curl 유틸리티를 다운로드 하는 자바스크립트 파일 2개를 업로드 하였던 것을 확인할 수 있는 증거를 발견했습니다. 공격자들은 WinRAR와 Curl 를 사용하여 탈취이후를 위한 툴셋이 들어있는 RAR아카이브를 다운로드 및 추출하였습니다.

디스코드 봇의 외부에서 POS네트워크에 접속을 유지하기 위해서, 공격자들은 Ngrok 와 OpenSSH를 활용하여 추가적인 백도어를 설치했습니다. X-Force팀은 POS 시스템에서 부터 자바스트립트 파일을 복원하였습니다. 이 과정에서 공격자들이 RDP를 통한 시스템 접근을 위해, Open SSH서버를 설치를 설치하여 SSH에 접근 및 Ngrok과 통신을 한다는 사실을 알게 되었습니다.

Once the attacker had established a C2 channel with the Discord bot on the POS system, the attacker leveraged the bot to download post-exploitation tools to facilitate credential harvesting and lateral movement activities.

X-Force uncovered evidence indicating the attacker uploaded two additional JavaScript files that downloaded the WinRAR and Curl utilities from a remote hosting service. The attacker then used Curl and WinRAR to download and extract RAR archives containing the post-exploitation toolset.

To maintain access to the POS network outside of the Discord bot, the attacker deployed additional backdoors leveraging Ngrok and OpenSSH. X-Force recovered script files from the POS system showing that the attacker installed an OpenSSH server to enable SSH access and set up a Ngrok connection to access the system via RDP.



[ 신분정보 수집 및 내부이동 공격 / Credential Harvesting and Lateral Movement ]

마이크로소프트 윈도우에서 신분정보는 LSASS 프로세스 (Local Security Authority Subsystem Service process) 메모리 공간에 저장이 됩니다. 공격자들은 LSASS 프로세스 메모리에 신분정보에 접근할 수 있게 하는 파일들을 퍼붓는 방식인 "프로세스 덤핑" 을 하기 위한 목적으로 LSASS 프로세스를 공격대상으로 삼습니다. X-Force 가 조사를 진행하는 동안, 공격자들 Sysinternals 유틸리티 ProcDump를 활용하는 증거들이 복원이 되었습니다. 이는 LSASS에 메모리 덤프 파일을 만들 어 냈습니다.

LSASS 데이터에 접근을 하여, 공격자들은 네트워크에 있는 모든 POS 시스템에 대한 공유로컬 관리자계정의 비밀번호를 복구할 수 있었습니다. 관리자의 계정을 모으고 난 후, 공격자들은 Sysinternals PsExec를 이용하여 내부이동을 시도하였습니다.

In Microsoft Windows, credentials are stored in the memory space of the LSASS process. Attackers target the LSASS process for “process dumping,” which enables the attacker to dump the contents of the LSASS process’ memory to a file that enables the attackers to access the credential data. During X-Force’s investigation, evidence was recovered indicating the attacker leveraged the Microsoft Sysinternals utility ProcDump to create a memory dump file of the Local Security Authority Subsystem Service process (LSASS).

Through accessing the LSASS data, the attacker was able to recover the password for the shared local administrator account for all the POS systems within the network. Following the collection of an administrator account, the attacker attempted to move laterally leveraging Sysinternals PsExec.




[ 공격행위의 목적: 데이터 탈취와 암호화폐 채굴 / Actions on Objectives: Exfiltration and Crypto Mining ] 

X-Force는 POS 시스템 안의 디스코드 봇으로 탈취가능한 데이터를 발견했습니다. 여기에는 POS 소프트웨어, POS 소프트웨어 드라이브, 운영시스템 드라이브, 관리 스크립트, 시스템 백업등이 포함되었습니다. X-Force는 공격자들이 POS 소프트웨어안에서 운영되고 있는 고객 및 송금 데이터에 접근하기 보다는, POS 소프트웨어 그 자체를 추출하고 모으는데 집중 하였다는 증거를 찾을 수는 없었습니다.

비활동기간 이후에 공격자들은 XMRig 크립토마이닝 소프트웨어를 사용하였으나 X-Force는 공격자들이 이 부가적인 소프트웨어를 사용하였다는것을 발견할 수 없었습니다.

  X-Force identified data staged for exfiltration through the Discord bot on the POS system that included copies of the POS software, POS software drivers, operating system drivers, administrative scripts, and system backups. X-Force did not uncover any evidence that the attacker was able to access any of the payment or customer data running on the POS software and instead was focused on collecting and exfiltrating the POS software itself.

  Following a period of inactivity, the attacker introduced the XMRig crypto mining software, however X-Force was unable to identify any evidence the miner software was ever used by the attacker.



[ 디스코드 봇 탐지기회 / Detection Opportunities for Discord Bot ]

네트워크 텔레미트리: 디스코드 API와 네트워크 통신하는 것에 대한 경고를 발견하는데 활용이 됩니다. POS 네트워크 안에 “discord.com/api” 를 포함하는 URL과의 연결을 찾을 수 있습니다.

파일 모니터링: POS 시스템 안에 있는 server.js, discord.min.js, discordapierror.js  에 대한 활동파일에 대한 경고를 찾을 수 있습니다.

프로세스 실행: POS 시스템 안에 node.exe를 보유하고 있는 프로세스 실행 이벤트에 대한 경고를 찾을 수 있습니다.

Network Telemetry: Leverage network telemetry to search for or alert on network communications to the Discord API by searching for connections to URLs containing “discord.com/api” on point-of-sale networks.

File Monitoring: Leverage file monitoring to search or alert on file write activities for server.js, discord.min.js, and discordapierror.js on point-of-sale systems.

Process Execution: Leverage process execution data to search for or alert on process execution events containing node.exe on point-of-sale systems.



[ 탈취 이후 탐지기회 / Detection Opportunities for Post-Exploitation ]

네트워크 텔레미트리: POS 네트워크 안에 인터넷 라우팅 소스  NGrok, SSH 와 네트워크 통신에 대한 경고를 찾을 수 있습니다.

파일 모니터링: POS 시스템 안에 있는 sass.dmp, security.hve, system.hve  에 대한 활동파일에 대한 경고를 찾을 수 있습니다.

프로세스 실행: POS 시스템 안에 curl.exe, procdump.exe, tcpdump.exe, ngrok.exe를 보유하고 있는 있는 프로세스 실행 이벤트에 대한 경고를 찾을 수 있습니다.

Network Telemetry: Leverage network telemetry to search for or alert on network communications to NGrok and SSH to internet routable resources from point-of-sale networks.

File Monitoring: Leverage file monitoring to search or alert on file write activities for lsass.dmp, security.hve, and system.hve on point-of-sale systems.

Process Execution: Leverage process execution data to search for or alert on process execution events containing curl.exe, procdump.exe, tcpdump.exe, and ngrok.exe on point-of-sale systems.



[ 예방 / Prevention ] 

X-Force 는 지워질수 있는 미디어와 USB 아운팅이이 POS 시스템을 연결해제할 수 있다고 이야기 합니다. 관리 또는 유지보수가 필요할 때, X-Force는 기업들이 관리작업을 끝낼 수 있는  시간동안만 일시적으로 지워질 수 있는 미디어 접근만을 허용할 것을 권장합니다. 

X-Force recommends that removable media and USB mounting be disabled on all point-of-sale systems. When administrative or maintenance is required, X-Force recommends organizations design a process to temporarily allow removable media access only for the time to complete the administrative work



[ 하드워어에 대한 추가준비 / Hardware Additions Preparedness ]

보호되지 않은 기업 시스템에 물리적인 접속을 하는 공격자들은 높은 수준의 공격을 시도합니다. 왜냐하면 물리적인 접근은 일반적으로 원격공격시도를 막기 위해서 고안되었던 많은 보안 통제들을 한번에 통과할 수 있게 하기 때문입니다. X-Force는 기업을 악의적인 하드웨어 공격으로 부터 예방하고, 발견하고, 대응하는 전략을 수립하여, 위협관리에 성공적으로 이루어 낼 수 있게 합니다.

만약 귀사가 하드웨어 공격을 어떻게 예방하고, 발견하고, 대응하는 방법에 대해 알고싶어 한다면, X-Force는 전세계 적으로 귀사가 전체 위협환경에 대한 완벽한 준비를 할 수 있도록 적극적인 서비스를 제공 하기에 IBM으로 문의 주시기 바랍니다. 

Attackers with physical access to unsecured enterprise systems introduce a high level of risk to an organization because physical access enables the attacker to bypass many security controls that are normally designed to prevent a remote attack. X-Force recommends organizations implement a prevention, detection, and response strategy with regard to malicious hardware additions to achieve a holistic approach to risk management.

If you are interested in learning more about how to prevent, detect, and respond to hardware additions within your organization, X-Force provides world-class proactive and reactive services to ensure your organization achieves complete preparedness for the entire threat landscape.

https://securityintelligence.com/posts/self-checkout-discord-c2/

0 comments
21 views

Permalink