Defang/refang and extract indicators of compromise in SQL — IPs, domains, URLs, e-mails, hashes and CVEs from threat-intel text, plus hash typing
Maintainer(s):
alitrack
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.4.4 | 1.4.5 | 1.5.5 | 1.5.6 | 2.0.0 |
|---|---|---|---|---|---|
| Linux AMD64 | |||||
| Linux ARM64 | |||||
| macOS AMD64 | |||||
| macOS ARM64 | |||||
| Windows AMD64 | |||||
| Windows ARM64 | |||||
| WebAssembly |
Installing and Loading
INSTALL ioc FROM community;
LOAD ioc;
Example
INSTALL ioc FROM community;
LOAD ioc;
SELECT defang('http://evil.example.com/a'); -- hxxp[://]evil[.]example[.]com/a
SELECT refang('hxxp[://]evil[.]example[.]com');-- http://evil.example.com
SELECT hash_type('d41d8cd98f00b204e9800998ecf8427e'); -- md5
SELECT is_ioc('1.2.3.4'); -- true
-- One row per distinct indicator
SELECT * FROM extract_iocs('beacon to evil.example.com from 1.2.3.4');
About ioc
ioc — threat-intel text in SQL
Pure Rust matching engine (lazy-compiled regexes, no VGI, no Arrow IPC,
no JSON). Ported from the MIT-licensed Query-farm vgi-ioc worker.
| Function | Returns | Notes |
|---|---|---|
defang(text) |
VARCHAR |
http→hxxp, .→[.], @→[at], ://→[://]
|
refang(text) |
VARCHAR | Inverse of defang
|
hash_type(s) |
VARCHAR |
md5/sha1/sha256/sha512, NULL if not a hash |
is_ioc(text) |
BOOLEAN | Is the whole string a single indicator? |
extract_iocs(text) |
table |
type, value — one row per distinct IOC |
→ GitHub
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| defang | scalar | NULL | NULL | |
| extract_cves | scalar | NULL | NULL | |
| extract_domains | scalar | NULL | NULL | |
| extract_emails | scalar | NULL | NULL | |
| extract_hashes | scalar | NULL | NULL | |
| extract_iocs | table | NULL | NULL | |
| extract_ipv4 | scalar | NULL | NULL | |
| extract_ipv6 | scalar | NULL | NULL | |
| extract_urls | scalar | NULL | NULL | |
| hash_type | scalar | NULL | NULL | |
| is_ioc | scalar | NULL | NULL | |
| refang | scalar | NULL | NULL |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases | typed_value |
|---|---|---|---|---|---|
| temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |
© 2026 DuckDB Foundation, Amsterdam NL