utils

package
v0.0.98 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package utils provides utility functions used across the networkscan application.

Package utils provides stealth and timing utility functions for networkscan operations.

Package utils provides wordlist resolution utilities for the networkscan application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateDelayWithJitter added in v0.0.68

func CalculateDelayWithJitter(baseDelaySeconds int, jitterPercent int) time.Duration

CalculateDelayWithJitter calculates sleep duration with optional jitter. baseDelaySeconds: base delay in seconds jitterPercent: jitter percentage (0-100) to apply random variance Returns: final delay duration with jitter applied

func CalculateStealthDelay added in v0.0.68

func CalculateStealthDelay(sleepPtr *int, jitterPtr *int) time.Duration

CalculateStealthDelay calculates a delay with jitter from optional sleep and jitter parameters. This is a convenience function that handles nil pointer checks. sleepPtr: optional pointer to sleep delay in seconds (can be nil) jitterPtr: optional pointer to jitter percentage 0-100 (can be nil) Returns: final delay duration with jitter applied, or 0 if no sleep specified

func GenerateRandomString added in v0.0.61

func GenerateRandomString(length int) string

GenerateRandomString generates a random string of specified length using alphanumeric characters. This is useful for creating temporary file/directory names for testing purposes.

func GenerateUsernamesByScheme added in v0.0.61

func GenerateUsernamesByScheme(scheme pentest.UsernameScheme) ([]string, error)

GenerateUsernamesByScheme generates usernames based on the specified scheme

func GenerateUsernamesWithLimit added in v0.0.61

func GenerateUsernamesWithLimit(scheme pentest.UsernameScheme, limit int) ([]string, error)

GenerateUsernamesWithLimit generates a limited number of usernames based on the scheme

func GetDefaultPortForService added in v0.0.51

func GetDefaultPortForService(service pentestfern.SprayTargetService) int

GetDefaultPortForService returns the default port for a given service type

func GetEntriesFromTXTFiles added in v0.0.35

func GetEntriesFromTXTFiles(paths []string) ([]string, error)

GetEntriesFromTXTFiles reads and combines entries from multiple text files. It takes a list of file paths, reads each file line by line, and returns a combined list of all entries. Each line in the input files becomes a separate entry. Returns an error if any file cannot be opened or read.

func GetIPs added in v0.0.68

func GetIPs(host string) ([]net.IP, error)

GetIPs resolves a hostname to IP addresses

func GetUsernameSchemeDescription added in v0.0.61

func GetUsernameSchemeDescription(scheme pentest.UsernameScheme) string

GetUsernameSchemeDescription returns a human-readable description of the scheme

func IncIP added in v0.0.68

func IncIP(ip net.IP)

IncIP increments an IP address

func IsPrivilegedForNetworkScanning added in v0.0.88

func IsPrivilegedForNetworkScanning() bool

IsPrivilegedForNetworkScanning checks if the current process has the necessary privileges for network scanning operations that require raw sockets (like ICMP ping). On Windows, this checks if the process is running with Administrator privileges. On Unix-like systems, this checks for root privileges or CAP_NET_RAW capability.

func ParseHostPort added in v0.0.51

func ParseHostPort(target string, defaultPort int) (string, int)

ParseHostPort parses a target string into host and port components. If no port is provided, uses the specified default port. Returns the host and port as separate values.

func ParsePort added in v0.0.50

func ParsePort(portStr string) int

ParsePort converts a port string to an integer. Returns 0 if the port string is invalid or out of range (1-65535).

func ParseTargetHosts added in v0.0.68

func ParseTargetHosts(target string) ([]string, error)

ParseTargetHosts expands CIDR ranges and hostnames into individual IP addresses

func ParseTargetHostsWithMapping added in v0.0.78

func ParseTargetHostsWithMapping(target string) ([]string, map[string]string, error)

ParseTargetHostsWithMapping expands CIDR ranges and hostnames into individual IP addresses and returns a mapping from IP addresses back to their original hostnames (if resolved from FQDNs)

func ParseWordlistTypes added in v0.0.51

func ParseWordlistTypes(wordlistStrings []string) ([]pentestfern.WordlistType, error)

ParseWordlistTypes converts string slice to WordlistType enums

Types

type LDAPActionParser added in v0.0.54

type LDAPActionParser struct{}

LDAPActionParser handles LDAP-specific action parsing

func GetLDAPParser added in v0.0.54

func GetLDAPParser() *LDAPActionParser

GetLDAPParser returns the singleton LDAP action parser

func (*LDAPActionParser) ContainsAction added in v0.0.54

func (p *LDAPActionParser) ContainsAction(actions []ldapfern.PentestLdapAction, target ldapfern.PentestLdapAction) bool

func (*LDAPActionParser) GetValidActions added in v0.0.54

func (p *LDAPActionParser) GetValidActions() []string

func (*LDAPActionParser) ParseActions added in v0.0.54

func (p *LDAPActionParser) ParseActions(actionStrings []string) ([]ldapfern.PentestLdapAction, error)

type MSRPCActionParser added in v0.0.80

type MSRPCActionParser struct{}

MSRPCActionParser handles MSRPC-specific action parsing

func GetMSRPCParser added in v0.0.80

func GetMSRPCParser() *MSRPCActionParser

GetMSRPCParser returns the singleton MSRPC action parser

func (*MSRPCActionParser) ContainsAction added in v0.0.80

func (p *MSRPCActionParser) ContainsAction(actions []msrpcfern.PentestMsrpcAction, target msrpcfern.PentestMsrpcAction) bool

func (*MSRPCActionParser) GetValidActions added in v0.0.80

func (p *MSRPCActionParser) GetValidActions() []string

func (*MSRPCActionParser) ParseActions added in v0.0.80

func (p *MSRPCActionParser) ParseActions(actionStrings []string) ([]msrpcfern.PentestMsrpcAction, error)

type SMBActionParser added in v0.0.51

type SMBActionParser struct{}

SMBActionParser handles SMB-specific action parsing

func GetSMBParser added in v0.0.51

func GetSMBParser() *SMBActionParser

GetSMBParser returns the singleton SMB action parser

func (*SMBActionParser) ContainsAction added in v0.0.51

func (p *SMBActionParser) ContainsAction(actions []smbfern.PentestSmbAction, target smbfern.PentestSmbAction) bool

func (*SMBActionParser) GetValidActions added in v0.0.51

func (p *SMBActionParser) GetValidActions() []string

func (*SMBActionParser) ParseActions added in v0.0.51

func (p *SMBActionParser) ParseActions(actionStrings []string) ([]smbfern.PentestSmbAction, error)

type SSHActionParser added in v0.0.51

type SSHActionParser struct{}

SSHActionParser handles SSH-specific action parsing

func GetSSHParser added in v0.0.51

func GetSSHParser() *SSHActionParser

GetSSHParser returns the singleton SSH action parser

func (*SSHActionParser) ContainsAction added in v0.0.51

func (p *SSHActionParser) ContainsAction(actions []sshfern.PentestSshAction, target sshfern.PentestSshAction) bool

func (*SSHActionParser) GetValidActions added in v0.0.51

func (p *SSHActionParser) GetValidActions() []string

func (*SSHActionParser) ParseActions added in v0.0.51

func (p *SSHActionParser) ParseActions(actionStrings []string) ([]sshfern.PentestSshAction, error)

type TelnetActionParser added in v0.0.51

type TelnetActionParser struct{}

TelnetActionParser handles Telnet-specific action parsing

func GetTelnetParser added in v0.0.51

func GetTelnetParser() *TelnetActionParser

GetTelnetParser returns the singleton Telnet action parser

func (*TelnetActionParser) ContainsAction added in v0.0.51

func (*TelnetActionParser) GetValidActions added in v0.0.51

func (p *TelnetActionParser) GetValidActions() []string

func (*TelnetActionParser) ParseActions added in v0.0.51

func (p *TelnetActionParser) ParseActions(actionStrings []string) ([]telnetfern.PentestTelnetAction, error)

type WordlistResolver added in v0.0.51

type WordlistResolver struct {
	// contains filtered or unexported fields
}

WordlistResolver provides functionality to resolve wordlist enums to file paths

func GetDefaultWordlistResolver added in v0.0.51

func GetDefaultWordlistResolver() *WordlistResolver

GetDefaultWordlistResolver returns a WordlistResolver configured for the container environment

func NewWordlistResolver added in v0.0.51

func NewWordlistResolver(baseConfigDir string) *WordlistResolver

NewWordlistResolver creates a new WordlistResolver with the specified base config directory

func (*WordlistResolver) GetConfigFilePath added in v0.0.64

func (wr *WordlistResolver) GetConfigFilePath(relativePath string) string

GetConfigFilePath returns the full path for a file within the config directory It automatically handles container vs development environment paths

func (*WordlistResolver) GetPasswordWordlists added in v0.0.51

func (wr *WordlistResolver) GetPasswordWordlists(passwordLists []pentestfern.WordlistType) ([]string, error)

GetPasswordWordlists loads password wordlists based on the config

func (*WordlistResolver) GetUsernameWordlists added in v0.0.51

func (wr *WordlistResolver) GetUsernameWordlists(usernameLists []pentestfern.WordlistType) ([]string, error)

GetUsernameWordlists loads username wordlists based on the config

func (*WordlistResolver) LoadWordlistEntries added in v0.0.51

func (wr *WordlistResolver) LoadWordlistEntries(wordlistTypes []pentestfern.WordlistType) ([]string, error)

LoadWordlistEntries loads entries from resolved wordlist paths

func (*WordlistResolver) ResolveWordlistPaths added in v0.0.51

func (wr *WordlistResolver) ResolveWordlistPaths(wordlistTypes []pentestfern.WordlistType) ([]string, error)

ResolveWordlistPaths takes wordlist types and resolves them to actual file paths

Jump to

Keyboard shortcuts

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