Set up defensive OSINT properly: the intelligence cycle, passive versus active collection, GDPR and computer intrusion basics, a written scope document, analyst OPSEC, Admiralty source grading, and a Python evidence logger that hashes every collection step.
Open source intelligence is easy to start and easy to get wrong. A defender who maps the public exposure of their own organisation needs the same discipline as any other security assessment: a mandate, a written scope, a repeatable method, and a record of every step. This tutorial sets out that framework and ends with a small Python evidence logger you can use in every later exercise in this category.
OSINT is intelligence produced from information that is publicly and lawfully available: DNS records, Certificate Transparency logs, published code, search engine caches, regulatory filings, archived web pages, and similar sources. The word that matters is intelligence. A pile of search results is raw material. Intelligence is what remains after the material has been collected for a stated question, checked for reliability, analysed, and turned into a conclusion someone can act on.
In this category OSINT has one purpose: an organisation examining what the internet can see about its own assets. Typical questions are "Which hostnames under our domains are publicly visible?", "Did a deployment leak configuration into a public repository?", or "Which of our certificates expire in the next 30 days?". The answers feed patching, decommissioning and policy decisions.
Some things are explicitly out of scope and will not be covered anywhere in this series:
The classic intelligence cycle is a useful backbone for exposure reviews because it forces you to write down the question before you start collecting. It has five phases.
Feedback from dissemination flows back into planning. If the network team says a hostname was retired last year, the next cycle should explain why it still appears in your sources.
Passive collection means you never send traffic to the systems under review. You query third parties that have already recorded information: Certificate Transparency logs, passive DNS databases, web archives, code hosting search. The target cannot see you and your actions cannot affect its availability.
Active collection means you interact with the target: resolving its DNS names against its authoritative servers, requesting web pages, grabbing TLS banners, port scanning. Even a simple HTTP request is active, because it reaches the target's infrastructure and appears in its logs.
The line matters for three reasons:
Some steps sit in between. Resolving a hostname through a public recursive resolver queries the target's authoritative name servers indirectly. Treat that as low-impact active collection and put it in scope explicitly rather than arguing about it afterwards.
This section gives general orientation, not legal advice. Laws differ between jurisdictions and change over time. Before you start a programme, ask your legal counsel or data protection officer to confirm the approach for your organisation.
Even when you only look at your own infrastructure, the data you collect can contain personal data: an e-mail address in a certificate, a developer's name in a commit, a staff member's account name in a leaked configuration file. As soon as personal data is in scope, the GDPR applies to your processing.
Record the processing activity in your register of processing activities, as Article 30 requires for most organisations.
In the Netherlands, computer intrusion (computervredebreuk) is defined in the Criminal Code as intentionally and unlawfully entering an automated system or part of it. Other EU member states have comparable provisions, harmonised to a large extent by Directive 2013/40/EU on attacks against information systems. The practical rule for defenders is simple: do not access any system without authorisation, and do not bypass any security measure, however weak. Using a password found in a public paste to "check whether it still works" is access, not OSINT.
Authorisation must come from someone entitled to give it. A team lead cannot authorise testing of a system hosted and operated by a third party; the contract with that party determines what is allowed. Many cloud and hosting contracts contain specific testing policies. Read them before any active step.
The Netherlands also has an established practice of coordinated vulnerability disclosure. If your review uncovers a weakness in a third party's system along the way, stop, record what you saw, and report it through that party's disclosure channel. Do not investigate further.
Rules of engagement translate the mandate into concrete limits. They answer who may do what, against which assets, when, how fast, and what happens when something unexpected turns up. Write them down and get them signed before collection starts. A minimal scope document looks like this.
| Field | Example content |
|---|---|
| Case identifier | MYPROJECT-2026-001 |
| Requester and approver | Head of IT (requester), CISO (approver), signed and dated |
| Intelligence requirement | Inventory of public hostnames under our domains with DNS state and certificate expiry |
| Assets in scope | example.com, example.org and all subdomains; 192.0.2.0/24; 198.51.100.0/24 |
| Assets out of scope | Third-party SaaS tenants, supplier domains, personal accounts of staff |
| Permitted passive sources | Certificate Transparency logs, public DNS, web archives, public code search |
| Permitted active techniques | DNS resolution via the corporate resolver; no port scanning, no HTTP requests |
| Rate limits | One request per 10 seconds per external source |
| Personal data handling | Not collected deliberately; incidental personal data removed during processing |
| Lawful basis and LIA | Legitimate interest; LIA reference LIA-2026-004 |
| Retention | Raw artefacts 90 days; findings 2 years |
| Time window | 2026-12-07 to 2026-12-18, office hours |
| Stop conditions | Signs of compromise, third-party vulnerability, personal data beyond incidental: stop and escalate |
| Escalation contacts | Security on-call, data protection officer |
| Deliverables | Findings report, evidence log, updated asset inventory |
Keep the scope machine-readable as well. Later tutorials in this category refuse to run against a domain that is not listed in a settings file, which turns the scope document into an enforced control rather than a PDF in a shared folder.
Operational security in defensive OSINT protects two things: the integrity of your evidence and the confidentiality of your organisation's interests. You are not hiding from your own employer, but you do want clean, attributable, reproducible collection.
The Admiralty system, also used in NATO doctrine, grades each item on two independent axes: the reliability of the source and the credibility of the information. Combining them gives a compact code such as B2.
| Code | Source reliability | Code | Information credibility |
|---|---|---|---|
| A | Completely reliable | 1 | Confirmed by other independent sources |
| B | Usually reliable | 2 | Probably true |
| C | Fairly reliable | 3 | Possibly true |
| D | Not usually reliable | 4 | Doubtful |
| E | Unreliable | 5 | Improbable |
| F | Reliability cannot be judged | 6 | Truth cannot be judged |
Grade the two axes separately. A Certificate Transparency log operated under a public policy might be a B: it is cryptographically append-only, but an aggregator in front of it can lag, drop entries or time out. A hostname found in a certificate is probably true as a statement that the name was certified, so 2, but it says nothing about whether the host exists today. After your own DNS resolution confirms the name, the finding can move to 1.
Default unknown sources to F6 and upgrade only with reasons you can write down. Do not let a high source grade inflate a claim the source never made.
Every conclusion in your report should trace back to a specific collection step: which source, which query, when, by whom, and exactly what came back. Three properties make that trace trustworthy:
The helper below uses only the standard library. It was tested on Python 3.13 and needs Python 3.12 or later. The demonstration uses requests 2.34.2, the latest stable release at the time of writing; later tutorials in this category add Django 5.2.20 LTS (pinned as Django>=5.2,<6.0) and dnspython 2.9.2.
python -m venv .venv
. .venv/bin/activate # Windows: .venv\Scripts\activate
pip install "requests>=2.34,<3.0"
Save the following as evidence.py:
"""Append-only evidence log for OSINT collection steps (JSON Lines)."""
from __future__ import annotations
import hashlib
import json
import os
import uuid
from dataclasses import asdict, dataclass
from datetime import datetime, timezone
from pathlib import Path
@dataclass(frozen=True)
class EvidenceRecord:
record_id: str
case_id: str
analyst: str
source: str
query: str
collected_at: str
artefact: str
sha256: str
size_bytes: int
grading: str
note: str
class EvidenceLog:
def __init__(self, case_id: str, analyst: str, root: Path) -> None:
self.case_id = case_id
self.analyst = analyst
self.root = Path(root)
self.artefacts = self.root / "artefacts"
self.artefacts.mkdir(parents=True, exist_ok=True)
self.log_path = self.root / "evidence.jsonl"
def record(self, *, source: str, query: str, content: bytes,
suffix: str = ".bin", grading: str = "F6",
note: str = "") -> EvidenceRecord:
digest = hashlib.sha256(content).hexdigest()
artefact = self.artefacts / f"{digest}{suffix}"
if not artefact.exists():
artefact.write_bytes(content)
rec = EvidenceRecord(
record_id=str(uuid.uuid4()),
case_id=self.case_id,
analyst=self.analyst,
source=source,
query=query,
collected_at=datetime.now(timezone.utc).isoformat(timespec="seconds"),
artefact=artefact.relative_to(self.root).as_posix(),
sha256=digest,
size_bytes=len(content),
grading=grading,
note=note,
)
line = json.dumps(asdict(rec), ensure_ascii=False, sort_keys=True)
with self.log_path.open("a", encoding="utf-8") as fh:
fh.write(line + "\n")
fh.flush()
os.fsync(fh.fileno())
return rec
def verify(self) -> list[str]:
"""Return a list of problems; an empty list means the log is intact."""
problems = []
with self.log_path.open(encoding="utf-8") as fh:
for n, line in enumerate(fh, start=1):
rec = json.loads(line)
path = self.root / rec["artefact"]
if not path.exists():
problems.append(f"line {n}: missing {rec['artefact']}")
continue
actual = hashlib.sha256(path.read_bytes()).hexdigest()
if actual != rec["sha256"]:
problems.append(f"line {n}: hash mismatch for {rec['artefact']}")
return problems
Design choices worth noting:
fsync. A crash can lose at most the line being written, never corrupt earlier lines.The demonstration below performs one passive query: Certificate Transparency entries for example.com from the public crt.sh aggregator. In a real case you would substitute a domain from your signed scope.
import requests
from pathlib import Path
from evidence import EvidenceLog
log = EvidenceLog(case_id="MYPROJECT-2026-001", analyst="analyst-01",
root=Path("case-001"))
url = "https://crt.sh/?q=example.com&output=json"
resp = requests.get(url, timeout=60,
headers={"User-Agent": "myproject-exposure-review/1.0"})
resp.raise_for_status()
rec = log.record(source="crt.sh", query=url, content=resp.content,
suffix=".json", grading="B2",
note="CT entries for own domain, scope item S-01")
print(rec.collected_at, rec.sha256[:16], rec.size_bytes)
print("problems:", log.verify())
Output from a real run:
2026-12-05T16:19:07+00:00 b3b8f7173648f73d 27146
problems: []
The log line, formatted for readability:
{"analyst": "analyst-01",
"artefact": "artefacts/b3b8f7173648f73da6e90f031cec09f223f42b48d39a25c19e855f495d932fba.json",
"case_id": "MYPROJECT-2026-001",
"collected_at": "2026-12-05T16:19:07+00:00",
"grading": "B2",
"note": "CT entries for own domain, scope item S-01",
"query": "https://crt.sh/?q=example.com&output=json",
"record_id": "d281ae1a-6c29-4688-88a5-bf3f4a870730",
"sha256": "b3b8f7173648f73da6e90f031cec09f223f42b48d39a25c19e855f495d932fba",
"size_bytes": 27146,
"source": "crt.sh"}
To see the integrity check work, append one byte to the stored artefact and call verify() again:
['line 1: hash mismatch for artefacts/b3b8f7173648f73da6e90f031cec09f223f42b48d39a25c19e855f495d932fba.json']
Note that the raw crt.sh response is stored unmodified, so it may contain e-mail addresses that a certificate authority included in a subject field. That is incidental personal data. Your scope document should say how long such raw artefacts are kept and who can read them, and your processing step should drop those values before anything reaches a report.
A local file protects against accidents, not against a determined insider. For higher assurance:
A good defensive OSINT report is short and verifiable. For each finding give a one-sentence statement, the affected asset, the grading, the evidence record identifiers, a recommended action and an owner. Separate observation ("the name staging.example.com appears in a certificate issued in November") from assessment ("the staging environment is probably reachable from the internet"). Readers should be able to disagree with your assessment while accepting your observation.
Close each case formally: confirm that deliverables were accepted, schedule deletion of raw artefacts according to the retention period, and note lessons for the next planning phase.
verify() before handing over evidence, and enforce the retention period afterwards.Found a mistake in this tutorial? Let us know and we will fix it.