Skip to content

Commit

Permalink
Refactored whole code, added ability to run from anywhere and fixed s…
Browse files Browse the repository at this point in the history
…ome bugs
  • Loading branch information
Ice3man543 committed Jun 19, 2018
1 parent ae4a856 commit 73766f0
Showing 1 changed file with 62 additions and 25 deletions.
87 changes: 62 additions & 25 deletions subover.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import (
"fmt"
"github.com/parnurzeal/gorequest"
"io/ioutil"
"log"
"net"
"os"
"path/filepath"
"strings"
"sync"
"time"
Expand Down Expand Up @@ -38,7 +40,12 @@ var (
)

func InitializeProviders() {
raw, err := ioutil.ReadFile("./providers.json")
dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
if err != nil {
fmt.Printf("%s", err)
os.Exit(1)
}
raw, err := ioutil.ReadFile(dir + "/providers.json")
if err != nil {
fmt.Println(err.Error())
os.Exit(1)
Expand Down Expand Up @@ -106,36 +113,66 @@ func CNAMEExists(key string) bool {
return false
}

func Checker(target string) {
TargetCNAME, err := net.LookupCNAME(target)
fmt.Printf("DEBUG: %s=>%s\n", target, TargetCNAME)
if err != nil {
return
} else {
if (All != true && CNAMEExists(TargetCNAME)) || (All == true) {
_, body, errs := Get(target, 120, ForceHTTPS)
if len(errs) <= 0 {
for _, provider := range Providers {
for _, response := range provider.Response {
if strings.Contains(body, response) == true {

switch provider.Name {
case "cloudfront":
_, body2, _ := Get(target, 120, true)
if strings.Contains(body2, response) == true {
fmt.Printf("\n[\033[31;1;4m%s\033[0m] Takeover Possible At : %s", provider.Name, target)
}
func Check(target string, TargetCNAME string) {
_, body, errs := Get(target, Timeout, ForceHTTPS)
if len(errs) <= 0 {
if TargetCNAME == "" {
for _, provider := range Providers {
for _, response := range provider.Response {
if strings.Contains(body, response) == true {
fmt.Printf("\n[\033[31;1;4m%s\033[0m] Takeover Possible At %s ", provider.Name, target)
}

default:
fmt.Printf("\n[\033[31;1;4m%s\033[0m] Takeover Possible At : %s", provider.Name, target)
return
}
}
} else {
// This is a less false positives way
for _, provider := range Providers {
for _, cname := range provider.Cname {
if strings.Contains(TargetCNAME, cname) {
for _, response := range provider.Response {
if strings.Contains(body, response) == true {
if provider.Name == "cloudfront" {
_, body2, _ := Get(target, 120, true)
if strings.Contains(body2, response) == true {
fmt.Printf("\n[\033[31;1;4m%s\033[0m] Takeover Possible At : %s", provider.Name, target)
}
} else {
fmt.Printf("\n[\033[31;1;4m%s\033[0m] Takeover Possible At %s with CNAME %s", provider.Name, target, TargetCNAME)
}
}

break
return
}
}
}
}
}
} else {
if Verbose == true {
log.Printf("[ERROR] Get: %s => %v", target, errs)
}
}

return
}

func Checker(target string) {
TargetCNAME, err := net.LookupCNAME(target)
if err != nil {
return
} else {
if All != true && CNAMEExists(TargetCNAME) == true {
if Verbose == true {
log.Printf("[SELECTED] %s => %s", target, TargetCNAME)
}
Check(target, TargetCNAME)
} else if All == true {
if Verbose == true {
log.Printf("[ALL] %s ", target)
}
Check(target, "ALL")
}
}
}

Expand All @@ -147,7 +184,7 @@ func main() {
fmt.Println("==================================================\n")

if HostsList == "" {
fmt.Printf("[!] No hosts list specified !")
fmt.Printf("SubOver: No hosts list specified for testing!")
fmt.Printf("\nUse -h for usage options\n")
os.Exit(1)
}
Expand Down

2 comments on commit 73766f0

@proabiral
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still need to switch to ~/go/src/github.com/Ice3man543/SubOver to run subover else, error stating
/providers.json: no such file or directory is received.

@Ice3man543
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@abiral1 Did you update the tool. I don't think you did. I tested it and it worked fine !

Please sign in to comment.