Documentation
¶
Overview ¶
Package utils provides utility functions for the application.
Index ¶
- func CheckASCIIString(str string) bool
- func CheckAreArraysEqual(a, b []string) bool
- func CheckAreMapsEqual(a, b map[string]int) bool
- func CheckHexString(s string) bool
- func CombineMaps(maps ...map[string]int) map[string]int
- func ConvertMultiByteCharToIteratingRule(index int, str string) string
- func ConvertMultiByteCharToRule(str string) string
- func GenerateNGrams(text string, n int) []string
- func GeneratePassphrase(text string, n int) []string
- func GetFilesInDirectory(dir string) ([]string, error)
- func GetMemoryUsage() float64
- func IncrementIteratingRuleCall(s string) string
- func IsFileSystemDirectory(path string) bool
- func IsValidFile(path string) bool
- func IsValidURL(str string) bool
- func LoadStdinToMap(scanner models.Scanner) (map[string]int, error)
- func ProcessURL(url string, ch chan<- string, wg *sync.WaitGroup, parsingMode int, ...)
- func ProcessURLFile(filePath string, ch chan<- string, wg *sync.WaitGroup, parsingMode int, ...)
- func ReadFilesToMap(fs models.FileSystem, filenames []string) map[string]int
- func ReadJSONToArray(fs models.FileSystem, filenames []string) []models.TemplateFileOperation
- func ReadURLsToMap(urls []string, parsingMode int, debugMode int) (map[string]int, error)
- func ReplaceAllSubstring(original string, replacements map[string]int) []string
- func ReplaceSubstring(original string, replacements map[string]int) []string
- func ReverseString(s string) string
- func SplitBySeparatorString(s string, sep string) []string
- func SubstringMap(sMap map[string]int, sIndex int, eIndex int, bypass bool, debug bool) map[string]int
- func TrackLoadTime(done <-chan bool, work string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckASCIIString ¶
CheckASCIIString checks to see if a string only contains ascii characters
Args:
str (string): Input string to check
Returns:
(bool): If the string only contained ASCII characters
func CheckAreArraysEqual ¶
CheckAreArraysEqual checks if two arrays are equal by comparing the length of the arrays and the values of the elements in the arrays. If the arrays are equal, the function returns true, otherwise it returns false.
Args: a ([]string): The first array to compare b ([]string): The second array to compare
Returns: bool: True if the arrays are equal, false otherwise
func CheckAreMapsEqual ¶
CheckAreMapsEqual checks if two maps are equal by comparing the length of the maps and the values of the keys in the maps. If the maps are equal, the function returns true, otherwise it returns false.
Args:
a (map[string]int): The first map to compare b (map[string]int): The second map to compare
Returns:
bool: True if the maps are equal, false otherwise
func CheckHexString ¶
CheckHexString is used to identify plaintext in the $HEX[...] format
Args:
s (str): The string to be evaluated
Returns:
(bool): Returns true if it matches and false if it did not
func CombineMaps ¶
CombineMaps combines any number of maps into a single map combining values for common keys and returning a new map
Args: maps ([]map[string]int): The maps to combine
Returns: map[string]int: A new map combining the values of the input maps
func ConvertMultiByteCharToIteratingRule ¶
ConvertMultiByteCharToIteratingRule converts non-ascii characters to a hashcat valid format for rule.CharToIteratingRule functions
Args:
index (int): Index to start the iteration str (string): Input string to transform
Returns:
returnStr (string): Converted string
func ConvertMultiByteCharToRule ¶
ConvertMultiByteCharToRule converts non-ascii characters to a hashcat valid format for rule.CharToRule functions
Args:
str (string): Input string to transform
Returns:
returnStr (string): Converted string
func GenerateNGrams ¶ added in v0.3.0
GenerateNGrams generates n-grams from a string of text and returns a slice of n-grams
Args: text (string): The text to generate n-grams from n (int): The number of words in each n-gram
Returns: []string: A slice of n-grams
func GeneratePassphrase ¶ added in v0.3.4
GeneratePassphrase generates a passphrase from a string of text and returns a slice of passphrases
Args: text (string): The text to generate passphrases from n (int): The number of words in the passphrase
Returns: []string: A slice of passphrases
func GetFilesInDirectory ¶ added in v0.3.0
GetFilesInDirectory returns a slice of files in a directory by reading the directory and appending the files to a slice if they are not directories
Args: dir (string): The directory to read
Returns: []string: A slice of files in the directory
func GetMemoryUsage ¶ added in v0.4.0
func GetMemoryUsage() float64
GetMemoryUsage returns the current memory usage in megabytes
func IncrementIteratingRuleCall ¶
IncrementIteratingRuleCall increments the last character of a string for rules.CharToIteratingRules functions
For example, "i4" will be incremented to "i5", "iA" will be incremented to "IB"
Args:
s (string): Input string to increment
Returns:
output (string): Incremented string
func IsFileSystemDirectory ¶ added in v0.2.4
IsFileSystemDirectory checks to see if a string is a valid file system directory by checking if the path exists and if it is a directory
Args:
path (string): The path to check
Returns:
bool: True if the path is a directory, false otherwise
func IsValidFile ¶ added in v0.3.0
IsValidFile checks if a file exists and is not a directory by checking if the file exists
Args: path (string): The path to the file
Returns: bool: True if the file is valid, false otherwise
func IsValidURL ¶ added in v0.3.0
IsValidURL checks if a string is a valid URL by parsing the string
Args: str (string): The URL to check
Returns: bool: True if the URL is valid, false otherwise
func LoadStdinToMap ¶
LoadStdinToMap reads the contents of stdin and returns a map[string]int where the key is the line and the value is the frequency of the line in the input
Args:
scanner (models.Scanner): The scanner to read from stdin
Returns:
map[string]int: A map of lines from stdin error: An error if one occurred
func ProcessURL ¶
func ProcessURL(url string, ch chan<- string, wg *sync.WaitGroup, parsingMode int, debugMode int, sleepOnStart bool)
ProcessURL reads the contents of a URL and sends each sentence to the channel
Args:
url (string): The URL to read ch (chan<- string): The channel to send the sentences to wg (*sync.WaitGroup): The WaitGroup to signal when done parsingMode (int): Change parsing mode for URL input. [0 = Strict, 1 = Permissive, 2 = Maximum] [0-2]. debugMode (int): A flag to print debug information sleepOnStart (bool): A flag to sleep before starting the request
Returns:
None
func ProcessURLFile ¶ added in v0.3.0
func ProcessURLFile(filePath string, ch chan<- string, wg *sync.WaitGroup, parsingMode int, debugMode int)
ProcessURLFile reads the contents of a file containing URLs and sends each URL to the channel
Args: filePath (string): The path to the file containing URLs ch (chan<- string): The channel to send the URLs to wg (*sync.WaitGroup): The WaitGroup to signal when done parsingMode (int): Change parsing mode for URL input. [0 = Strict, 1 = Permissive, 2 = Maximum] [0-2]. debugMode (int): A flag to print debug information
Returns: None
func ReadFilesToMap ¶
func ReadFilesToMap(fs models.FileSystem, filenames []string) map[string]int
ReadFilesToMap reads the contents of the multiple files and returns a map of words
Args:
fs (FileSystem): The filesystem to read the files from (used for testing) filenames ([]string): The names of the files to read
Returns:
(map[string]int): A map of words from the files
func ReadJSONToArray ¶ added in v0.2.0
func ReadJSONToArray(fs models.FileSystem, filenames []string) []models.TemplateFileOperation
ReadJSONToArray reads the contents of a transformation template file and returns a slice of template structs.
Args:
fs (FileSystem): The filesystem to read the file from (used for testing) fileArray ([]string): The name of the files to read
Returns:
templates ([]models.TemplateFileOperation): The slice of template structs
func ReadURLsToMap ¶
ReadURLsToMap reads the contents of the multiple URLs and returns a map of words from the URLs. Supports files or directories containing URLs.
Args:
urls ([]string): The URLs to read parsingMode (int): Change parsing mode for URL input. [0 = Strict, 1 = Permissive, 2 = Maximum] [0-2]. debugMode (int): A flag to print debug information
Returns:
map[string]int: A map of words from the URLs error: An error if one occurred
func ReplaceAllSubstring ¶ added in v0.2.5
ReplaceAllSubstring replaces all instances of a substring in a string with a new substring if the substring is found in the original string. All of the replacements are applied to the original string. The new substring is determined by the key in the replacements map separated by a colon character.
Args:
original (string): The original string replacements (map[string]int): A map of substrings to replace
Returns:
[]string: The original string with all instances of the substring replaced
func ReplaceSubstring ¶
ReplaceSubstring replaces all instances of a substring in a string with a new substring if the substring is found in the original string. The new substring is determined by the key in the replacements map separated by a colon character.
Args:
original (string): The original string replacements (map[string]int): A map of substrings to replace
Returns:
[]string: The original string with all instances of the substring replaced
func ReverseString ¶
ReverseString will return a string in reverse
Args:
str (string): Input string to transform
Returns:
(string): Transformed string
func SplitBySeparatorString ¶
SplitBySeparatorString splits a string by a separator string and returns a slice with the separator string included
Args:
s (string): The string to split sep (string): The separator string
Returns:
[]string: A slice of strings with the separator string included
func SubstringMap ¶ added in v0.2.2
func SubstringMap(sMap map[string]int, sIndex int, eIndex int, bypass bool, debug bool) map[string]int
SubstringMap returns a map of substrings from a map of strings starting at the start index and ending at the end index. If the bypass flag is set to true, the function will print to stdout and return an empty map. If the end index is greater than the length of the string, the function will use the length of the string as the end index for that string.
Args:
sMap (map[string]int): The map of substrings sIndex (int): The start index of the substring eIndex (int): The end index of the substring bypass (bool): Skip returning the map and print to stdout debug (bool): A flag to print debug information
Returns:
map[string]int: A map of substrings
func TrackLoadTime ¶ added in v0.4.0
TrackLoadTime tracks the time it takes to load the input and prints the time
Args: done (chan bool): channel to use to track tasks work (string): string used in status printing
Returns: None
Types ¶
This section is empty.