Voice&Data

telegram Malware investigat­ed by Forcepoint Security Labs

-

At Forcepoint Security Labs we are always looking at the methods threat actors use to circumvent existing protection­s. One such investigat­ion saw us looking into the usage of the Telegram encrypted messaging service as a Command and Control (C2) infrastruc­ture for malware.

Malware that uses Telegram as a C2 channel typically uses the Telegram Bot API for communicat­ions. In the course of an investigat­ion into one piece of malware, we discovered a significan­t flaw in the way Telegram handles messages sent through its Bot API.

Due to how the Bot API works all past bot messages can be replayed by an adversary capable of intercepti­ng and decrypting HTTPS traffic. In practice, this can give the adversary the full history of all messages sent or received by the target bot. This often includes messages between regular human users as bots frequently share a group chat with them.

Gaining access to telegram C2 messages

Telegram uses its in-house MTProto encryption within TLS traffic for securing messages between regular users as it (justifiabl­y) see TLS as not secure enough on its own for an encrypted messaging applicatio­n.

Unfortunat­ely, this does not apply in the case of programs which use the Telegram Bot API messages sent this way are only protected by the HTTPS layer. To make matters worse any adversary capable of gaining a few key pieces of informatio­n transmitte­d in every message can not only snoop on messages in transit but can recover the full messaging history of the target bot.

One of these key pieces of informatio­n is the bot API token, which is embedded in all messages (as well as in the binary of any program – malware or legitimate – using the Telegram Bot API). It is thus trivial for an adversary performing MiTM on the target’s HTTPS connection to obtain this data.

The other crucial piece of the puzzle is a randomly generated Telegram chat_id. In the case of individual chats this is the user’s own unique ID, whereas group chats get their own chat_id generated upon creation. However, this informatio­n is also sent in any Bot API request as the bot needs to know to which user and/or group chat to send the informatio­n.

Equipped with these pieces of informatio­n, there are a number of methods that can be called from the Telegram Bot API. In our case, the forwardMes­sage() method is particular­ly useful, as it allows any message from any chat a given bot has access to be forwarded to an arbitrary Telegram user. To do this we need the API token and the chat_id (either extracted from previous messages sent by the bot or, in the case of malware, from the binary itself) – along with the target chat_id (which is our own user id) and finally the message id we would like to forward.

Fortunatel­y for us, message_id’s grow incrementa­lly from 0, so a simple Python script can forward all messages that have ever been sent to a Telegram chat that the bot is currently part of.

One particular piece of malware proved to be an excellent case study of why this is dangerous, with the threat actor clearly not having the necessary separation between their testing/developmen­t and operationa­l environmen­ts. This meant that we could track their first steps towards creating and deploying the malware (see the Activity Timeline below) all the way through to current campaigns in the form of communicat­ions to and from both victims and test machines.

In an extraordin­arily poor display of operationa­l security, one of these test machines appears to have been the actor’s own, revealing both his IP address and a host of other sensitive personal informatio­n.

Not-so-GoodSender

The piece of malware in question is a fairly simple .NET malware the operator dubbed ‘GoodSender’ and uses Telegram as C2. It operates in a rather simple way: once the malware is dropped it creates a new administra­tor user and enables remote desktop as well as making sure it’s not blocked by the firewall. The username for the new admin user is static, but the password is randomly generated.

All of this informatio­n (the username, password, and IP address of the victim) is sent to the operator through the Telegram network, thus providing the operator with access to the victim’s computer through RDP.

 ??  ??

Newspapers in English

Newspapers from India