From 6db3c9a9977079812a44ffa4705c42459ad2cb61 Mon Sep 17 00:00:00 2001 From: Athanasios Kostopoulos Date: Sat, 31 Oct 2015 18:54:00 +0100 Subject: [PATCH] introduced factor for more efficient use of CPU, reworked README --- README.md | 18 +++++++----------- delaporter.go | 13 +++++++++---- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 16ee3b5..ebd2fec 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,14 @@ # delaporter [![Build Status](https://travis-ci.org/thanasisk/delaporter.svg?branch=master)](https://travis-ci.org/thanasisk/delaporter) -~~this is not working atm - check back in a day or two :-)~~ This is a rudimentary SSH private key password recovery tool. It does not claim to be production quality, as the initial coding was done in a few hours. However, PRs/issues are more than welcome. -BUGS: - -- ~~does not support DSA SSH keys~~ - -- ~~does not exit when a password is found (FIXED)~~ - -- ~~false positives (FIXED)~~ - -- code is slow (max I have seen is 4 cores in an 8-core machine) is it Go or my skills? - +This version introduces factor an integer variable (default value is 1). +This directly influences the number of consumers (erroneously set initially to +the number of cores per machine) using the formula factor * number of cores. +In my 8-core machine, using a factor value of 512, saw 7 out of 8 cores being utilized. +Feel free to experiment with this variable, as I do not have access to a lot of machines. +Feedback welcome at lixtetrax@grhack.net, once I get access to more machines or +get some feedback, I will try to deduct optimal values ... diff --git a/delaporter.go b/delaporter.go index 9157aa4..6d05fdb 100644 --- a/delaporter.go +++ b/delaporter.go @@ -62,7 +62,7 @@ func checkKey(jobs <-chan string, wg *sync.WaitGroup, block *pem.Block) { } } -func crack(block *pem.Block, wordlist string) string { +func crack(block *pem.Block, wordlist string, factor int) string { jobs := make(chan string) file, err := os.Open(wordlist) if err != nil { @@ -79,7 +79,7 @@ func crack(block *pem.Block, wordlist string) string { } close(jobs) }() - for w := 0; w < 512*workers; w++ { + for w := 0; w < factor*workers; w++ { wg.Add(1) go checkKey(jobs, wg, block) } @@ -88,7 +88,7 @@ func crack(block *pem.Block, wordlist string) string { } func usage() { - fmt.Println("delaporter -keyfile -wordlist ") + fmt.Println("delaporter -keyfile -wordlist -factor <1 <-> +oo>") os.Exit(1) } @@ -105,6 +105,7 @@ func main() { runtime.GOMAXPROCS(workers) keyPtr := flag.String("keyfile", "with_pass", "the keyfile you want to crack") wordPtr := flag.String("wordlist", "pass.txt", "the wordlist you want to use") + factorPtr := flag.Int("factor", 1, "performance factor") flag.Parse() // a small sanity check if _, err := os.Stat(*keyPtr); err != nil { @@ -115,6 +116,10 @@ func main() { fmt.Printf("wordlist %s not found - exiting\n", *wordPtr) usage() } + if *factorPtr < 1 { + fmt.Printf("performance factor %d should be more than 1 - exiting\n", *factorPtr) + usage() + } fmt.Printf("Cracking %s with wordlist %s\n", *keyPtr, *wordPtr) pemKey, err := ioutil.ReadFile(*keyPtr) fatal(err) @@ -124,5 +129,5 @@ func main() { fmt.Println("No pass detected - yay") os.Exit(0) } - fmt.Println(crack(block, *wordPtr)) + fmt.Println(crack(block, *wordPtr, *factorPtr)) }