kgretzky/evilginx2 · error

js_inject: %v

Error message

js_inject: %v

What it means

During js_inject registration (adding a new injection entry to the phishlet), each entry's `trigger_paths` values are compiled as regexps wrapped with ^...$. If regexp.Compile fails for any trigger path, the error is wrapped as `js_inject: %v` and registration aborts. This guarantees only valid trigger path regexps are stored on the injection entry.

Source

Thrown at core/phishlet.go:997

		header: header,
	}

	return nil
}

func (p *Phishlet) addJsInject(trigger_domains []string, trigger_paths []string, trigger_params []string, script string) error {
	js := JsInject{
		id: GenRandomToken(),
	}
	for _, d := range trigger_domains {
		js.trigger_domains = append(js.trigger_domains, strings.ToLower(d))
	}
	for _, d := range trigger_paths {
		re, err := regexp.Compile("^" + d + "$")
		if err == nil {
			js.trigger_paths = append(js.trigger_paths, re)
		} else {
			return fmt.Errorf("js_inject: %v", err)
		}
	}
	for _, d := range trigger_params {
		js.trigger_params = append(js.trigger_params, strings.ToLower(d))
	}
	js.script = script

	p.js_inject = append(p.js_inject, js)
	return nil
}

func (p *Phishlet) addIntercept(domain string, path *regexp.Regexp, http_status int, body string, mime string) error {
	ic := Intercept{
		domain:      strings.ToLower(domain),
		path:        path,
		http_status: http_status,
		body:        body,
		mime:        mime,

View on GitHub (pinned to 4c0988a1d9)

Solutions

  1. Fix the regexp syntax in the js_inject `trigger_paths` entry reported in the wrapped error message
  2. Escape literal regex metacharacters (e.g. use \. for dots, \? for question marks)
  3. Test the regexp with a validator (regexp.Compile in Go or an online tester) before adding it to the phishlet

Example fix

# before
js_inject:
  - trigger_paths:
      - '/account(/detail)?*'
# after
js_inject:
  - trigger_paths:
      - '/account(/detail)?'
Defensive patterns

Strategy: validation

Validate before calling

for _, d := range triggerPaths {
    if _, err := regexp.Compile("^" + d + "$"); err != nil {
        return fmt.Errorf("invalid trigger_paths regexp %q: %v", d, err)
    }
}

Type guard

func isValidTriggerPath(d string) bool {
    _, err := regexp.Compile("^" + d + "$")
    return err == nil
}

Try / catch

err := ph.AddJsInject(domains, triggerPaths, triggerParams, script)
if err != nil {
    if strings.HasPrefix(err.Error(), "js_inject:") {
        log.Fatal("bad trigger_paths regexp in js_inject: %v", err)
    }
    return err
}

Prevention

When it happens

Trigger: Adding a js_inject block whose `trigger_paths` contain an invalid regular expression (e.g. unbalanced parenthesis, stray `*`, or an unterminated character class); the AddJsInject/registration path returns the wrapped compile error.

Common situations: Phishlet authors hand-writing regexps in YAML and making syntax mistakes; paths containing regex metacharacters like `?` or `+` that were meant literally but not escaped; copied regexps truncated during paste.

Related errors


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