alterations

package
v3.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

type Cache struct {
	sync.RWMutex
	Counters map[string]int
}

Cache maintains counters for word usage within alteration techniques.

func NewCache

func NewCache(seed []string) *Cache

NewCache returns an initialized Cache.

func (*Cache) Update

func (c *Cache) Update(word string) int

Update increments the count for the provided word.

type LenDist

type LenDist struct {
	Count float64
	Freq  float64
}

LenDist provides a counter and frequency across peer elements.

type MarkovModel

type MarkovModel struct {
	sync.Mutex
	Ngrams map[string]map[rune]*LenDist
	// contains filtered or unexported fields
}

MarkovModel trains on DNS names and provides data for generating name guesses.

func NewMarkovModel

func NewMarkovModel(ngramSize int) *MarkovModel

NewMarkovModel returns a MarkovModel used for training on and generating DNS names.

func (*MarkovModel) AddSubdomain

func (m *MarkovModel) AddSubdomain(name string)

AddSubdomain accepts a FQDN and adds the largest proper subdomain to the collection maintained by the model.

func (*MarkovModel) GenerateLabel

func (m *MarkovModel) GenerateLabel() string

GenerateLabel returns a valid DNS name label based on the trained model.

func (*MarkovModel) GenerateNames

func (m *MarkovModel) GenerateNames(num int, subdomains ...string) []string

GenerateNames returns 'num' guesses for each of the subdomains provided. If no subdomains are provided, all the subdomains previously added to the model will be used instead.

func (*MarkovModel) NgramSize

func (m *MarkovModel) NgramSize() int

NgramSize returns the maximum size ngrams used by this markov model.

func (*MarkovModel) Subdomains

func (m *MarkovModel) Subdomains() []string

Subdomains returns all the subdomain names in the collection maintained by the model.

func (*MarkovModel) TotalTrainings

func (m *MarkovModel) TotalTrainings() int

TotalTrainings returns the number of times the model has been trained.

func (*MarkovModel) Train

func (m *MarkovModel) Train(name string)

Train enriches the model adding the name provided to the existing data.

type State

type State struct {
	MinForWordFlip int
	EditDistance   int
	Prefixes       *Cache
	Suffixes       *Cache
}

State maintains the word prefix and suffix counters.

func NewState

func NewState(wordlist []string) *State

NewState returns an initialized State.

func (*State) AddPrefixWord

func (s *State) AddPrefixWord(name string) []string

AddPrefixWord appends a subdomain name to a prefix.

func (*State) AddSuffixWord

func (s *State) AddSuffixWord(name string) []string

AddSuffixWord appends a suffix to a subdomain name.

func (*State) AppendNumbers

func (s *State) AppendNumbers(name string) []string

AppendNumbers appends a number to a subdomain name.

func (*State) FlipNumbers

func (s *State) FlipNumbers(name string) []string

FlipNumbers flips numbers in a subdomain name.

func (*State) FlipWords

func (s *State) FlipWords(name string) []string

FlipWords flips prefixes and suffixes found within the provided name.

func (*State) FuzzyLabelSearches

func (s *State) FuzzyLabelSearches(name string) []string

FuzzyLabelSearches returns new names generated by making slight mutations to the provided name.

Jump to

Keyboard shortcuts

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