Coder Social home page Coder Social logo

assafmo / xioc Goto Github PK

View Code? Open in Web Editor NEW
162.0 10.0 13.0 66 KB

Extract indicators of compromise from text, including "escaped" ones.

License: MIT License

Go 96.56% Shell 3.44%
ioc iocs extract extraction text-mining text-processing indicators-of-compromise command-line-tool command-line defang

xioc's Introduction

xioc

Extract indicators of compromise from text, including "escaped" ones like hxxp://banana.com, 1.1.1[.]1 and phish at malicious dot com.

CircleCI Coverage Status Go Report Card GoDoc

Installation

  • Download a precompiled binary from https://github.com/assafmo/xioc/releases

  • Or... Use go get:

    go get -u github.com/assafmo/xioc
  • Or... Use snap install (Ubuntu):

    snap install xioc
  • Or use Ubuntu PPA:

    curl -SsL https://assafmo.github.io/ppa/ubuntu/KEY.gpg | sudo apt-key add -
    sudo curl -SsL -o /etc/apt/sources.list.d/assafmo.list https://assafmo.github.io/ppa/ubuntu/assafmo.list
    sudo apt update
    sudo apt install xioc

Features

  • Extract IOCs (indicators of compromise) from an input text:
    • IPv4
    • IPv6
    • Domain
    • URL
    • Email
    • MD5
    • SHA1
    • SHA256
  • Translate some kinds of "escaping"/"defanging" techniques:
    • (dot), [dot], (.), [.], {.} to ..
    • (at), [at], (@), [@], {@} to @.
    • hxxp, hzzzp, hxxxp, hXXp, h__p, h**p to http.
  • Command line interface
  • Go library

Command line usage

$ xioc -h
Usage of xioc:
  -o string
        Extract only specified types.
        Types must be comma seperated. E.g: xioc -o "ip4,domain,url,md5"
        Available types:
                - ip4
                - ip6
                - domain
                - url
                - email
                - md5
                - sha1
                - sha256
  -v    Print version and exit
$ REPORT="https://unit42.paloaltonetworks.com/digital-quartermaster-scenario-demonstrated-in-attacks-against-the-mongolian-government/"
$ lynx -dump "$REPORT" | xioc
sha256  5beb50d95c1e720143ca0004f5172cb8881d75f6c9f434ceaff59f34fa1fe378
domain  energy.gov.mn
email   [email protected]
sha256  10090692ff40758a08bd66f806e0f2c831b4b9742bbf3d19c250e778de638f57
# ...
$ REPORT="https://unit42.paloaltonetworks.com/digital-quartermaster-scenario-demonstrated-in-attacks-against-the-mongolian-government/"
$ lynx -dump "$REPORT" | xioc -o email,sha256
sha256  5beb50d95c1e720143ca0004f5172cb8881d75f6c9f434ceaff59f34fa1fe378
email   [email protected]
sha256  10090692ff40758a08bd66f806e0f2c831b4b9742bbf3d19c250e778de638f57
email   [email protected]
# ...

Library usage

Full API:
GoDoc

package main

import (
	"fmt"

	"github.com/assafmo/xioc/xioc"
)

func main() {
	input := `e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
	banana.com
	hxxp://i.robot.com/robots.txt
	1.2.3.4
	1.1.1[.]1
	info at gmail dot com
	hxxps://m.twitter[dot]com/`

	fmt.Println(xioc.ExtractDomains(input)) // => [i.robot.com m.twitter.com gmail.com banana.com]
	fmt.Println(xioc.ExtractSHA256s(input)) // => [e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855]
	fmt.Println(xioc.ExtractMD5s(input))    // => []
	fmt.Println(xioc.ExtractIPv4s(input))   // => [1.2.3.4 1.1.1.1]
	fmt.Println(xioc.ExtractURLs(input))    // => [http://i.robot.com/robots.txt https://m.twitter.com/]
	fmt.Println(xioc.ExtractEmails(input))  // => [[email protected]]
}

Sources

xioc's People

Contributors

assafmo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xioc's Issues

Add streaming search support

@philpraxis:

On input, if non-allocating aka streaming search support could be implemented (it looks like not it's not, I didn't look at the source), that would be a huge plus since you will have arbitrarily long input lines in your input.

URL: fix trailing ")"

Sometimes URLs are inside parenthesis, e.g. (https://google.com).
This results in returning https://google.com) because the regex starts with http and also ) is legal character within a URL.

Support lines bigger than 64k bytes

$ python3 -c "print('A'*6553)" | ~/go/bin/xioc -o "ip4,domain,url" 
$

OK !

$ python3 -c "print('A'*65536)" | ~/go/bin/xioc -o "ip4,domain,url" 
2019/01/21 13:18:49 bufio.Scanner: token too long
$ 

NOT OK

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.