Skip to content

Commit

Permalink
Update subov88r.go
Browse files Browse the repository at this point in the history
  • Loading branch information
h0tak88r committed Mar 14, 2024
1 parent dd0174a commit 5288631
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions subov88r.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import (
"flag"
"fmt"
"net"
"net/http"
"os"
"os/exec"
"regexp"
"strings"
)

Expand Down Expand Up @@ -43,10 +45,7 @@ func main() {
subdomain := scanner.Text()

// Get the CNAME record for the subdomain
cname, err := net.LookupCNAME(subdomain)
if err != nil {
return
}
cname, _ := net.LookupCNAME(subdomain)

// Get the status of the subdomain
status, err := getStatus(subdomain)
Expand All @@ -55,6 +54,13 @@ func main() {
continue
}

isVuln := azureSTO(cname, status)

if isVuln {
fmt.Printf("[%v,%v,%v] Possiply Vulnerable to subdomain takevover", subdomain, cname, status)
continue
}

// Print results with ANSI colors
fmt.Printf("%sSubdomain: %s %s, %sCNAME: %s %s, %sStatus: %s%s\n", Red, subdomain, NC, Blue, cname, NC, Green, status, NC)
}
Expand Down Expand Up @@ -82,3 +88,17 @@ func getStatus(subdomain string) (string, error) {
}
return status, nil
}

// function that check for subdomain takeover in azure services
func azureSTO(cname string, status string) bool {
azureRegex := regexp.MustCompile(`(?i)^(?:[a-z0-9-]+\.)?(?:cloudapp\.net|azurewebsites\.net|cloudapp\.azure\.com)$`)

if strings.Contains(status, "NXDOMAIN") && azureRegex.MatchString(cname) {
url := fmt.Sprintf("https://%s", cname)
_, err := http.Get(url)
if err != nil {
return true // If there's an error, assume it's a possible subdomain takeover
}
}
return false
}

0 comments on commit 5288631

Please sign in to comment.