Skip to content
Chethan Yadav_
Cybersecurity

SEC/Lesson 6 of 7/8 min read

Malware and Social Engineering

Malware types (viruses, worms, trojans, ransomware, rootkits, spyware, botnets), persistence and evasion, phishing and its variants, other social engineering tactics, and defenses.


On this page

Malware

Malware (malicious software) is any software designed to harm, exploit or gain unauthorized control over a system. Types are classified by how they spread and what they do (the payload); real samples often combine several.

Malware types

Virus

A virus attaches itself to a legitimate host file or program and spreads when that host is run or shared. It needs user action to propagate. Variants: file infectors, boot sector viruses, macro viruses (in Office documents), and polymorphic or metamorphic viruses that change their code on each infection to dodge signatures.

Worm

A worm is standalone and self-propagating across networks by exploiting vulnerabilities, with no user action. Worms spread extremely fast: WannaCry (2017) used the EternalBlue SMB exploit to hit hundreds of thousands of machines in days. Defense: patching, network segmentation, closing exposed services.

Trojan

A trojan disguises itself as legitimate software (a cracked game, a fake invoice, a fake update) and tricks the user into running it. It does not self-replicate. A RAT (remote access trojan) gives the attacker full remote control.

Ransomware

Ransomware encrypts the victim's files (and often backups) and demands payment for the key. Modern groups use double extortion: they also steal data and threaten to publish it. Delivered through phishing, exposed RDP, or unpatched VPN appliances, often after hands-on-keyboard lateral movement.

Defenses: offline, immutable, tested backups (the 3-2-1 rule: 3 copies, 2 media, 1 offsite), patching, MFA on remote access, least privilege, segmentation, and EDR.

Rootkit

A rootkit hides its presence (and other malware) by subverting the operating system: hooking system calls, hiding processes and files, or living in the kernel, bootloader (bootkit) or firmware. Extremely hard to detect from inside the infected OS. Defenses: Secure Boot, measured boot, kernel driver signing, and reimaging on suspicion.

Spyware

Spyware secretly collects information: browsing, credentials, location, messages. Adware shows unwanted ads; stalkerware is spyware used against partners or family members.

Keylogger

A keylogger records keystrokes to steal passwords and messages, in software (API hooks) or hardware (an inline USB device). MFA and passkeys limit the value of stolen passwords.

Other types

  • Fileless malware: runs in memory using built-in tools (PowerShell, WMI, "living off the land"), leaving little on disk.
  • Logic bomb: code that triggers on a condition (a date, an employee's removal from payroll).
  • Cryptojacker: mines cryptocurrency on the victim's CPU or cloud account.
  • Backdoor: a hidden way to bypass authentication.
TypeSelf-replicatesNeeds user actionMain goal
VirusYes (via host)YesSpread, payload
WormYesNoSpread fast
TrojanNoYesAccess via deception
RansomwareSometimesUsuallyExtortion
RootkitNoNoStealth, persistence

Botnet

A botnet is a network of compromised machines (bots or zombies) controlled by an attacker (the bot herder). Uses: DDoS, spam, credential stuffing, click fraud, proxying traffic.

Command and Control

Bots receive instructions from command and control (C2) infrastructure: centralized servers (IRC, HTTP), peer-to-peer networks (harder to take down), or covert channels (DNS tunneling, social media, cloud services). Domain generation algorithms (DGAs) create many rotating domains so blocking one does not cut the botnet off. Detecting beaconing (regular outbound calls to rare domains) is a key defensive signal.

Persistence and evasion

After the initial foothold, attackers:

  • Persist: scheduled tasks, startup registry keys, services, cron jobs, SSH authorized keys, new admin accounts.
  • Escalate privileges: kernel exploits, misconfigured services, stolen admin credentials.
  • Move laterally: pass-the-hash, stolen tokens, RDP and SSH with harvested credentials.
  • Evade: obfuscation, packing, code signing with stolen certificates, disabling security tools, clearing logs.

The MITRE ATT&CK framework catalogs these tactics and techniques and is the shared vocabulary for detection engineering.

Zero-Day

A zero-day is a vulnerability unknown to the vendor (so there are "zero days" to fix it before exploitation), and a zero-day exploit uses it. Valuable and expensive; usually used in targeted attacks. N-day vulnerabilities are known and patched but still exploited on systems that have not updated, and they cause most real-world compromises. Defense: fast patching, defense in depth, behavior-based detection.

Social Engineering

Social engineering manipulates people into breaking security procedures. It exploits psychological levers rather than technical flaws:

  • Authority: "This is the CEO, I need this done now."
  • Urgency and fear: "Your account will be closed in 24 hours."
  • Scarcity and greed: "You have won a prize, claim now."
  • Social proof and familiarity: impersonating a known colleague or vendor.
  • Helpfulness: holding the door, helping a "new employee" with access.

Phishing

Phishing sends fraudulent messages that impersonate a trusted party to steal credentials, deliver malware, or trigger payments.

Red flags: look-alike domains (paypa1.com, micros0ft-support.com), mismatched link targets, unexpected attachments (macro documents, ISO, HTML files), urgency, requests to bypass process, generic greetings.

Spear Phishing

Spear phishing targets a specific person with researched, personalized content (their manager's name, a real project). Whaling targets executives.

Variants

VariantChannel
SmishingSMS
VishingVoice calls (increasingly with AI voice cloning)
QuishingQR codes
Clone phishingCopy of a real email with a malicious link swapped in
Adversary-in-the-middle phishingA proxy site relays the real login and steals the session cookie, bypassing TOTP MFA

The last one is why phishing-resistant MFA (passkeys, FIDO2) matters: the browser will not sign a challenge for the wrong domain.

Business Email Compromise

Business email compromise (BEC) uses a compromised or spoofed executive or vendor mailbox to request wire transfers or changes to bank details. No malware involved, and it causes some of the largest financial losses of any cybercrime. Defenses: out-of-band verification for payment changes, dual approval, DMARC.

Email authentication

  • SPF: lists which servers may send mail for a domain.
  • DKIM: signs messages with the domain's key.
  • DMARC: tells receivers what to do when SPF and DKIM fail (p=reject), and sends reports. Together they stop exact-domain spoofing, but not look-alike domains.

Other social engineering tactics

  • Pretexting: a fabricated scenario (IT support, auditor) to extract information.
  • Baiting: infected USB drives left in a parking lot.
  • Tailgating / piggybacking: following an authorized person through a secure door.
  • Watering hole: compromising a website the target group regularly visits.
  • Shoulder surfing and dumpster diving.
  • MFA fatigue: spamming push prompts until the victim approves.

Supply Chain Attack

A supply chain attack compromises a trusted vendor, tool or dependency to reach its customers: SolarWinds (malicious update to network management software), the xz-utils backdoor (a maintainer takeover), typosquatted or hijacked npm and PyPI packages, and dependency confusion (a public package with the name of a company's internal package).

Defenses: pin and verify dependencies (lockfiles, checksums, signatures), use private registry scoping, SBOMs, least-privilege CI tokens, and review new or changed dependencies.

Defenses against malware

Antivirus

Traditional antivirus matches files against signatures of known malware, plus heuristics for suspicious structure. Cheap and useful against commodity malware, but blind to new, polymorphic and fileless attacks.

EDR

Endpoint Detection and Response (EDR) records process, file, network and registry activity on every endpoint, detects malicious behavior (Office spawning PowerShell, mass file encryption), and lets responders isolate hosts and investigate remotely. XDR extends this across email, network and cloud.

Other controls

  • Patch operating systems, browsers and applications quickly.
  • Application allow-listing, macro blocking, removing local admin rights.
  • Sandboxing suspicious attachments before delivery.
  • Email filtering, DNS filtering of known-bad domains.
  • Regular security awareness training and phishing simulations, plus an easy "report phishing" button and a no-blame culture so people report mistakes fast.

Quick revision

  • Virus needs a host and user action; worm self-propagates; trojan deceives; rootkit hides.
  • Ransomware encrypts and often steals data; offline immutable backups are the key defense.
  • Botnets are controlled via C2; look for beaconing to rare domains.
  • Zero-days are unknown to the vendor; most breaches still use unpatched n-days.
  • Social engineering exploits authority, urgency and helpfulness; phishing is the top initial access vector.
  • Phishing-resistant MFA, SPF/DKIM/DMARC, and out-of-band payment verification counter phishing and BEC.
  • Antivirus matches signatures; EDR detects behavior and enables response.