Skip to content
Tutorials Center
My learning

Topics

Lesson 28 of 37 ยท Defence and Detection

Detecting Metasploit Activity

How defenders spot Metasploit-style activity: network beacons, scan patterns, endpoint telemetry and log clues, with Python stand-ins for beacon and scan detection.

Metasploit is open source and widely used, so security tools know it well. Detecting it is not about recognising one magic string. It is about noticing the behaviour that any exploitation framework produces: reconnaissance, exploitation, a callback and follow-on activity. This lesson shows what defenders look at, from the network, from the endpoint and from logs.

The stand-ins analyse invented traffic and logs; they teach the logic behind detections you would write in an intrusion detection system or a SIEM.

The attack chain and where to look

flowchart LR
    R["Recon: scans"] --> E["Exploit attempt"]
    E --> C["Callback / session"]
    C --> P["Post-exploitation"]
    R -.-> N1["Firewall, IDS logs"]
    E -.-> N2["Application and WAF logs"]
    C -.-> N3["Egress and DNS logs"]
    P -.-> N4["Endpoint telemetry"]

Each stage leaves a different kind of evidence.

A detection strategy covers every stage, because attackers change tools but rarely skip the stages themselves.

Network indicators

  • Scanning. One source touching many ports or hosts in a short time.
  • Unusual outbound connections. A server starting a connection to a rarely seen external address and port (reverse payloads connect out, which is why egress rules matter).
  • Beaconing. Connections at regular intervals, often with small, similar-sized packets.
  • Known byte patterns. Staged payloads include recognisable stager code. Signature-based systems (Snort, Suricata) match such patterns, but attackers can encode them, so signatures are only one layer.
  • Default ports. Handlers often listen on 4444 by default. Easy to change, yet still seen in the wild.

Beaconing

Software that checks in with a controller does so on a timer, with a little random "jitter". The stand-in measures how regular a set of connection times is. Human browsing is bursty; a beacon has a steady period.

Python Score how regular connection times are

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A low variation score is a lead, not proof: monitoring agents and update checkers also beacon. Combine it with destination reputation and which process made the connection.

Endpoint indicators

Endpoint detection and response (EDR) software sees what the network cannot:

  • A user program spawning a command interpreter or PowerShell with encoded commands.
  • Executable memory not backed by a file, and one process writing into another's memory (migration).
  • New services, scheduled tasks or startup entries created shortly after a login.
  • Credential-store access by processes that have no reason to touch it.

On Linux, auditd, eBPF sensors and journald give similar telemetry: unexpected children of web server processes, new cron entries, and outbound sockets from unusual users.

Log indicators

The earliest evidence is often in ordinary logs. This stand-in scans an invented web log for the repeated error and probing pattern a scanner produces, then flags the source.

Python Find probing in a sample web log

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Deception and canaries

A honeypot or canary is a host, service or file that no legitimate user touches. Any connection to it is suspicious. Because scanners sweep whole ranges, a few canary addresses in each subnet give near-zero-noise alerts. It is among the cheapest detections to deploy.

Layered detection

Layer Strength Weakness
Signatures Precise for known payloads Easy to evade by encoding
Behaviour Catches new tools Needs tuning, false positives
Canaries Very low noise Only catch those who touch them
Endpoint telemetry Deep host view Needs agents and storage

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Why do reverse payloads make egress monitoring valuable?

    Reverse payloads call back from inside, so unusual outbound connections are a key indicator.
  2. 2. What does a low variation in the gaps between connections suggest?

    Software on a timer produces regular intervals, though legitimate agents do too.
  3. 3. Why are signatures alone not enough?

    Pattern matching is evaded by encoding, so combine it with behaviour and endpoint detection.
  4. 4. What is a canary host?

    Unused decoys produce alerts with almost no false positives.

Summary

  • Detect the behaviour at each stage: scan, exploit, callback, post-exploitation.
  • Network clues: scans, outbound callbacks, beacons, known stager patterns.
  • Endpoint clues: odd process trees, unbacked executable memory, persistence changes.
  • Logs and canaries often give the earliest, cleanest alerts.
  • Layer signatures, behaviour and deception; none works alone.

Next: Writing Detection Signatures