kgretzky/evilginx2 · error

index out of bounds: %d

Error message

index out of bounds: %d

What it means

SetLure rejects the index argument because it falls outside the valid range [0, len(c.lures)). This is a validation guard against out-of-range lure indices supplied by callers (e.g., from user CLI input); the lure at that index cannot be replaced and the config is left unchanged.

Source

Thrown at core/config.go:693

		}
		c.cfg.Set(CFG_SITE_DOMAINS, c.siteDomains)
		c.cfg.Set(CFG_SITES_ENABLED, sites_enabled)
		c.cfg.Set(CFG_SITES_HIDDEN, sites_hidden)
		c.cfg.WriteConfig()*/
}

func (c *Config) AddLure(site string, l *Lure) {
	c.lures = append(c.lures, l)
	c.lureIds = append(c.lureIds, GenRandomToken())
	c.cfg.Set(CFG_LURES, c.lures)
	c.cfg.WriteConfig()
}

func (c *Config) SetLure(index int, l *Lure) error {
	if index >= 0 && index < len(c.lures) {
		c.lures[index] = l
	} else {
		return fmt.Errorf("index out of bounds: %d", index)
	}
	c.cfg.Set(CFG_LURES, c.lures)
	c.cfg.WriteConfig()
	return nil
}

func (c *Config) DeleteLure(index int) error {
	if index >= 0 && index < len(c.lures) {
		c.lures = append(c.lures[:index], c.lures[index+1:]...)
		c.lureIds = append(c.lureIds[:index], c.lureIds[index+1:]...)
	} else {
		return fmt.Errorf("index out of bounds: %d", index)
	}
	c.cfg.Set(CFG_LURES, c.lures)
	c.cfg.WriteConfig()
	return nil
}

View on GitHub (pinned to 4c0988a1d9)

Solutions

  1. Verify the index is within 0..len(c.lures)-1 before calling (use GetLures/length check)
  2. Refresh the lure list and recompute the index after any add/delete
  3. Use index 0..N-1 numbering, not the CLI's 1-based lure numbering

Example fix

// before
cfg.SetLure(idx, lure)
// after
lures := cfg.GetLures()
if idx >= 0 && idx < len(lures) {
    cfg.SetLure(idx, lure)
}
Defensive patterns

Strategy: validation

Validate before calling

func validLureIndex(cfg *core.Config, i int) bool {
    return i >= 0 && i < len(cfg.GetLures())
}

Try / catch

if err := cfg.SetLure(i, lure); err != nil {
    return fmt.Errorf("lure index %d invalid, refresh list: %w", i, err)
}

Prevention

When it happens

Trigger: Calling cfg.SetLure(index, lure) where index is negative or >= the number of lures currently loaded in config.

Common situations: Storing lure indexes across config reloads (a lure deleted by another session shifts indexes); using 1-based numbering from a CLI; appending a new lure by passing len(c.lures) instead of using a create method.

Related errors


AI-assisted analysis of kgretzky/evilginx2@4c0988a1d9 (2026-09-05). Data as JSON: /api/errors/365ab7bffb5e77b4. Report an issue: GitHub.