Skip to content

Commit

Permalink
added a fused subdomain splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4f53 committed Aug 6, 2024
1 parent f064c83 commit 0b32891
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
5 changes: 4 additions & 1 deletion test_case.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,4 +114,7 @@ subdomain27.example.com
example-.com (hyphen at the end)
example..com (consecutive dots)
exa mple.com (space within the domain)
[email protected] (special character not allowed)
[email protected] (special character not allowed)

// Fused
dev.static.landstorebase.storemyspreadshop.atmyspreadshop.bemyspreadshop.camyspreadshop.chmyspreadshop.demyspreadshop.dkmyspreadshop.esmyspreadshop.fimyspreadshop.frmyspreadshop.iemyspreadshop.itmyspreadshop.nlmyspreadshop.nomyspreadshop.plmyspreadshop.sestreak-link.comstreaklinks.comazimuth.networklima-city.rockssite.transip.mediskstation.orgvirtual-user.deexpress.val.runvoorloper.clouddaemon.panel.ggmesswithdns.comyandexcloud.net
32 changes: 32 additions & 0 deletions textsubs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func removeDuplicateSubAndDoms(items []SubAndDom) []SubAndDom {

func getSubdomains(text string) ([]string, error) {

text = breakFusedSubdomains(text)

Check failure on line 43 in textsubs.go

View workflow job for this annotation

GitHub Actions / build

undefined: breakFusedSubdomains

var subdomains []string

lines := strings.Split(text, "\n")
Expand Down Expand Up @@ -233,3 +235,33 @@ func SubdomainAndDomainPair(text string, removeDuplicates bool) ([]SubAndDom, er
return results, nil

}

var tlds = []string{".com", ".org", ".store", ".net", ".int", ".edu", ".gov", ".mil", ".co", ".us", ".info", ".biz", ".me", ".mobi", ".asia", ".tel", ".tv", ".cc", ".ws", ".in", ".uk", ".ca", ".de", ".eu", ".fr", ".au", ".ru", ".ch", ".it", ".nl", ".se", ".no", ".es", ".jp", ".br", ".cn", ".kr", ".mx", ".nz", ".za", ".ie", ".be", ".at", ".dk", ".fi", ".gr", ".pt", ".tr", ".pl", ".hk", ".sg", ".my", ".th", ".vn", ".tw", ".il", ".ar", ".cl", ".ve", ".uy", ".co.uk", ".co.in", ".co.jp", ".cn.com", ".de.com", ".eu.com", ".gb.net", ".hu.net", ".jp.net", ".kr.com", ".qc.com", ".ru.com", ".sa.com", ".se.net", ".uk.com", ".us.com", ".za.com", ".ac", ".ad", ".ae", ".af", ".ag", ".ai", ".al", ".am", ".an", ".ao", ".aq", ".ar", ".as", ".at", ".au", ".aw", ".ax", ".az", ".ba", ".bb", ".bd", ".bf", ".bg", ".bh", ".bi", ".bj", ".bm", ".bn", ".bo", ".bq", ".br", ".bs", ".bt", ".bv", ".bw", ".by", ".bz", ".ca", ".cc", ".cd", ".cf", ".cg", ".ch", ".ci", ".ck", ".cl", ".cm", ".cn", ".co", ".cr", ".cu", ".cv", ".cw", ".cx", ".cy", ".cz", ".de", ".dj", ".dk", ".dm", ".do", ".dz", ".ec", ".ee", ".eg", ".eh", ".er", ".es", ".et", ".eu", ".fi", ".fj", ".fk", ".fm", ".fo", ".fr", ".ga", ".gb", ".gd", ".ge", ".gf", ".gg", ".gh", ".gi", ".gl", ".gm", ".gn", ".gp", ".gq", ".gr", ".gs", ".gt", ".gu", ".gw", ".gy"}

func BreakFusedSubdomains(text string) string {

var output string

var domains []string
for i := 1; i < len(text); i++ {
if text[i-1] == '.' {
continue
}

for _, tld := range tlds {
if strings.HasPrefix(text[i:], tld) {
domains = append(domains, text[:i+len(tld)])
text = text[i+len(tld):]
i = 0
break
}
}
}

for _, domain := range domains {
output += domain + "\n"
}

return output

}

0 comments on commit 0b32891

Please sign in to comment.