Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Brute forcer in go. Tries given dictionary first.
package main
import (
"bufio"
"fmt"
"os"
"time"
)
func main() {
pc := make(chan string, 2)
go func() {
f, err := os.Open("pass.txt")
defer f.Close()
if err != nil {
panic(err)
}
s := bufio.NewScanner(f)
for s.Scan() {
pc <- s.Text()
}
if err := s.Err(); err != nil {
panic(err)
}
n := byte(33)
x := byte(126)
b := []byte{n}
PushChar(b, 1, pc, n, x)
}()
for {
fmt.Println(<-pc)
}
}
func PushChar(b []byte, l int, pc chan<- string, n byte, x byte) {
pc <- string(b)
b[len(b)-l]++
if b[len(b)-l] > x {
b[len(b)-l] = n
l++
if len(b) < l {
b = append(b, n)
l = 1
}
} else {
l = 1
}
PushChar(b, l, pc, n, x)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment