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

fix: panic while converting phish url to real url #205

Merged
merged 1 commit into from Jun 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions runtime/func.go
Expand Up @@ -144,16 +144,21 @@ func PhishURLToRealURL(phishURL string) string {
var host string
var out string

u, _ := url.Parse(phishURL)
// url parse returns nil when phishURL does not have protocol
if strings.HasPrefix(phishURL, "https://") == false && strings.HasPrefix(phishURL, "http://") == false {
u, _ := url.Parse(fmt.Sprintf("https://%s", phishURL))
host = u.Host
} else {
u, _ := url.Parse(phishURL)
if u.Host != "" {
host = u.Host
} else {
host = phishURL
}
}

out = phishURL

// Parse both cases with http url scheme and without
if u.Host != "" {
host = u.Host
} else {
host = phishURL
}

if strings.Contains(phishURL, ProxyDomain) {
subdomain := strings.Replace(host, "."+ProxyDomain, "", 1)
// has subdomain
Expand Down