Malware: Viruses, Ransomware and Spyware
Malware is short for malicious software: any program made to harm your device, steal data or take control of it.
Types of Malware
| Type | What it does |
|---|---|
| Virus | Attaches to files and spreads when they are opened |
| Worm | Spreads by itself across networks, without anyone clicking |
| Trojan | Pretends to be a useful program, but hides harmful code |
| Ransomware | Locks (encrypts) your files and demands payment |
| Spyware | Secretly watches you: messages, passwords, location |
| Adware | Fills your screen with unwanted ads |
| Keylogger | Records every key you type, including passwords |
| Banking trojan | Steals banking and mobile wallet details, often on Android |
How Malware Spreads
- Cracked software and games downloaded from unknown websites
- Fake apps sent as
.apkfiles on WhatsApp ("new wedding card app", "bank update") - Email attachments, such as a fake invoice in a
.zipor a document asking you to "enable macros" - Infected USB drives passed between computers, for example at a print shop
- Unpatched software with known weaknesses
Install apps only from the official Google Play Store or Apple App Store, and software only from the maker's official website.
Signs of an Infected Device
- The device becomes very slow or the battery drains quickly
- Pop-up ads appear even when no browser is open
- New apps or browser toolbars you did not install
- Your friends receive messages you did not send
- Files suddenly have strange extensions and will not open
Checking a File's Hash
Security teams identify known malware by its hash, a unique fingerprint of the file. You can calculate a file's SHA-256 hash and compare it with the one published on the official download page.
On Windows (PowerShell):
Example
Get-FileHash .\setup.exe -Algorithm SHA256Algorithm Hash Path --------- ---- ---- SHA256 3A7BD3E2360A3D29EEA436FCFB7E44C735D117C42D1C1835420B6B9942DD4F1B C:\Users\Ali\Downloads\setup.exe
On Linux or macOS:
Example
sha256sum setup.exeIf the hash does not match the one the publisher gives, the file was changed. Do not run it.
Checking a File's Real Type
Attackers rename programs so they look like documents, such as fees-list.pdf.exe. Windows may hide the last part. This Python example checks the first bytes of a file, which reveal its real type:
Example
signatures = {
b"%PDF": "PDF document",
b"MZ": "Windows program (.exe)",
b"PK": "ZIP archive (also .docx, .xlsx, .apk)",
}
with open("fees-list.pdf", "rb") as f:
start = f.read(4)
for magic, kind in signatures.items():
if start.startswith(magic):
print("Real type:", kind)Real type: Windows program (.exe)
This "PDF" is actually a program. In Windows File Explorer, turn on View > Show > File name extensions to see full names.
Ransomware and Backups
Ransomware is one of the most damaging threats for businesses. The best protection is a good backup. Follow the 3-2-1 rule:
- Keep 3 copies of important data
- On 2 different types of storage (for example a laptop and an external drive)
- With 1 copy kept offline or off-site (a disconnected drive, or cloud backup with version history)
With a clean backup, you can restore files without paying anyone. Paying does not guarantee you will get your files back.
How to Protect Your Devices
- Keep the operating system, browser and apps updated
- Use the built-in antivirus (Microsoft Defender on Windows, Google Play Protect on Android) and keep it on
- Do not open unexpected attachments or install unknown
.apkfiles - Use a normal (standard) user account on Windows for daily work, not an administrator
- Make regular backups and test that you can restore them
If You Think You Are Infected
- Disconnect from Wi-Fi and mobile data
- Run a full antivirus scan
- Remove unknown apps and browser extensions
- Change important passwords from a different, clean device
- If the problem continues, reset the device and restore from a clean backup
Exercise
Exercise
Which type of malware locks your files and demands payment to unlock them?
