├── README.md ├── image └── sonarbyte.png └── main.go /README.md: -------------------------------------------------------------------------------- 1 | # sonarbyte 2 | [![GitHub issues](https://img.shields.io/github/issues/channyein1337/sonarbyte)](https://github.com/channyein1337/sonarbyte/issues) 3 | [![GitHub forks](https://img.shields.io/github/forks/channyein1337/sonarbyte)](https://github.com/channyein1337/sonarbyte/network) 4 | [![GitHub stars](https://img.shields.io/github/stars/channyein1337/sonarbyte)](https://github.com/channyein1337/sonarbyte/stargazers) 5 | 6 | # Description 7 | Sonarbyte is a simple and fast subdomain scanner written in go to extract subdomains from Rapid7's DNS Database using omnisint's api. 8 | 9 | # Install 10 | ``` 11 | ▶ go get github.com/channyein1337/sonarbyte 12 | ``` 13 | ``` 14 | ▶ git clone https://github.com/channyein1337/sonarbyte.git 15 | ▶ go build main.go 16 | ▶ sudo mv sonarbyte /usr/bin/sonarbyte 17 | ``` 18 | # Usage 19 | ``` 20 | ▶ sonarbyte -h 21 | Usage of sonarbyte: 22 | -d string 23 | Set the domain name 24 | -df string 25 | Set the file 26 | ``` 27 | ![](https://raw.githubusercontent.com/channyein1337/sonarbyte/main/image/sonarbyte.png) 28 | 29 | For a single domain 30 | ``` 31 | ▶ sonarbyte -d hackerone.com 32 | ``` 33 | For multiple domains 34 | ``` 35 | ▶ sonarbyte -df domain.txt 36 | ``` 37 | Run with httpx 38 | ``` 39 | ▶ sonarbyte -df domain.txt | httpx 40 | ``` 41 | 42 | # Updates Feature 43 | - Add new flags 44 | 45 | # Future plan 46 | - New Services 47 | - File output 48 | 49 | # Implement 50 | 51 | https://omnisint.io/ 52 | -------------------------------------------------------------------------------- /image/sonarbyte.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/byt3hx/sonarbyte/c5e0c45b8609cdc057573444ccb54e5954344452/image/sonarbyte.png -------------------------------------------------------------------------------- /main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import( 4 | "fmt" 5 | "flag" 6 | "sync" 7 | "net/http" 8 | "io/ioutil" 9 | "encoding/json" 10 | "os" 11 | "bufio" 12 | "time" 13 | ) 14 | 15 | func main() { 16 | var domainfile string 17 | var domain string 18 | flag.StringVar(&domain , "d" , "" , "Set the domain name") 19 | flag.StringVar(&domainfile, "df" , "" , "Set the file") 20 | flag.Parse() 21 | 22 | if domain != "" { 23 | sub , err := scan(domain) 24 | if err != nil { 25 | fmt.Println(err) 26 | } 27 | sort := unique(sub) 28 | for _, finaldomain := range sort { 29 | fmt.Println(finaldomain) 30 | } 31 | } 32 | 33 | if domainfile != "" { 34 | file, err := os.Open(domainfile) 35 | if err != nil { 36 | fmt.Println("File could not be read!") 37 | } 38 | defer file.Close() 39 | time.Sleep(time.Millisecond * 10) 40 | 41 | scanner := bufio.NewScanner(file) 42 | 43 | for scanner.Scan() { 44 | var domains []string 45 | domains = append(domains, scanner.Text()) 46 | var wg sync.WaitGroup 47 | for i := 0 ; i <= 0; i++ { 48 | wg.Add(1) 49 | go func() { 50 | for _, finaldomain := range domains { 51 | sorting(finaldomain) 52 | } 53 | wg.Done() 54 | }() 55 | wg.Wait() 56 | } 57 | } 58 | } 59 | 60 | } 61 | 62 | func scan(domain string) ([]string, error) { 63 | resp, err := http.Get(fmt.Sprintf("https://sonar.omnisint.io/subdomains/%s", domain)) 64 | if err != nil { 65 | fmt.Println(nil) 66 | } 67 | defer resp.Body.Close() 68 | body, err := ioutil.ReadAll(resp.Body) 69 | 70 | if err !=nil { 71 | fmt.Println(err) 72 | } 73 | 74 | var values []string 75 | 76 | if err := json.Unmarshal([]byte(body), &values); err != nil { 77 | 78 | panic(err) } 79 | f := make([]string, 0) 80 | for _, item := range values { 81 | f = append(f,item) 82 | } 83 | return f,nil 84 | 85 | } 86 | 87 | func unique(strSlice []string) []string { 88 | 89 | keys := make(map[string]bool) 90 | list := []string{} 91 | 92 | for _, entry := range strSlice { 93 | if _, value := keys[entry]; !value { 94 | keys[entry] = true 95 | list = append(list, entry) 96 | } 97 | } 98 | return list 99 | } 100 | 101 | func sorting(domain string) { 102 | sub , err := scan(domain) 103 | if err != nil { 104 | fmt.Println(err) 105 | } 106 | sort := unique(sub) 107 | for _, finaldomain := range sort { 108 | fmt.Println(finaldomain) 109 | } 110 | 111 | } 112 | --------------------------------------------------------------------------------