项目作者: ninoseki

项目描述 :
An npm package for extracting common IOC(Indicator of Compromise)
高级语言: TypeScript
项目地址: git://github.com/ninoseki/ioc-extractor.git
创建时间: 2018-06-19T08:02:20Z
项目社区:https://github.com/ninoseki/ioc-extractor

开源协议:MIT License

下载


IoC extractor

npm version
Node.js CI
CodeFactor
Coverage Status
Documentation

IoC extractor is an npm package for extracting common IoC (Indicator of Compromise) from a block of text.

Note: the package is highly influenced by cacador.

Installation

  1. npm install -g ioc-extractor
  2. # or if you want to use ioc-extractor as a library in your JS/TS project
  3. npm install ioc-extractor

Usage

As a CLI

  1. $ ioc-extractor --help
  2. Usage: ioc-extractor [options]
  3. Options:
  4. --no-strict Disable strict option
  5. --no-refang Disable refang option
  6. --no-sort Disable sort option
  7. -p, --punycode Enable punycode option
  8. -o, --only <types...> Show only specific IoC types
  9. -h, --help display help for command
  1. $ echo "1.1.1.1 8.8.8.8 example.com" | ioc-extractor | jq
  2. {
  3. "asns": [],
  4. "btcs": [],
  5. "cves": [],
  6. "domains": [
  7. "example.com"
  8. ],
  9. "emails": [],
  10. "eths": [],
  11. "gaPubIDs": [],
  12. "gaTrackIDs": [],
  13. "ipv4s": [
  14. "1.1.1.1",
  15. "8.8.8.8"
  16. ],
  17. "ipv6s": [],
  18. "macAddresses": [],
  19. "md5s": [],
  20. "sha1s": [],
  21. "sha256s": [],
  22. "sha512s": [],
  23. "ssdeeps": [],
  24. "urls": [],
  25. "xmrs": []
  26. }
  27. $ echo "1.1.1.1 8.8.8.8" | ioc-extractor --only ipv4s | jq
  28. {
  29. "ipv4s": [
  30. "1.1.1.1",
  31. "8.8.8.8"
  32. ]
  33. }

As a Library

  1. import { extractIOC } from "ioc-extractor";
  2. const input = "1.1.1[.]1 google(.)com f6f8179ac71eaabff12b8c024342109b";
  3. const ioc = extractIOC(input);
  4. console.log(ioc.md5s);
  5. // => ['f6f8179ac71eaabff12b8c024342109b']
  6. console.log(ioc.ipv4s);
  7. // => ['1.1.1.1']
  8. console.log(ioc.domains);
  9. // => ['google.com']

extractIOC takes the following options:

If you want to extract a specific type of IoC, you can use an extract function by IoC type.

  1. import {
  2. refang,
  3. extractDomains,
  4. extractIPv4s,
  5. extractMD5s,
  6. } from "ioc-extractor";
  7. const input = "1.1.1[.]1 google(.)com f6f8179ac71eaabff12b8c024342109b";
  8. const refanged = refang(input);
  9. // => 1.1.1.1 google.com f6f8179ac71eaabff12b8c024342109b
  10. const ipv4s = extractIPv4s(refanged);
  11. // => ['1.1.1.1']
  12. const domains = extractDomains(refanged);
  13. // => ['google.com']
  14. const md5s = extractMD5s(refanged);
  15. // => ['f6f8179ac71eaabff12b8c024342109b']

Network related extract functions (e.g. extractDomains) can take the following options:

See docs for more details.

Alternatively, if you want to extract a list of specific IoC types at once, you can use partialExtractIOC.

  1. import { partialExtractIOC } from "ioc-extractor";
  2. const input = "1.1.1[.]1 google(.)com f6f8179ac71eaabff12b8c024342109b";
  3. const ioc = partialExtractIOC(input, ["ipv4s", "domains"]);
  4. console.log(ioc);
  5. // => {"ipv4s":["1.1.1.1"],"domains":["google.com"]}

IoC Types

This package supports the following IoCs:

  • Hashes: MD5, SHA1, SHA256, SHA512, SSDEEP
  • Networks: domain, email, IPv4, IPv6, URL, ASN
  • Hardwares: MAC address
  • Utilities: CVE (CVE ID)
  • Cryptocurrencies: BTC (BTC address), ETH (ETH address), XMR (XMR address)
  • Trackers: GA track ID (Google Analytics tracking ID), GA pub ID (Google Adsense Publisher ID)

Refang Techniques

For Networks IoCs, the following refang techniques are supported:

Techniques Defanged Refanged
. in spaces 1.1.1 . 1 1.1.1.1
. in brackets, parentheses, etc. 1.1.1[.]1 1.1.1.1
dot in brackets, parentheses, etc. example[dot]com example.com
Back slash before . example\.com example.com
/ in brackets, parentheses, etc. http://example.com[/]path http://example.com/path
:// in brackets, parentheses, etc. http[://]example.com http://example.com
: in brackets, parentheses, etc. http[:]//example.com http://example.com
@ in brackets, parentheses, etc. test[@]example.com test@example.com
at in brackets, parentheses, etc. test[at]example.com test@example.com
hxxp hxxps://example.com https://example.com
Partial 1.1.1[.1 1.1.1.1
Any combination hxxps[:]//test\.example[.)com[/]path https://test.example.com/path

Options

strict

Whether to do strict TLD matching or not. Defaults to true.

refang

Whether to do refang or not. Defaults to false.

punycode

Whether to do Punycode conversion or not. Defaults to false.

sort

Whether to sort values or not. Defaults to true.

Alternatives