神刀安全网

Ransomware in your inbox: the rise of malicious JavaScript attachments

Abot, also known aszombie malware, usually sits quietly on your computer and waits for crooks to send it commands from afar, for example todeliver spam or to click on fraudulent ads.

RATs, or Remote Access Trojans , are similar to bots, but their main purpose is to keep out of sight while criminals dig around on your computer, stealing files or tapping into your webcam for their own creepy reasons.

Banking malware likeDridex also likes to go unnoticed, sneakily stealing your banking or email passwords so the crooks can raid your accounts.

But nothing quite grabs your attention like ransomware.

Ransomware generally strikes fast and hard, scrambling your files, keeping only one copy of the decryption key, and offering to let you buy your data back, typically for a few hundred dollars.

As we’ve explained before, the crooks responsible for ransomware sometimes make mistakes in how they do the encryption, so you can unscramble your files without paying up.

Unfortunately, the main families of ransomware we’ve seen in the past few months areLocky,TeslaCrypt andCryptoWall, and it’s as good as impossible to unscramble locked files without buying back the key from the criminals.

In other words, prevention is a lot better than cure.

You not only save yourself a big dollop of time and money, but also avoid having to negotiate with the crooks, which is an odious enough prospect even if you can afford the extortion payment.

How ransomware arrives

Ransomware, like any malware, can enter your network and infect your computer infdan many ways, including onUSB devices, via booby-trapped websites , and even on the coat-tails of an existing malware infection .

(If you’re already infected with aRAT or azombie, crooks can easily instruct your computer to download and install additional malware, such as ransomware.)

However, most ransomware these days arrives in some sort of email attachment, along with a message that encourages you to open the file and look at it.

Ransomware crooks have learned that keeping it simple works best, so they generally stick to messages that look unexceptionable to both home users and businesses, like these recent examples:

Ransomware in your inbox: the rise of malicious JavaScript attachments

Ransomware in your inbox: the rise of malicious JavaScript attachments

Ransomware in your inbox: the rise of malicious JavaScript attachments

Booby-trapped attachments

Until the end of 2015, most of the ransomware enquiries received by Sophos involved emails containing Word documents .

We’ve encouraged you many times to take care with unsolicited document attachments, particularly those that ask you to enable a Microsoft Office feature calledmacros.

Macros are special programs that you can embed in Office files, making those filesdangerous when received from untrusted senders.

The good news is that the effectiveness of malware that relies on Word macro programs seems to be falling.

More and more of you have become rightfully suspicious of documents that start by instructing you to turn on macros, which is the same as telling you to turn off an important security feature.

The bad news is that the crooks are increasingly turning to JavaScript attachments instead.

In the above sample emails, the attached ZIP files, when opened, contained files with the extension .JS , rather than document files ending in .DOC or .RTF .

Because Windows doesn’t show you file extensions by default, you’ll probably see something like this once you’ve opened a ZIP attachment containing a JavaScript file and browsed to the folder where the files were extracted:

Ransomware in your inbox: the rise of malicious JavaScript attachments

As you can see, the default Windows icon for scripts such as .JS files is a stylised scroll of paper, still crudely rendered at the low resolution of a decade or more ago.

That’s meant to reflect that scripts are written as plain old text, rather than compiled into illegible binary data like programs in C, C++ or Delphi.

Unfortunately, combined with the missing extension, the I-am-a-text-file icon gives the impression that JavaScript files ought to be safe to launch, much like clicking to open a file called README.TXT in good old Notepad.

As you can see in the bottom right of the screenshot above, the crooks often add a double extension to malware filenames, such as receipt.PDF.js .

When Windows suppresses the final extension, the second-last extension (which is really just part of the filename) gives the impression that the file is not what it seems, showing up simply as receipt.PDF .

JavaScript considered safe

You probably know that JavaScript is used to write programs, and that untrusted programs can be dangerous.

Nevertheless, you’d also be forgiven for assuming that the risk of opening a .JS attachment is smaller than opening a document and turning on macros.

After all, JavaScript inside email messages has been disabled by default for years in all major email programs, so emailed JavaScript ought to be safe.

And you open JavaScript from websites all the time in your browser, but the risk is mitigated by safeguards built into the browser itself.

Notably, a security feature known as theSame Origin Policy means that a .JS file in your browser can only download additional files from the website it came from – and in the case of JavaScript from an email, there is no associated website to connect back to.

Also, browser JavaScript is constrained to run only inside the browser, so it can’t read data from your hard disk, let alone write new files and then load them as Windows applications.

Unfortunately, once a .JS file has been saved to your hard disk, Windows will run it by default outside your browser, using a system component called WSH, short for Windows Script Host .

A standard system program called WScript.exe (or its companion, CScript.exe , for command-line scripts with no graphical interface) will load your script, feed it into WSH, and then run it with all the power that a regular executable program would enjoy.

In this example, taken from one of the attachments in the emails above, the lines containing calls to a special WSH function called WScript.CreateObject() .

This WSH function allows the malware author to create network connections to a list of servers, to request and retrieve web content, and to save and run a downloaded ransowmare executable:

Ransomware in your inbox: the rise of malicious JavaScript attachments

Then the malware creates a file called DECRYPT.TXT to tell you how to buy back your scrambled files:

Ransomware in your inbox: the rise of malicious JavaScript attachments

Given that .JS files are stored as plain text, you might imagine that dangerous code like the scripts above would be easy to spot.

Unfortunately, text programs are also easy for programs themselves to spit out.

Hundreds of different tricks can be used by criminals to produce JavaScript malware that is hard to follow when you look at it statically, but nevertheless unscrambles itself correctly at runtime.

For example, the three attachments in the above emails all made use of a JavaScript function called String.fromCharCode() that allows you to use ASCII digits to represent characters.

(Turning text into numbers makes it easy to hide text strings such as URLs, or to disguising program fragments that make suspicious calls to the WScript.CreateObject() function.)

You can use String.fromCharCode(34) to represent a double quote character (“), which is a handy trick when you need to include a quote mark inside a text string that is itself enclosed in double quotes.

One malware sample does it like this:

Ransomware in your inbox: the rise of malicious JavaScript attachments

But the other two use completely different, though equally peculiar, ways of calling the same function:

Ransomware in your inbox: the rise of malicious JavaScript attachments

Ransomware in your inbox: the rise of malicious JavaScript attachments

What to do?

  • To defend against ransomware in general , see our article How to stay protected against ransomware .
  • To protect against JavaScript attachments , tell Explorer to open .JS files with Notepad by default. (See below.)
  • To protect against misleading filenames , tell Explorer to show you files with their extensions. (See below.)

If you’re a Sophos customer, you can also protect against outside-the-browser script malware by blocking the Windows Script Host programs WScript.exe and CScript.exe. Use Sophos Endpoint Security’sApplication Control feature to block Microsoft WHS Cscript and Microsoft WSH WScript under the application type Programming/Scripting tools .

HOW TO TELL EXPLORER TO OPEN .JS FILES WITH NOTEPAD

Right click on a .JS file and then click on: Open with | Choose another app | More apps ↓

Ransomware in your inbox: the rise of malicious JavaScript attachments

Select Notepad and then turn on Always use this app to open .js files :

Ransomware in your inbox: the rise of malicious JavaScript attachments

Note that this doesn’t disable the Windows Script Host altogether.

If you really need to run a local JavaScript file, you can save it to disk and then either:

  • Right click in Explorer and use Open with to launch it with the Script Host.
  • Open a command prompt and run the script with > wscript filename.js .

HOW TO TELL EXPLORER TO SHOW FILE EXTENSIONS

Click on the View menu and turn on the tick-box labelled File name extensions :

Ransomware in your inbox: the rise of malicious JavaScript attachments

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » Ransomware in your inbox: the rise of malicious JavaScript attachments

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址