Skip to content

Instantly share code, notes, and snippets.

@tedb
Last active December 23, 2015 15:42
Show Gist options
  • Save tedb/fb98dbdfa64952315547 to your computer and use it in GitHub Desktop.
Save tedb/fb98dbdfa64952315547 to your computer and use it in GitHub Desktop.
Simple program to brute force crack lambdaconf.us's TripleSec puzzle
package main
import (
"encoding/hex"
"github.com/keybase/go-triplesec"
"os"
"runtime"
"strconv"
"sync"
// "time"
)
func main() {
ciphertext, err := hex.DecodeString("1c94d7de00000003f9e55ae037496b48b86749819b28b0fcbfa153b96ef477289fe334940cd2dcf1db655bdaab4066745e624053aeceff315d1539e24303deaf6a237cc59e512919746a32fcf9ad582985d1572439879546448419121c362a1627615fbe8828af709027b6ecfd22de7ce8475a4921e135c6a1f52cceae10be59aaf306d4e6d630126105fee941c980c59fd733950bfa2d36c479f496640cae4fa385fa3ca762fbc6437737f2514b29821d7fdfd8327931c442ac78496b84305a469c2fcb531535c3070f61f2604ad65212093ccd6207981051ff96489808493f579d452ded97124e38cca603b3aeb8770ca64e338b6db436010467521aa45f3957b57a18e021afb6c1434d56ca80b958d4e25124713fddb6c1da189841bd038041584ef5f2d3537d70201908f993b53301a4454c06ead07ac7e00089a62a3527e9175b81e430a5841cf8fd5f4f099f36c588e9e5e3f4c0cde65b735dc054a4564916d333f57e7276f7e79df678476814705c3aa8d2c13d6e104a9dfe494aaea77ea7f3f584ad141c6caa7b3e8549")
//ciphertext, err := hex.DecodeString("1c94d7de0000000359a5e5d60f09ebb6bc3fdab6642725e03bc3d51e167fa60327df567476d467f8b6ce65a909b4f582443f230ff10a36f60315ebce1cf1395d7b763c768764207f4f4cc5207a21272f3a5542f35db73c94fbc7bd551d4d6b0733e0b27fdf9606b8a26d45c4b79818791b6ae1ad34c23e58de482d454895618a1528ec722c5218650f8a2f55f63a6066ccf875f46c9b68ed31bc1ddce8881d704be597e1b5006d16ebe091a02e24d569f3d09b0578d12f955543e1a1f1dd75784b8b4cba7ca0bb7044389eb6354cea628a21538d")
if err != nil {
println("bad decode")
}
c := make(chan []byte, 32)
var wg sync.WaitGroup
for i := 0; i < runtime.NumCPU(); i++ {
wg.Add(1)
go func(idx int) {
defer wg.Done()
println("goroutine", idx)
for pw := range c {
println(string(pw))
c, err := triplesec.NewCipher(pw, nil)
if err != nil {
println("bad cipher")
}
decrypted, err := c.Decrypt(ciphertext)
if err == nil {
println("good pw", string(pw))
println(string(decrypted))
os.Exit(0)
}
//} else if _, ok := err.(triplesec.BadPassphraseError); ok {
// println("bad passphrase")
//} else {
// println("something else bad", err)
//}
//runtime.Gosched()
}
}(i)
}
/* go func() {
for {
runtime.GC()
time.Sleep(1000 * time.Millisecond)
}
}()
*/
start, _ := strconv.Atoi(os.Args[1])
for i := start; i < 10000000; i++ {
c <- []byte(strconv.Itoa(i))
}
wg.Wait()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment