Skip to content

Commit

Permalink
introduced factor for more efficient use of CPU, reworked README
Browse files Browse the repository at this point in the history
  • Loading branch information
Athanasios Kostopoulos committed Oct 31, 2015
1 parent 47f0501 commit 6db3c9a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -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 [email protected], once I get access to more machines or
get some feedback, I will try to deduct optimal values ...
13 changes: 9 additions & 4 deletions delaporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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)
}
Expand All @@ -88,7 +88,7 @@ func crack(block *pem.Block, wordlist string) string {
}

func usage() {
fmt.Println("delaporter -keyfile <SSH PRIVATE KEY> -wordlist <YOUR WORDLIST>")
fmt.Println("delaporter -keyfile <SSH PRIVATE KEY> -wordlist <YOUR WORDLIST> -factor <1 <-> +oo>")
os.Exit(1)
}

Expand All @@ -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 {
Expand All @@ -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)
Expand All @@ -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))
}

0 comments on commit 6db3c9a

Please sign in to comment.