Skip to content

Commit 4bb8d68

Browse files
committed
add doppelganger strategie
1 parent 3b252e3 commit 4bb8d68

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Diff for: dnsmorph.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -568,7 +568,8 @@ func outputToFile(targets []string) {
568568
{"omission", sanitizedDomain, omissionAttack},
569569
{"hyphenation", sanitizedDomain, hyphenationAttack},
570570
{"bitsquatting", sanitizedDomain, bitsquattingAttack},
571-
{"homograph", sanitizedDomain, homographAttack}} {
571+
{"homograph", sanitizedDomain, homographAttack},
572+
{"doppelganger", sanitizedDomain, doppelgangerAttack}} {
572573
for _, r := range t.Function(t.TargetDomain) {
573574
results = append(results, []string{r + "." + tld, t.Technique})
574575
}
@@ -636,6 +637,7 @@ func runPermutations(targets []string) {
636637
printReport("replacement", replacementAttack(sanitizedDomain), tld)
637638
printReport("bitsquatting", bitsquattingAttack(sanitizedDomain), tld)
638639
printReport("transposition", transpositionAttack(sanitizedDomain), tld)
640+
printReport("doppelganger", doppelgangerAttack(sanitizedDomain), tld)
639641
}
640642
}
641643
}
@@ -769,6 +771,18 @@ func hyphenationAttack(domain string) []string {
769771
return results
770772
}
771773

774+
// performs a doppelganger attack by removing hypens in subdomain
775+
func doppelgangerAttack(domain string) []string {
776+
results := []string{}
777+
778+
for i := len(domain)-1; i > 0; i-- {
779+
if (rune(domain[i]) == '.' || rune(domain[i]) == '-') {
780+
results = append(results, fmt.Sprintf("%s%s", domain[:i], domain[i+1:]))
781+
}
782+
}
783+
return results
784+
}
785+
772786
// performs a bitsquat permutation attack
773787
func bitsquattingAttack(domain string) []string {
774788

Diff for: dnsmorph_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var tests = []testcase{
5454
{"test", hyphenationAttack, 3, "t-est"},
5555
{"test", bitsquattingAttack, 31, "test"},
5656
{"test", homographAttack, 27, "τest"},
57+
{"test.test", doppelgangerAttack, 1, "testtest"},
5758
}
5859

5960
func TestAttackResults(t *testing.T) {
@@ -75,7 +76,7 @@ func TestWhoisLookup(t *testing.T) {
7576
t.Errorf("expected 1997-09-15T04:00:00Z, got %s", result[0])
7677
}
7778

78-
if result[1] != "2018-02-21T18:36:40Z" {
79-
t.Errorf("expected 2018-02-21T18:36:40Z, got %s", result[1])
79+
if result[1] != "2019-09-09T15:39:04Z" {
80+
t.Errorf("expected 2019-09-09T15:39:04Z, got %s", result[1])
8081
}
8182
}

0 commit comments

Comments
 (0)