func main() { { // testing that crypto works back and forth t := []byte("some secret stuff AAAA") ct := make([]byte, len(t)) MTEncrypt(0, ct, t) t2 := make([]byte, len(t)) MTEncrypt(0, t2, ct) fmt.Println(bytes.Equal(t, t2)) } { // generate random bytes with AAA's appended t := util.RandBytes(int(util.RandByte())) knownText := "AAAAAAAAAAAAA" t = append(t, []byte(knownText)...) ct := make([]byte, len(t)) MTEncrypt(int(util.RandByte())*int(util.RandByte()), ct, t) for i := 0; i < 0xFFFF; i++ { z := make([]byte, len(ct)) MTEncrypt(i, z, ct) if string(z[len(z)-len(knownText):]) == knownText { fmt.Println("Found the key:", i) break } } } { // generate "random" "password reset token" mt := util.NewMT19337(uint64(time.Now().Unix())) token := mt.Next() time.Sleep(1 * time.Second) fmt.Println("Is MT19337 token: ", isMT19337Token(token)) } }
func main() { mt := util.NewMT19337(0) clone := util.NewMT19337(100) var i uint64 for i = 0; i < 624; i++ { o := mt.Next() clone.SetMT(i, untemper(o)) } clone.SetIndex(624) fmt.Println("Original Clone") for i := 0; i < 10; i++ { o := mt.Next() c := clone.Next() fmt.Printf("%x %x\n", o, c) } }
func main() { waitRandom() ts := uint64(time.Now().Unix()) mt := util.NewMT19337(ts) waitRandom() output := mt.Next() fmt.Println("output:", output) crackSeed(output) }
func isMT19337Token(n uint64) bool { now := uint64(time.Now().Unix()) for i := now; i > now-3600*24*7; i-- { mt := util.NewMT19337(i) if mt.Next() == n { return true } } return false }
func crackSeed(n uint64) { ts := uint64(time.Now().Unix()) for ts > 0 { mt := util.NewMT19337(ts) try := mt.Next() if try == n { fmt.Println("seed found:", ts) return } ts-- } fmt.Println("seed was not found!") }
func NewMTCrypto(key int) *MTCrypto { mtc := &MTCrypto{mt: util.NewMT19337(uint64(key))} mtc.cacheNext() return mtc }
func main() { mt := util.NewMT19337(0) fmt.Println(mt.Next()) fmt.Println(mt.Next()) }