Skip to content

Commit

Permalink
Merge pull request #5 from thanasisk/wip
Browse files Browse the repository at this point in the history
merging work in progress
  • Loading branch information
Athanasios Kostopoulos committed Oct 31, 2015
2 parents 043a097 + 6db3c9a commit f39ad7b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 23 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 ...
22 changes: 10 additions & 12 deletions delaporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ func fatal(e error) {

func printNDie(pass []byte) {
fmt.Println(string(pass))
os.Stdout.Write([]byte("\033[?25h"))
os.Exit(0)
}

Expand Down Expand Up @@ -63,9 +62,8 @@ 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)
//results := make(chan string, 1)
file, err := os.Open(wordlist)
if err != nil {
fatal(err)
Expand All @@ -81,8 +79,7 @@ func crack(block *pem.Block, wordlist string) string {
}
close(jobs)
}()
// start up some workers that will block and wait?
for w := 0; w < workers; w++ {
for w := 0; w < factor*workers; w++ {
wg.Add(1)
go checkKey(jobs, wg, block)
}
Expand All @@ -91,26 +88,24 @@ func crack(block *pem.Block, wordlist string) string {
}

func usage() {
fmt.Println("delaporter -keyfile <SSH PRIVATE KEY> -wordlist <YOUR WORDLIST>")
os.Stdout.Write([]byte("\033[?25h"))
fmt.Println("delaporter -keyfile <SSH PRIVATE KEY> -wordlist <YOUR WORDLIST> -factor <1 <-> +oo>")
os.Exit(1)
}

func main() {
os.Stdout.Write([]byte("\033[?25l"))
// let us set a ^C handler ...
c := make(chan os.Signal, 1)
signal.Notify(c, os.Interrupt)
signal.Notify(c, syscall.SIGTERM)
go func() {
<-c
os.Stdout.Write([]byte("\r"))
os.Stdout.Write([]byte("\033[?25h"))
fmt.Println("^C caught - Exiting")
os.Exit(255)
}()
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 @@ -121,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 @@ -130,6 +129,5 @@ func main() {
fmt.Println("No pass detected - yay")
os.Exit(0)
}
fmt.Println(crack(block, *wordPtr))
os.Stdout.Write([]byte("\033[?25h"))
fmt.Println(crack(block, *wordPtr, *factorPtr))
}

0 comments on commit f39ad7b

Please sign in to comment.