Last active
May 4, 2019 02:11
-
-
Save ypcrts/144fe87e0aaf7198ce1b911c12a7ea0d to your computer and use it in GitHub Desktop.
Golang HTTP virtual host bruteforcer, with concurrency
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "net/http" | |
import "fmt" | |
import "io/ioutil" | |
import "bufio" | |
import "os" | |
// golang virtualhost bruteforcer with concurrency | |
func makeRequest(subdomain string) bool { | |
const NORMAL_LENGTH = 11175 | |
client := http.Client{} | |
req, err := http.NewRequest("GET", "http://10.10.10.112", nil) | |
if err != nil { | |
panic(err) | |
} | |
fqdn := fmt.Sprintf("%s.bighead.htb", subdomain) | |
req.Host = fqdn | |
req.Close = true | |
resp, err := client.Do(req) | |
if err != nil { | |
panic(err) | |
} | |
b, _ := ioutil.ReadAll(resp.Body) | |
length := len(b) | |
if length == NORMAL_LENGTH { | |
fmt.Printf(".") | |
return false | |
} | |
fmt.Printf("\n%s \t\t%d\n", subdomain, length) | |
return true | |
} | |
func loadCandidates(scanner *bufio.Scanner, candidates chan string) { | |
for scanner.Scan() { | |
text := scanner.Text() | |
candidates <- text | |
} | |
close(candidates) | |
} | |
func main() { | |
file, err := os.Open("/pentest/password-recovery/dictionary/Discovery/Web-Content/common.txt") | |
if err != nil { | |
panic(err) | |
} | |
scanner := bufio.NewScanner(file) | |
candidates := make(chan string) | |
sem := make(chan bool, 100) | |
go loadCandidates(scanner, candidates) | |
for c := range candidates { | |
sem <- true | |
go func() { | |
makeRequest(c) | |
<-sem | |
}() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment