ioc

package
v0.0.0-...-1fa144e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

Types of all IOCs

Functions

func GetIOCsCounts

func GetIOCsCounts(iocs []*IOC) map[Type]int

GetIOCsCounts Given []IOC return count of each

func GetIOCsReader

func GetIOCsReader(ctx context.Context, reader io.Reader, getFangedIOCs bool, matches chan *IOC) error

GetIOCsReader Get iocs from reader TODO: This is not deterministic output

Example
reader := strings.NewReader(`this is a bad url http[://]google[.]com/path`)

iocs := make(chan *IOC)
go func() {
	defer close(iocs)
	err := GetIOCsReader(context.Background(), reader, false, iocs)
	if err != nil {
		panic(err)
	}
}()
for ioc := range iocs {
	// Print IOC
	fmt.Println(ioc)
}
Output:

func PrintIOCs

func PrintIOCs(iocs []*IOC, format string) string

PrintIOCs Takes IOCs and prints them according to the format desired Format can be csv or table

func PrintIOCsCSV

func PrintIOCsCSV(iocs []*IOC) string

PrintIOCsCSV Takes []IOC and returns them in a csv format

func PrintIOCsStats

func PrintIOCsStats(iocs []*IOC) string

PrintIOCsStats Given iocs print the stats associated with them

func PrintIOCsTable

func PrintIOCsTable(iocs []*IOC) string

PrintIOCsTable Takes []IOC and returns them in a csv format

func StandardizeDefangs

func StandardizeDefangs(iocs []*IOC)

StandardizeDefangs will run all IOCs through a Fang() then Defang(), which will make all the IOCs of the same defanged style.

Types

type IOC

type IOC struct {
	IOC  string
	Type Type // hash, url, domain, file
}

IOC Struct to store an IOC and it's type

func GetIOCs

func GetIOCs(data string, getFangedIOCs bool) []*IOC

GetIOCs Return a slice of IOCs from the provided data. getFangedIOCs will also return IOCs that are fanged (ex: google.com).

Example
data := `this is a bad url http[://]google[.]com/path`

iocs := GetIOCs(data, false)
iocs = SortByType(iocs)
StandardizeDefangs(iocs)
fmt.Println(iocs)
Output:

[google[.]com|Domain hxxp[://]google[.]com/path|URL]

func GetIOCsFromHTML

func GetIOCsFromHTML(htmlContent *string) ([]*IOC, error)

GetIOCsFromHTML Takes a html page as a string and will extract the IOCs

func GetIOCsFromRSS

func GetIOCsFromRSS(ctx context.Context, url string) ([]*IOC, error)

GetIOCsFromRSS Given RSS feed url, parse articles for IOCs

func GetIOCsFromURLPage

func GetIOCsFromURLPage(req *http.Request) ([]*IOC, error)

GetIOCsFromURLPage Given a url get IOCs from the _text_ of the page

func ParseIOC

func ParseIOC(ioc string) *IOC

ParseIOC Parses a single IOC and gets its type. It will only return the highest IOC type (so if it's an email, it will return the email, not the domain in the email)

func SortByType

func SortByType(iocs []*IOC) []*IOC

SortByType takes a group of IOCs and sorts them by their type

func (*IOC) Defang

func (ioc *IOC) Defang() *IOC

Defang Takes an IOC and defangs it using the standard defangReplacements

Example
ioc := &IOC{IOC: "google.com", Type: Domain}
ioc = ioc.Defang()
fmt.Println(ioc)
ioc = ioc.Fang()
fmt.Println(ioc)
Output:

google[.]com|Domain
google.com|Domain

func (*IOC) Fang

func (ioc *IOC) Fang() *IOC

Fang Takes an IOC and removes the defanging stuff from it (converts to a fanged IOC). Ex: john[AT]gmail[dot]com -> john@gmail.com

func (*IOC) IsFanged

func (ioc *IOC) IsFanged() bool

IsFanged Takes an IOC and returns if it is fanged. Non fanging types (bitcoin, hashes, file, cve) are always determined to not be fanged

func (*IOC) String

func (ioc *IOC) String() string

String Takes an IOC and prints in csv form: IOC|Type

type Type

type Type int

Type Type of IOC (bitcoin, sha1, etc)

const (
	Unknown Type = iota
	Bitcoin
	MD5
	SHA1
	SHA256
	SHA512
	Domain
	Email
	IPv4
	IPv6
	URL
	File
	CVE
	CAPEC
	CWE
	CPE
)

Types ordered in list of largest to smallest (so an email is > domain since an email contains a domain)

func (Type) String

func (i Type) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL