How? by constantly applying important security patches. In this case, a patch for Microsoft Windows SMB Server (4013389) that has been published back in March 2017(!)
But what to do now ? Assuming you are a still unharmed windows user, don't wait - go to control panel/windows update and apply the recommended updates. On your day to day update routine, pay special heed to security updates and updates that are classified as important.
The second step you should take is make sure you have an AntiVirus software installed, make sure it is updated, and develop a routine of using it to scan you computer, at least on a weekly basis (preferably on a nightly basis). Some would also advise installing an anti ransomware software. I have provided a link (below, at the "useful links" section, but personally, I prefer a more general security solution.
A step that might specifically help with the "petya" threat", suggested by Israeli security expert Amit Serper, is creating an empty file with the name "perfc" without an extension, under your Windows folder (in most computers it is located at the C:\ drive). It is important to note that this solution will most likely cease to work if and when the creators of the ransomware update it, but I guess it can't hurt for the time being.
And last two steps that will most assuredly help in keeping you out of harm's away, if you adopt them:
1) Take care with the materials you allow into your digital world. Don't open documents, don't click links, don't install software, don't view movies, don't listen to music, don't view photos - unless you know their source and have a good reason to believe they are what they appear to be.
2) Backup everything that is important to you. I wrote about backup principles a long time ago on this blog, but the three most basic principles are: a) backup your crucial data often b) keep a relatively recent copy of your backup away. c) periodically verify that your backup is actually useful.
And may god help us all in this new age of evolutionary harmful software.
- VirusTotal - a free service that analyzes suspicious files and URLs and facilitates the quick detection of viruses, worms, trojans, and all kinds of malware. (and helps being up-to-date as to which anti viruses are aware of threats, such as petya)
- Ransomfree - an anti ransomware software that may help
- Avira AntiVirus - Free for Home use