Last active
October 6, 2024 11:44
-
-
Save HanEmile/8696d6d2545bf9886de3ba6ba00d431d to your computer and use it in GitHub Desktop.
A super simple fuzzer for the easterhegg 2023 workshop
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 ( | |
"fmt" | |
"io" | |
"net/http" | |
"os" | |
"strings" | |
"time" | |
) | |
func request(id int, url string) { | |
resp, err := http.Get(url) | |
if err != nil { | |
fmt.Println("Some error: ", err) | |
} | |
defer resp.Body.Close() | |
body, err := io.ReadAll(resp.Body) | |
if err != nil { | |
fmt.Println("Some error: ", err) | |
} | |
if len(body) != 146 { | |
fmt.Printf("[%d] made an http request to url %s | len(req) = %d\n", id, url, len(body)) | |
} | |
} | |
func worker(id int, wordChan chan string, doneChan chan bool) { | |
out: | |
for { | |
select { | |
case url := <-wordChan: | |
url = fmt.Sprintf("https://emile.space/%s", url) | |
request(id, url) | |
case <-time.After(3 * time.Second): | |
fmt.Printf("worker %d couldn't get a new url after 3 seconds, quitting\n", id) | |
break out | |
} | |
} | |
doneChan <- true | |
} | |
func main() { | |
dat, err := os.ReadFile("./wordlist.txt") | |
if err != nil { | |
fmt.Println("Some error: ", err) | |
} | |
words := strings.Split(string(dat), "\n") | |
wordChan := make(chan string, 10) | |
doneChan := make(chan bool, 4) | |
for i := 1; i < 4; i++ { | |
go worker(i, wordChan, doneChan) | |
} | |
for _, word := range words { | |
wordChan <- word | |
} | |
for i := 1; i < 4; i++ { | |
<-doneChan | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Handeling the errors: