Created
August 6, 2020 12:10
-
-
Save akimasa/8554ac6d1319b8a7c4850210f1fa60f2 to your computer and use it in GitHub Desktop.
ssh-keysearch
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" | |
"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