Skip to content

Instantly share code, notes, and snippets.

@chuckwagoncomputing
Created September 12, 2018 16:57
Show Gist options
  • Save chuckwagoncomputing/b4df13ec1fe6fa98e11fcbb68483c10e to your computer and use it in GitHub Desktop.
Save chuckwagoncomputing/b4df13ec1fe6fa98e11fcbb68483c10e to your computer and use it in GitHub Desktop.
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