Python package to defang and fang indicators of compromise from text.
Project description
IOC Fanger
Python package to fang (example[.]com => example.com) and defang (example.com => example[.]com) indicators of compromise in text.
Read more in our interactive documentation!
What can be fanged?
ioc_fanger.fang recognises the following defanging patterns and restores them to their normal form:
- Brackets, parentheses, or braces around a
.or,— e.g.example[.]com,example(.)com,example{.}com,example[,]com - Brackets, parentheses, or braces around a
:— e.g.http[:]//example.com - The literal word
DOT,dot,punto, orpunktstanding in for a.— e.g.example[dot]com,example DOT com,example-punto-com - Brackets, parentheses, or braces around
://— e.g.http[://]example.com - Brackets, parentheses, or braces around
www— e.g.[www]example.com - Brackets, parentheses, or braces around a
-— e.g.service[-]ict.nl @replaced withat,et,arroba, or@itself wrapped in brackets/parentheses/braces — e.g.user[at]example.com,user(@)example.com,user AT example.com- Defanged URL schemes such as
hXXp://,hXXps://,hxxp://,xxxx://,xxxxs://,xxxx[s]://, as well as bracketed variants like[http]://andhtt[p]:// - URL schemes split by extra slashes or whitespace — e.g.
http:///example.com,http: //example.com,https : //example.com - IPv4 addresses written with commas instead of dots — e.g.
8,8,8,8→8.8.8.8 - Backslash-, caret-, or angle-bracket-escaped dots — e.g.
example\.com,example^.com,example<.>com - Backslash-escaped slashes — e.g.
http:\/\/example.com - Stray whitespace around an
@in an email — e.g.user @ example.com
These patterns combine, so inputs like hXXp://bad[.]example[dot]com/file[.]php are fully restored in a single call.
What can be defanged?
ioc_fanger.defang applies a small, deliberately conservative set of substitutions so the output is unambiguous to re-fang:
- A
.between two word characters becomes[.]— e.g.example.com→example[.]com,8.8.8.8→8[.]8[.]8[.]8 - The URL schemes
http:andhttps:becomehXXp:andhXXps:— e.g.http://example.com→hXXp://example[.]com - An
@between two non-whitespace characters becomes(at)— e.g.user@example.com→user(at)example[.]com
Developer Docs
For those working on or testing this library, here's some helpful tips.
Updating Benchmarks
This project uses pytest-benchmark to test the performance impact of changes.
By default, every time you run tests it will compare the new results with the existing results.
If you need to update the benchmarks, open the pyproject.toml and replace all flags starting with --benchmark with:
--benchmark-save=benchmark
This will save a file in the .benchmarks/ dir.
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 ioc_fanger-5.0.0.tar.gz.
File metadata
- Download URL: ioc_fanger-5.0.0.tar.gz
- Upload date:
- Size: 115.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
94cfc7f7c2801d54cfbb794beac0663c1dbff7a14167decf067a7202b49af356
|
|
| MD5 |
0a49e9b631ba08adbfb340d1771d1670
|
|
| BLAKE2b-256 |
cd896010d4af0bdef5475ac29302c406692cd4cd25da4d88851117e0d543ad77
|
Provenance
The following attestation bundles were made for ioc_fanger-5.0.0.tar.gz:
Publisher:
python-publish.yml on ioc-fang/ioc-fanger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ioc_fanger-5.0.0.tar.gz -
Subject digest:
94cfc7f7c2801d54cfbb794beac0663c1dbff7a14167decf067a7202b49af356 - Sigstore transparency entry: 1523850339
- Sigstore integration time:
-
Permalink:
ioc-fang/ioc-fanger@f81dcf87f18d6c1189a18e2865d6299cc74180f4 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/ioc-fang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f81dcf87f18d6c1189a18e2865d6299cc74180f4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ioc_fanger-5.0.0-py3-none-any.whl.
File metadata
- Download URL: ioc_fanger-5.0.0-py3-none-any.whl
- Upload date:
- Size: 7.3 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 |
0391947de217740020020baa34f79f155c5f347e6a048fd4e5b2ab5e36cf4cd0
|
|
| MD5 |
15e835bd80c91093122204045d2516fc
|
|
| BLAKE2b-256 |
f8fef464b0d69f7209be2897eecfcdbc899a6ebe60b9d846207d0604b3896039
|
Provenance
The following attestation bundles were made for ioc_fanger-5.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on ioc-fang/ioc-fanger
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ioc_fanger-5.0.0-py3-none-any.whl -
Subject digest:
0391947de217740020020baa34f79f155c5f347e6a048fd4e5b2ab5e36cf4cd0 - Sigstore transparency entry: 1523850362
- Sigstore integration time:
-
Permalink:
ioc-fang/ioc-fanger@f81dcf87f18d6c1189a18e2865d6299cc74180f4 -
Branch / Tag:
refs/tags/v5.0.0 - Owner: https://github.com/ioc-fang
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@f81dcf87f18d6c1189a18e2865d6299cc74180f4 -
Trigger Event:
push
-
Statement type: