Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/lspr24/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ assumptions applied, and the policies are built from the latter.
| The overnight window is the learning window | `night` in `firru.toml`, read with `--window night` | Red is not scheduled overnight, so the choice does not depend on the dataset's `Label`. It is not literally clean: 863 of its 9.4M flows involve a red-team peer, none reaching a named internal host. |
| Which inventory host each loot file is | `identity-assertions.yml`; `via` in `def/host_metadata.json` | 51 of 59 bind by unique name and 6 by the loot's own address; 2 are asserted, each with its evidence. |
| Each host's dynamic port range | `dynamic_ranges` in `assumptions.yml`; `metadata.ephemeral_source` in the loot | The archive records none. The OS defaults are what every stock install in firru-os-baselines has (102 Linux runs; 19 of 20 Windows runs). `mail` is an Exchange server, and Exchange moves TCP to 6005-64325, as the stock Exchange install shows. |
| The Windows services syscollector never saw change | `windows` in `assumptions.yml`; `inferred` and `inferred_from` on each filled-in listener | Each Windows host is the stock install of its role (DC, CA, Exchange member, domain workstation) plus the layers its traffic shows (OpenSSH, RDP, WinRM), each measured on its own. `assumptions.py --flows` checks it: every port that answered overnight is explained except one: `tcp/134` on both domain controllers, which the green-team checker opens about once a minute (Zeek `RSTO`: the handshake completed, then the checker reset it). Something listened there that neither the loot nor any baseline knows; it is left unexplained rather than assumed, so the policies deny it and tighten's would-block report shows it. |
| The Windows services syscollector never saw change | `windows` in `assumptions.yml`; `inferred` and `inferred_from` on each filled-in listener | Each Windows host is the stock install of its role (DC, CA, Exchange member, domain workstation) plus the layers its traffic shows (OpenSSH, RDP, WinRM), each measured on its own. A listener the stock install bound to its own lab address is bound to the host's addresses instead, both families, since the baseline's addresses say nothing about this network. `assumptions.py --flows` checks it: every port that answered overnight is explained except one: `tcp/134` on both domain controllers, which the green-team checker opens about once a minute (Zeek `RSTO`: the handshake completed, then the checker reset it). Something listened there that neither the loot nor any baseline knows; it is left unexplained rather than assumed, so the policies deny it and tighten's would-block report shows it. |
| The blue team's own management sources | `mgmt_hosts` in `assumptions.yml`, MGMT_HOSTS in `def/networks.yml` | Of the 28 sources answered on SSH or RDP overnight, 25 are the green team, which the inventory names; the interior ones reach 26 hosts each on both, administration as well as scoring. The other three: the DMZ firewall's own address (administration through its NAT) and two exterior addresses. Over all windows 173 internal sources reached SSH or RDP: users and lateral movement inside the zones, not management. |
| Each subnet's management entry point | `zone_mgmt` in `assumptions.yml`; `<ZONE>_MGMT`, or `<ZONE>_<n>_MGMT` where a zone has several, in `def/networks.yml` | The top address of each internal subnet opens SSH, RDP and VNC to the hosts in that subnet and nowhere else, on both days and never at night: 64,159 answered flows from nine addresses, all labelled blue team. No asset is named at any of them, so the data shows that they carry management, not who operates them. |
| Who may administer a host | `def/heuristics.py` | The administrators the traffic shows, per zone: SSH, RDP and WinRM from the zone's green-team hosts, the management entry point of the host's own subnet and MGMT_HOSTS. NetBIOS and WS-Discovery come from the zone's own hosts, since neither has a reason to cross a zone. |
Expand Down
51 changes: 47 additions & 4 deletions examples/lspr24/assumptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
with metadata.ephemeral and metadata.ephemeral_source set,
and Windows hosts filled in from their baseline. A filled-in
listener carries the `inferred` flag and `inferred_from`, the
run it came from; an observed listener always wins.
run it came from; an observed listener always wins. One the
baseline bound to its own lab or link-local address is
rebound to the host's (`bind_from` keeps the original).
def/ MGMT_HOSTS defined, and every host's management source set to
it in host_metadata.json; with a zone_mgmt section, also
<ZONE>_MGMT, each zone's management entry point. A host's
Expand Down Expand Up @@ -60,6 +62,42 @@ def key(entry):
return entry["protocol"], int(entry["port"])


def own_addresses(defs, host):
"""The loot host's own addresses, by family, from its inventory token:
the short label's alias_of, else the label itself. Link-local left out."""
nets = (yaml.safe_load((defs / "networks.yml").read_text()) or {}).get("networks", {})
hm = json.loads((defs / "host_metadata.json").read_text())
token = (hm.get(host) or {}).get("alias_of", host)
own = {4: [], 6: []}
for v in (nets.get(token) or {}).get("values") or []:
try:
ip = ipaddress.ip_address(v.get("address", ""))
except ValueError:
continue
if not ip.is_link_local:
own[ip.version].append(ip)
return own


def rebind(e, own):
"""A baseline listener as it would bind on this host. A baseline run is
a stock install on its own lab network, so a listener bound to one of
its addresses binds to the same family's addresses here. The lab VM has
no global IPv6, so its link-local bind is the listener binding per IPv6
address, and it binds to the host's IPv6 addresses. Wildcard and
loopback binds are the same on every host."""
bind = e.get("bind_address") or ""
text = bind.split("/")[0].split("%")[0]
try:
ip = ipaddress.ip_address(text)
except ValueError:
return [e]
if ip.is_unspecified or ip.is_loopback:
return [e]
width = 32 if ip.version == 4 else 128
return [dict(e, bind_address=f"{mine}/{width}", bind_from=bind) for mine in own[ip.version]]


def windows_fill(spec, dyn):
"""The listeners `spec` assumes, outside the host's dynamic range."""
def in_dyn(e):
Expand Down Expand Up @@ -126,13 +164,18 @@ def range_for(host, os_name):
spec = (a["windows"] or {}).get(host)
if spec:
seen = {key(e) for e in doc["listen_ports"]}
add = []
own = own_addresses(pathlib.Path(args.defs), host)
add, added = [], set()
for (proto, port, _), (e, run) in sorted(windows_fill(spec, dyn or {}).items(),
key=lambda kv: (kv[0][0], kv[0][1], str(kv[0][2]))):
if (proto, port) in seen:
continue
add.append(dict(e, flags=sorted(set(e.get("flags") or []) | {"inferred"}),
inferred_from=run))
for r in rebind(e, own):
if (proto, port, r.get("bind_address")) in added:
continue
added.add((proto, port, r.get("bind_address")))
add.append(dict(r, flags=sorted(set(r.get("flags") or []) | {"inferred"}),
inferred_from=run))
doc["listen_ports"].extend(add)
filled[host] = {(e["protocol"], int(e["port"])) for e in add}
stats["listeners filled in"] += len(add)
Expand Down
Loading