kgretzky/evilginx2 · error

edit: invalid hostname

Error message

edit: invalid hostname

What it means

Regex validation error for `lures edit <id> hostname <val>`: after the base-domain suffix check, the value must match the RFC-style hostname pattern (alphanumeric labels separated by dots, hyphens only inside labels, no underscores, spaces, ports, or paths). The value failed this hostname regex.

Source

Thrown at core/terminal.go:926

				}
				l, err := t.cfg.GetLure(l_id)
				if err != nil {
					return fmt.Errorf("edit: %v", err)
				}
				val := args[3]
				do_update := false

				switch args[2] {
				case "hostname":
					if val != "" {
						val = strings.ToLower(val)

						if val != t.cfg.general.Domain && !strings.HasSuffix(val, "."+t.cfg.general.Domain) {
							return fmt.Errorf("edit: lure hostname must end with the base domain '%s'", t.cfg.general.Domain)
						}
						host_re := regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`)
						if !host_re.MatchString(val) {
							return fmt.Errorf("edit: invalid hostname")
						}

						l.Hostname = val
						t.cfg.refreshActiveHostnames()
						t.manageCertificates(true)
					} else {
						l.Hostname = ""
					}
					do_update = true
					log.Info("hostname = '%s'", l.Hostname)
				case "path":
					if val != "" {
						u, err := url.Parse(val)
						if err != nil {
							return fmt.Errorf("edit: %v", err)
						}
						l.Path = u.EscapedPath()
						if len(l.Path) == 0 || l.Path[0] != '/' {

View on GitHub (pinned to 4c0988a1d9)

Solutions

  1. Provide a bare hostname: labels of [a-zA-Z0-9-] separated by dots, no scheme/port/path/wildcard
  2. Strip the scheme and path first: use `lures edit <id> path /login` for paths, not the hostname
  3. Replace underscores with hyphens in the DNS name

Example fix

// before
lures edit 2 hostname https://login.example.com/login
// after
lures edit 2 hostname login.example.com
lures edit 2 path /login
Defensive patterns

Strategy: validation

Validate before calling

var hostRe = regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`)
if !hostRe.MatchString(val) { /* invalid hostname */ }

Type guard

func isValidHostname(s string) bool {
	return regexp.MustCompile(`^(([a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z0-9]|[A-Za-z0-9][A-Za-z0-9\-]*[A-Za-z0-9])$`).MatchString(s)
}

Prevention

When it happens

Trigger: `lures edit 2 hostname login.example.com:443`, values containing underscores (login_page.example.com), trailing dots, spaces, wildcards (*.example.com), or a path appended to the hostname.

Common situations: Pasting a full URL (https://login.example.com/path) into the hostname field, using wildcard entries, or internal hostnames with underscores (common in dev environments).

Related errors


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