Extract threat indicators (IOCs) from unstructured text — IPs, domains, URLs, hashes, CVEs, MITRE techniques, threat actors, and malware families. Layer 1 of an IOC-lifecycle toolkit.
Project description
iocflow
Pull indicators of compromise out of unstructured text — threat-intel reports, advisories, emails, tickets — in one call. iocflow extracts IPs, domains, URLs, filenames, file hashes, CVEs, MITRE ATT&CK technique IDs, threat actors, and malware families, with the false-positive defenses you'd otherwise write by hand: a Public Suffix List domain validator, benign-domain/IP allowlists, hash de-duplication across MD5/SHA1/SHA256, and re-fanging of defanged IOCs.
from iocflow import extract
text = """
APT28 (a.k.a. Fancy Bear) staged Cobalt Strike from evil-domain[.]ru and
185.220.101.5, dropping install.ps1 (MD5 a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4).
Exploited CVE-2021-44228 via T1190. Contact: ops@evil-domain[.]ru.
"""
entities = extract(text)
print(entities.summary())
# 1 IPs, 1 domains, 1 filenames, 1 hashes, 1 CVEs, 1 emails, 1 threat actors, 1 MITRE techniques
for ind in entities.iter_indicators():
print(ind.kind, ind.value)
# ip 185.220.101.5
# domain evil-domain.ru
# ...
The defanged evil-domain[.]ru and ops@evil-domain[.]ru are re-fanged
automatically; 185.220.101.5 is kept while private/benign IPs are dropped.
Install
pip install iocflow # core — one dependency (tldextract)
pip install "iocflow[mitre]" # + a ready-made MITRE ATT&CK malware-name source
What it extracts
extract(text) returns an ExtractedEntities with:
ips— public IPv4, excluding private ranges, benign IPs, and version-number-like valuesdomains— validated against the Mozilla Public Suffix List viatldextracturls— bothhttps://…and barehost/pathforms (so package-registry paths survive)filenames— suspicious script/executable/macro/archive filenameshashes—{"md5": [...], "sha1": [...], "sha256": [...]}, de-duplicated across lengthscves—CVE-YYYY-NNNN+, normalized to uppercaseemailsmitre_techniques—T1059,T1059.001, …threat_actors(+threat_actors_enriched) — APT/UNC/FIN/TA/DEV/STORM designators, a curated well-known list, and the"<Name> ransomware"patternmalware_families— populated when you supply a malware-name source (see below)
Each individual extractor is also importable and composable:
from iocflow import extract_ips, extract_hashes, refang_text
extract_ips(refang_text("c2 at 185[.]220[.]101[.]5")) # ['185.220.101.5']
Pluggable name sources
The core has no external-data dependency. Two enrichment sources are optional and supplied by you, so iocflow drops cleanly into any environment — plug in your own feeds, or use the bundled MITRE extra.
Malware families. Give extract a MalwareNames and it matches families
(with alias-to-canonical normalization) behind a three-layer false-positive
defense. Build one from your own list, from MITRE-shaped records, or from the
optional extra:
from iocflow import extract, MalwareNames
# Your own list:
names = MalwareNames.from_names(["Cobalt Strike", "Emotet", "Qakbot"])
entities = extract(report_text, malware_names=names)
# Or the bundled MITRE ATT&CK source (needs: pip install "iocflow[mitre]"):
from iocflow.mitre import mitre_malware_names
entities = extract(report_text, malware_names=mitre_malware_names())
Threat-actor aliases. Give extract an ActorAliases to match a custom
name set and enrich actors with common_name / region / all_names. Without
it, actors are still found by pattern and curated list:
from iocflow import extract, ActorAliases
aliases = ActorAliases.from_index({
"apt28": {"common_name": "APT28", "region": "Russia",
"all_names": ["Fancy Bear", "Sofacy", "Sednit"]},
})
entities = extract(report_text, actor_aliases=aliases)
entities.threat_actors_enriched[0].region # "Russia"
entities.threat_actors_enriched[0].aliases_display() # "Fancy Bear, Sofacy, Sednit"
Command line
iocflow "APT28 used 185.220.101.5 and evil[.]example[.]com"
echo "report text…" | iocflow --json
iocflow --mitre "Emotet dropped Cobalt Strike" # needs iocflow[mitre]
Layer 2 — enrichment
Take the extracted entities and look every indicator up against threat-intel sources, getting back a normalized verdict per indicator. Install the extra and set the API keys you have:
pip install "iocflow[enrich]"
export IOCFLOW_VT_API_KEY=... # VirusTotal (free key)
export IOCFLOW_ABUSEIPDB_API_KEY=... # AbuseIPDB (free key)
export IOCFLOW_ABUSECH_API_KEY=... # abuse.ch (free Auth-Key)
from iocflow import extract
from iocflow.enrich import enrich
entities = extract(report_text)
report = enrich(entities) # uses every source whose key is set
print(report.summary())
# 5 indicators across 3 sources, 2 malicious, 1 suspicious
for ind in report.malicious:
print("malicious:", ind.kind, ind.value, "→", report.verdict_for(ind.kind, ind.value).value)
Each indicator is routed only to the sources that handle its kind (VirusTotal: IPs/domains/URLs/hashes; AbuseIPDB: IPs; abuse.ch: IPs/domains/URLs/hashes via ThreatFox/URLhaus/MalwareBazaar). Lookups fan out over a thread pool. A source with no key is skipped, and a failing lookup becomes an error record rather than crashing the batch — so partial coverage still produces a report.
Verdicts are normalized to MALICIOUS / SUSPICIOUS / BENIGN / UNKNOWN and
aggregated worst-wins across sources. You can also pass enrichers explicitly,
restrict to certain kinds, or supply a cache:
from iocflow.enrich import enrich, VirusTotalEnricher, MemoryCache
report = enrich(
entities,
[VirusTotalEnricher("my-key")],
kinds={"ip", "domain"},
cache=MemoryCache(),
)
Bring your own source by implementing the Enricher protocol (name,
supports(kind), enrich(kind, value) -> EnrichmentRecord) — or subclass
HTTPEnricher to get session handling, rate-limiting, and error-wrapping for
free.
Where this is going
iocflow grows in independently-useful layers, each behind its own pip extra.
Layer 1 (extraction) and Layer 2 (enrichment) ship today; next are AI
commentary, suggested hunts, and optional perimeter blocking. The pipeline is a
clean hand-off chain of stable types: ExtractedEntities (L1) feeds enrich(),
which returns an EnrichmentReport (L2) that later layers consume.
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iocflow-0.2.0.tar.gz.
File metadata
- Download URL: iocflow-0.2.0.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c59e8e9fa78b244a82ed3dec9c32d7f390833fd12fba4e4d47ea8fa400965688
|
|
| MD5 |
f21aa822e9771ef00eb8ead4adfeb8fd
|
|
| BLAKE2b-256 |
bec773c90e32dc5248e7a85ebb518e6dfa0837290cf53fff5c2f262e3314ae43
|
Provenance
The following attestation bundles were made for iocflow-0.2.0.tar.gz:
Publisher:
release.yml on vinayvobbili/iocflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iocflow-0.2.0.tar.gz -
Subject digest:
c59e8e9fa78b244a82ed3dec9c32d7f390833fd12fba4e4d47ea8fa400965688 - Sigstore transparency entry: 1677084767
- Sigstore integration time:
-
Permalink:
vinayvobbili/iocflow@76a7485372054bba068e64541de5d1d8dfcae42f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/vinayvobbili
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@76a7485372054bba068e64541de5d1d8dfcae42f -
Trigger Event:
push
-
Statement type:
File details
Details for the file iocflow-0.2.0-py3-none-any.whl.
File metadata
- Download URL: iocflow-0.2.0-py3-none-any.whl
- Upload date:
- Size: 35.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cb50c413655ca6c8fb619b7f759fbd23e77c8021f74be0432e818013fb1d45c
|
|
| MD5 |
7c5f2775ac575c4e21e0bd670a1941fe
|
|
| BLAKE2b-256 |
178fd7c2a0f19506237bb907ac176536ce7d31876a5b1646fc69d92c0b236dc0
|
Provenance
The following attestation bundles were made for iocflow-0.2.0-py3-none-any.whl:
Publisher:
release.yml on vinayvobbili/iocflow
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iocflow-0.2.0-py3-none-any.whl -
Subject digest:
1cb50c413655ca6c8fb619b7f759fbd23e77c8021f74be0432e818013fb1d45c - Sigstore transparency entry: 1677084777
- Sigstore integration time:
-
Permalink:
vinayvobbili/iocflow@76a7485372054bba068e64541de5d1d8dfcae42f -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/vinayvobbili
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@76a7485372054bba068e64541de5d1d8dfcae42f -
Trigger Event:
push
-
Statement type: