Documentation
¶
Index ¶
- type CrossoverEngine
- type CrossoverFunc
- type CrossoverType
- type EvolutionConfig
- type EvolutionEngine
- type FitnessCriterion
- type FitnessEvaluator
- type GenerationStats
- type GeneratorConfig
- type GeneratorMetrics
- type Logger
- type MutationConstraints
- type MutationEngine
- type MutationFunc
- type MutationParams
- type MutationType
- type Payload
- type PayloadConstraints
- type PayloadFeatures
- type PayloadGenerator
- func (g *PayloadGenerator) EvolveFromSuccess(successful *Payload, variations int) []*Payload
- func (g *PayloadGenerator) GenerateBatch(ctx context.Context, objective string, count int, ...) ([]*Payload, error)
- func (g *PayloadGenerator) GeneratePayload(ctx context.Context, objective string, constraints PayloadConstraints) (*Payload, error)
- func (g *PayloadGenerator) LearnFromFeedback(payload *Payload, success bool, response string)
- type PopulationTracker
- type SeedBank
- type SelectionMethod
- type SemanticComponents
- type SuccessCache
- type SuccessHistory
- type SuccessRecord
- type TournamentSelection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CrossoverEngine ¶
type CrossoverEngine struct {
// contains filtered or unexported fields
}
CrossoverEngine handles payload recombination
type CrossoverFunc ¶
CrossoverFunc combines two payloads
type CrossoverType ¶
type CrossoverType string
CrossoverType categorizes crossover methods
const ( SinglePointCrossover CrossoverType = "single_point" TwoPointCrossover CrossoverType = "two_point" UniformCrossover CrossoverType = "uniform" SemanticCrossover CrossoverType = "semantic" TechniqueCrossover CrossoverType = "technique" TokenLevelCrossover CrossoverType = "token" )
type EvolutionConfig ¶
type EvolutionConfig struct {
SelectionPressure float64
MutationDecay float64 // Reduce mutation over time
DiversityPressure float64
ConvergencePatience int // Generations without improvement
}
EvolutionConfig configures evolution parameters
type EvolutionEngine ¶
type EvolutionEngine struct {
// contains filtered or unexported fields
}
EvolutionEngine manages genetic algorithm evolution
func NewEvolutionEngine ¶
func NewEvolutionEngine(config GeneratorConfig) *EvolutionEngine
EvolutionEngine implementation
type FitnessCriterion ¶
type FitnessCriterion string
FitnessCriterion defines what makes a good payload
const ( SuccessRateCriterion FitnessCriterion = "success_rate" ComplexityCriterion FitnessCriterion = "complexity" UniqueCriterion FitnessCriterion = "uniqueness" StealthCriterion FitnessCriterion = "stealth" AdaptabilityCriterion FitnessCriterion = "adaptability" PersistenceCriterion FitnessCriterion = "persistence" )
type FitnessEvaluator ¶
type FitnessEvaluator struct {
// contains filtered or unexported fields
}
FitnessEvaluator scores payload effectiveness
func NewFitnessEvaluator ¶
func NewFitnessEvaluator() *FitnessEvaluator
func (*FitnessEvaluator) Evaluate ¶
func (f *FitnessEvaluator) Evaluate(payload *Payload, objective string, constraints PayloadConstraints) float64
func (*FitnessEvaluator) UpdateScores ¶
func (f *FitnessEvaluator) UpdateScores(payload *Payload, success bool, response string)
type GenerationStats ¶
type GeneratorConfig ¶
type GeneratorConfig struct {
PopulationSize int // Number of payloads per generation
MutationRate float64 // Probability of mutation (0.0-1.0)
CrossoverRate float64 // Probability of crossover (0.0-1.0)
EliteRate float64 // Top % to preserve unchanged
MaxGenerations int // Maximum evolution iterations
ConvergenceThreshold float64 // Stop if fitness plateaus
DiversityBonus float64 // Reward for unique payloads
SuccessLearning bool // Learn from successful payloads
ModelAdaptation bool // Adapt to specific models
}
GeneratorConfig configures the payload generator
type GeneratorMetrics ¶
type GeneratorMetrics struct {
// contains filtered or unexported fields
}
func NewGeneratorMetrics ¶
func NewGeneratorMetrics() *GeneratorMetrics
func (*GeneratorMetrics) RecordFeedback ¶
func (g *GeneratorMetrics) RecordFeedback(payload *Payload, success bool)
func (*GeneratorMetrics) RecordGeneration ¶
func (g *GeneratorMetrics) RecordGeneration(best *Payload, fitness float64)
type Logger ¶
type Logger interface {
Debug(msg string, keysAndValues ...interface{})
Info(msg string, keysAndValues ...interface{})
Warn(msg string, keysAndValues ...interface{})
Error(msg string, keysAndValues ...interface{})
}
Logger interface
type MutationConstraints ¶
type MutationEngine ¶
type MutationEngine struct {
// contains filtered or unexported fields
}
MutationEngine handles payload mutations
func NewMutationEngine ¶
func NewMutationEngine() *MutationEngine
func (*MutationEngine) MutatePayload ¶
func (m *MutationEngine) MutatePayload(payload *Payload, params MutationParams) *Payload
type MutationFunc ¶
type MutationFunc func(payload string, params MutationParams) string
MutationFunc performs a specific mutation
type MutationParams ¶
type MutationParams struct {
Intensity float64
Constraints []string
Context map[string]interface{}
}
MutationParams controls mutation behavior
type MutationType ¶
type MutationType string
MutationType categorizes mutations
const ( // Structural mutations TokenSwapMutation MutationType = "token_swap" TokenInsertMutation MutationType = "token_insert" TokenDeleteMutation MutationType = "token_delete" PhraseMutationMutation MutationType = "phrase_mutation" // Semantic mutations SynonymMutation MutationType = "synonym" ParaphraseMutation MutationType = "paraphrase" ToneMutation MutationType = "tone_shift" IntensityMutation MutationType = "intensity" // Obfuscation mutations EncodingMutation MutationType = "encoding" TypoMutation MutationType = "typo" HomoglyphMutation MutationType = "homoglyph" SpacingMutation MutationType = "spacing" // Technique mutations TechniqueAddMutation MutationType = "technique_add" TechniqueSwapMutation MutationType = "technique_swap" TechniqueMergeMutation MutationType = "technique_merge" // Creative mutations MetaphorMutation MutationType = "metaphor" AnalogyMutation MutationType = "analogy" NarrativeMutation MutationType = "narrative" )
type Payload ¶
type Payload struct {
ID string
Content string
Technique string
Generation int
Fitness float64
Success bool
ParentIDs []string
Mutations []MutationType
Features PayloadFeatures
Timestamp time.Time
}
Payload represents an attack payload with metadata
type PayloadConstraints ¶
type PayloadFeatures ¶
type PayloadFeatures struct {
Length int
Complexity float64
Obfuscation float64
Persuasiveness float64
Creativity float64
TechniqueCount int
EncodingLayers int
EmotionalAppeal float64
LogicalStructure float64
Tokens []string
}
PayloadFeatures captures payload characteristics
type PayloadGenerator ¶
type PayloadGenerator struct {
// contains filtered or unexported fields
}
PayloadGenerator creates and evolves attack payloads dynamically
func NewPayloadGenerator ¶
func NewPayloadGenerator(config GeneratorConfig, logger Logger) *PayloadGenerator
NewPayloadGenerator creates a new dynamic payload generator
func (*PayloadGenerator) EvolveFromSuccess ¶
func (g *PayloadGenerator) EvolveFromSuccess(successful *Payload, variations int) []*Payload
EvolveFromSuccess evolves new payloads from successful ones
func (*PayloadGenerator) GenerateBatch ¶
func (g *PayloadGenerator) GenerateBatch(ctx context.Context, objective string, count int, constraints PayloadConstraints) ([]*Payload, error)
GenerateBatch creates multiple payload variants
func (*PayloadGenerator) GeneratePayload ¶
func (g *PayloadGenerator) GeneratePayload(ctx context.Context, objective string, constraints PayloadConstraints) (*Payload, error)
GeneratePayload creates a new payload using evolutionary algorithms
func (*PayloadGenerator) LearnFromFeedback ¶
func (g *PayloadGenerator) LearnFromFeedback(payload *Payload, success bool, response string)
LearnFromFeedback updates the generator based on success/failure
type PopulationTracker ¶
type PopulationTracker struct {
// contains filtered or unexported fields
}
func NewPopulationTracker ¶
func NewPopulationTracker() *PopulationTracker
type SeedBank ¶
type SeedBank struct {
// contains filtered or unexported fields
}
func NewSeedBank ¶
func NewSeedBank() *SeedBank
func (*SeedBank) AddSuccessfulSeed ¶
func (*SeedBank) GetRandomSeed ¶
type SelectionMethod ¶
SelectionMethod determines how parents are chosen
type SemanticComponents ¶
type SuccessCache ¶
type SuccessCache struct {
// contains filtered or unexported fields
}
func NewSuccessCache ¶
func NewSuccessCache() *SuccessCache
func (*SuccessCache) AddSuccess ¶
func (s *SuccessCache) AddSuccess(payload *Payload)
type SuccessHistory ¶
type SuccessHistory struct {
// contains filtered or unexported fields
}
func NewSuccessHistory ¶
func NewSuccessHistory() *SuccessHistory
func (*SuccessHistory) FindSimilar ¶
func (s *SuccessHistory) FindSimilar(content string, threshold float64) []string
func (*SuccessHistory) GetSuccessRate ¶
func (s *SuccessHistory) GetSuccessRate(content string) float64
func (*SuccessHistory) Record ¶
func (s *SuccessHistory) Record(content string, success bool)
func (*SuccessHistory) RecordPattern ¶
func (s *SuccessHistory) RecordPattern(pattern string, score float64)
type SuccessRecord ¶
type TournamentSelection ¶
type TournamentSelection struct {
// contains filtered or unexported fields
}
TournamentSelection implements tournament selection
func NewTournamentSelection ¶
func NewTournamentSelection(size int) *TournamentSelection