Skip to content

Instantly share code, notes, and snippets.

@akimasa
Created August 6, 2020 12:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akimasa/8554ac6d1319b8a7c4850210f1fa60f2 to your computer and use it in GitHub Desktop.
Save akimasa/8554ac6d1319b8a7c4850210f1fa60f2 to your computer and use it in GitHub Desktop.
ssh-keysearch
package main
import (
"fmt"
"runtime"
"strings"
"time"
"golang.org/x/crypto/ssh"
"golang.org/x/crypto/ed25519"
)
var count int
func main() {
message := make(chan int)
go func() {
for {
fmt.Printf("%d keys/s \r", count)
count = 0
time.Sleep(time.Second)
}
}()
println("CPU num:", runtime.NumCPU())
for i := 0; i < runtime.NumCPU(); i++ {
go worker(message)
}
<-message
}
func worker(message chan int) {
for {
count = count + 1
pub, priv, err := ed25519.GenerateKey(nil)
if err != nil {
fmt.Println(err)
}
// fmt.Println(pub, priv)
sshpub, err := ssh.NewPublicKey(pub)
if err != nil {
fmt.Println(err)
}
autho := ssh.MarshalAuthorizedKey(sshpub)
str := string(autho)
strlow := strings.ToLower(str)
if strings.Contains(strlow, "akimasa") {
fmt.Println("match!")
fmt.Println(str)
fmt.Println(pub, priv)
message <- 1
return
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment