common

package
v0.0.0-...-a2fba50 Latest Latest
Warning

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

Go to latest
Published: May 20, 2025 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DEFAULT_TIMES     = 4
	DEFAULT_MOCK      = "http://localhost:1080"
	DEFAULT_PROCESSES = 1
	DEFAULT_LOGLEVEL  = LOG_NORMAL
)
View Source
const (
	LOG_VERBOSE = iota // Verbose and/or debug
	LOG_NORMAL         // Moderate
	LOG_QUIET          // Severe only
)
View Source
const (
	// Host states
	HostUp = iota
	HostDown
	HostUnknown
)

Variables

This section is empty.

Functions

func AddSeparator

func AddSeparator(num string, format int, separator string) string

Adds a separator S in middle, according to given format

Formats:

  • 0: NNNSNNNSNNNN - Example: phone number
  • 1: NNNNSNNNNSNNNNSNNNN - Example: credit card

Another format will return the string untouched

func ArgsHaveTimes

func ArgsHaveTimes(args ...string) int

func AttackRunner

func AttackRunner(attemptHandle AttemptHander, estimateDuration time.Duration) error

func CanLog

func CanLog(messageLevel int) bool

func CheckHostState

func CheckHostState(url string) (state, httpCode int)

func CheckURI

func CheckURI(testUrl string) (err error)

func CheckURL

func CheckURL(testUrl string) (err error)

func CompareSubdomains

func CompareSubdomains(a, b string) int

func Digits

func Digits(n int) int

Returns how many digits are in a number

func FileRead

func FileRead(filePath string) (data []byte, err error)

func FileWrite

func FileWrite(filePath string, data []byte) (err error)

func FindPos

func FindPos[T string](needle T, haystack []T) int

func GeneraApellidosCol

func GeneraApellidosCol() string

func GeneraCelColombia

func GeneraCelColombia() string

func GeneraCiudadDeptoColombia

func GeneraCiudadDeptoColombia() (string, string)

func GeneraIP

func GeneraIP() string

func GeneraNIPcolombia

func GeneraNIPcolombia() string

func GeneraNombresApellidosPersonaCol

func GeneraNombresApellidosPersonaCol(noAccents bool) (nombres, apellidos string)

func GeneraNombresApellidosPersonaCombinadosCol

func GeneraNombresApellidosPersonaCombinadosCol(noAccents bool) (s string)

func GeneraNombresHombreCol

func GeneraNombresHombreCol() (s string)

func GeneraNombresMujerCol

func GeneraNombresMujerCol() (s string)

func GeneraPin

func GeneraPin(digitos int) string

func GetAllCmds

func GetAllCmds(t TargetInterface) (opts []menu.CommandOption)

func JoinSlices

func JoinSlices[T any](slices ...[]T) []T

func LogLevelsHelp

func LogLevelsHelp() (s string)

func MergeDicts

func MergeDicts(source StorageDict, target TargetDict, state bool)

mergeDicts merges the source dictionary into the target dictionary, with a preset state for each entry.

func MinInt

func MinInt(a, b int) int

func PickRand

func PickRand[T any](options []T) T

Picks a random element of a slice

func RandDelayRange

func RandDelayRange(min, max time.Duration)

Random delay in a range of time Duration. If min > max, values will be considered swapped!

Example:

RandDelayRange(3*time.Second, 5*time.Second)

is a random delay ranging from 3 to 5 seconds

Previous example is equivalent to:

RandDelayWindowed(4*time.Second, 2*time.Second)

func RandDelayWindowed

func RandDelayWindowed(duration, window time.Duration)

Delay within a random window of duration. The 'duration' is the middle/average delay of a 'window' of allowed deviations against the specified duration. If half of the window (the peak) exceeds the duration, the window will be trimmed to twice the duration

Example:

RandDelayWindowed(10*time.Second, 2*time.Second)

would be equivalent to a delay of 10 seconds, in average. The 2 seconds window, will give a range of +/- 1 second in which the final delay will be randomly ranging

Previous example, in other words, is equivalent to:

RandDelayRange(9*time.Second, 11*time.Second)

func RandEmail

func RandEmail(names string, year int) string

func RandPass1

func RandPass1(min, max int) string

func RandUserAgent

func RandUserAgent() string

func RandUserName

func RandUserName(p *gofakeit.PersonInfo) string

func ReadYamlFile

func ReadYamlFile(filePath string, v any) (err error)

func RemoveAccents

func RemoveAccents(s *string)

func RunJS

func RunJS(jsCode string, result interface{}) (err error)

Runs a JS snippet. The snippet should only print to console a json serialized object. Uses installed nodejs to run the code.

func SetMockServer

func SetMockServer(serverUrl string) (err error)

func SortMirrors

func SortMirrors(stDict StorageDict)

func TimedCall

func TimedCall(each, limit time.Duration, handler func() (iterateAgain bool))

Calls a handler repeatedly in a limit time and if handler needs it.

The handler function will be called at most "limit"/"each" times while it returns true

func WriteYamlFile

func WriteYamlFile(filePath string, v any) (err error)

func YamlParse

func YamlParse(data []byte, v any) error

func YamlSerialize

func YamlSerialize(v any) (out []byte, err error)

Types

type AttemptHander

type AttemptHander func()

type Config

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

func GetConfig

func GetConfig() *Config

func (*Config) ClearFlags

func (c *Config) ClearFlags()

func (*Config) GetTarget

func (c *Config) GetTarget() string

func (*Config) GetThreads

func (c *Config) GetThreads() int

func (*Config) GetTimes

func (c *Config) GetTimes() int

func (*Config) ParseFlags

func (c *Config) ParseFlags()

type CustErr

type CustErr struct {
	Explain string
	Detail  error
}

func (*CustErr) Error

func (c *CustErr) Error() string

type Discord

type Discord struct {
	ReqHandler
	Webhook string
	// contains filtered or unexported fields
}

func (*Discord) DetectHookFromString

func (m *Discord) DetectHookFromString(haystack string)

func (*Discord) DetectHookFromURL

func (m *Discord) DetectHookFromURL(haystackUrl string) (e error)

func (*Discord) ResetAltHook

func (m *Discord) ResetAltHook()

func (*Discord) SendDiscord

func (m *Discord) SendDiscord(data HookData)

func (*Discord) SetAltHook

func (m *Discord) SetAltHook(hook string) bool

type DummyType

type DummyType struct{}

type HookData

type HookData struct {
	User    string `json:"username,omitempty"`
	Content string `json:"content"`
}
type MenuManager_t struct {
	// contains filtered or unexported fields
}
var MainMenu MenuManager_t
func (mm *MenuManager_t) Add(entry menu.CommandOption)
func (mm *MenuManager_t) Created(name string) bool
func (mm *MenuManager_t) GetAll() []menu.CommandOption
func (mm *MenuManager_t) Register(target TargetInterface)

type MirrorOptions

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

func (*MirrorOptions) HasOption

func (m *MirrorOptions) HasOption(opt string) bool

func (*MirrorOptions) ParseOptions

func (m *MirrorOptions) ParseOptions(opts string)

type ReqHandler

type ReqHandler struct {

	// Request object of the last HTTP request
	Request *http.Request

	// Response object of the last HTTP request
	Response *http.Response
	// contains filtered or unexported fields
}

func (*ReqHandler) InitClient

func (r *ReqHandler) InitClient()

Initializes the HTTP client

func (*ReqHandler) PrintCookies

func (r *ReqHandler) PrintCookies(u *url.URL)

func (*ReqHandler) SendGet

func (r *ReqHandler) SendGet(getUrl string, urlParams, additionalHeaders []SimpleTerm, filler interface{}) (err error, lastStep uint8)

func (*ReqHandler) SendJSON

func (r *ReqHandler) SendJSON(target string, payload interface{}, additionalHeaders []SimpleTerm, filler interface{}) (err error, lastStep uint8)

func (*ReqHandler) SendMultipart

func (r *ReqHandler) SendMultipart(targetURL string, values map[string]io.Reader, additionalHeaders []SimpleTerm, filler interface{}) (err error, lastStep uint8)

To send multipart/form-data

func (*ReqHandler) SendPostEncoded

func (r *ReqHandler) SendPostEncoded(postUrl string, params, additionalHeaders []SimpleTerm, filler interface{}) (err error, lastStep uint8)

func (*ReqHandler) UseJar

func (r *ReqHandler) UseJar(use bool)

Defines if a cookie jar will be used in subsequent requests. Also calls InitClient()

type SafeCounter

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

func NewSafeCounter

func NewSafeCounter(init int) *SafeCounter

func (*SafeCounter) Add

func (c *SafeCounter) Add() int

func (*SafeCounter) Read

func (c *SafeCounter) Read() int

type SimpleTerm

type SimpleTerm struct {
	K string // Key
	V string // Value
}

type StorageDict

type StorageDict map[string]([]string)

func SplitDicts

func SplitDicts(dict TargetDict) (alive, down StorageDict)

splitDicts splits the target dictionary into two separate dictionaries: one for alive hosts and one for down hosts.

type TargetBase

type TargetBase struct {
	Prefix, Description string
}

func (*TargetBase) GetProps

func (t *TargetBase) GetProps() TargetBase

type TargetDict

type TargetDict map[string](map[string]bool)

type TargetInterface

type TargetInterface interface {
	GetMirrors() []string
	GetProps() TargetBase
	Handler(mirror string)
	MirrorStatus(mirror string) int
	EstimateDuration() time.Duration
}

type TargetSimple

type TargetSimple struct {
	TargetBase
	// contains filtered or unexported fields
}

func (*TargetSimple) GetMirrors

func (t *TargetSimple) GetMirrors() []string

func (*TargetSimple) SetMirrors

func (t *TargetSimple) SetMirrors(m *[]string)

type TargetWithParams

type TargetWithParams struct {
	TargetBase
	// contains filtered or unexported fields
}

func (*TargetWithParams) GetMirrorParams

func (t *TargetWithParams) GetMirrorParams(mirror string) []string

func (*TargetWithParams) GetMirrors

func (t *TargetWithParams) GetMirrors() (names []string)

func (*TargetWithParams) SetMirrors

func (t *TargetWithParams) SetMirrors(m *[][]string)

type Telegram

type Telegram struct {
	ReqHandler
	Token     string
	Chat      string
	ParseMode string
	// contains filtered or unexported fields
}

func (*Telegram) ResetAltChat

func (m *Telegram) ResetAltChat()

func (*Telegram) ResetAltToken

func (m *Telegram) ResetAltToken()

func (*Telegram) SendToTelegram

func (m *Telegram) SendToTelegram(msg string)

Send Message to a Telegram Chat

Please take care of not exceeding Telegram fair usage: - https://rollout.com/integration-guides/telegram-bot-api/api-essentials - https://core.telegram.org/bots/faq#my-bot-is-hitting-limits-how-do-i-avoid-this

func (*Telegram) SetAltChat

func (m *Telegram) SetAltChat(chat string) bool

func (*Telegram) SetAltToken

func (m *Telegram) SetAltToken(token string) bool

type TgMsg

type TgMsg struct {
	ChatID    string `json:"chat_id"`
	Text      string `json:"text"`
	ParseMode string `json:"parse_mode,omitempty"`
}

Jump to

Keyboard shortcuts

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