Created
August 26, 2019 09:10
-
-
Save thers/8089b35d6d3d8e83ca4ff1dd2fbed068 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"time" | |
"bytes" | |
"strings" | |
"math/big" | |
"math/rand" | |
cryptoRand "crypto/rand" | |
) | |
type HashTuple struct { | |
hash uint32 | |
str string | |
} | |
func main() { | |
targets := []uint32 { | |
//uint32(0x0187b845), | |
//uint32(0x0203d234), | |
//uint32(0x1074d56e), | |
//uint32(0x14e2d61a), // events.xml | |
//uint32(0x15b636d3), | |
//uint32(0x5f9656ff), | |
//uint32(0x61b37b91), | |
//uint32(0x7fe69508), | |
uint32(0x9b89716c), | |
//uint32(0x662e68ca), | |
//uint32(0x87562960), | |
//uint32(0x90534326), // popgroups.xml | |
//uint32(0x9fa1bbaf), | |
//uint32(0xa33eca4e), | |
//uint32(0xa6f20ada), | |
//uint32(0xbc16a905), | |
//uint32(0xc7ea4394), | |
//uint32(0xd818f53b), | |
//uint32(0xffd53760), | |
} | |
found := make(chan HashTuple) | |
foundCounter := 0 | |
foundTuples := make([]HashTuple, len(targets)) | |
counter := make(chan int) | |
total := 0 | |
for i := 0; i < 400; i++ { | |
go brute(targets, found, counter) | |
} | |
go func (){ | |
tick := time.Tick(1 * time.Second) | |
prev := 0 | |
diff := 0 | |
for { | |
select { | |
case cnt := <-counter: | |
total += cnt | |
break | |
case <-tick: | |
diff = total - prev | |
prev = total | |
fmt.Println("Tried strings:", total, ",", diff, "str/s, found", foundCounter, "out of", len(targets)) | |
} | |
} | |
}() | |
for { | |
select { | |
case foundTuple := <-found: | |
fmt.Println("Found string:", foundTuple.str, "for hash", fmt.Sprintf("0x%x", foundTuple.hash)) | |
isDuplicate := false | |
for _, tuple := range foundTuples { | |
if tuple.hash == foundTuple.hash { | |
fmt.Println("String for this already has been discovered, skipping") | |
isDuplicate = true | |
break | |
} | |
} | |
if !isDuplicate { | |
foundTuples[foundCounter] = foundTuple | |
foundCounter++ | |
if foundCounter == len(targets) { | |
fmt.Println("Every hash has been found, table:"); | |
for _, tuple := range foundTuples { | |
fmt.Printf("\t%x -> %s\n", tuple.hash, tuple.str) | |
} | |
return | |
} | |
} | |
} | |
} | |
} | |
func brute(targets []uint32, found chan HashTuple, counter chan int) { | |
randInt, err := cryptoRand.Int(cryptoRand.Reader, new(big.Int).SetInt64(9999999)) | |
fmt.Printf("Init new bruter with seed: %x\n", randInt) | |
if err != nil { | |
panic(err) | |
} | |
var rnd *rand.Rand = rand.New(rand.NewSource(randInt.Int64())) | |
var str string | |
var hash uint32 | |
for { | |
str = randomString(rnd) | |
hash = joaat(str) | |
counter <- 1 | |
for _, target := range targets { | |
if hash == target { | |
found <- HashTuple{ hash, str } | |
} | |
} | |
} | |
} | |
func joaat(key string) (hash uint32) { | |
var i int = 0 | |
for i != len(key) { | |
hash += uint32(key[i]) | |
hash += hash << 10 | |
hash ^= hash >> 6 | |
i += 1 | |
} | |
hash += hash << 3 | |
hash ^= hash >> 11 | |
hash += hash << 15 | |
return | |
} | |
func randomString(rnd *rand.Rand) string { | |
var buffer bytes.Buffer | |
buffer.WriteString("fivem_loves_you_") | |
buffer.WriteString(fmt.Sprintf("%x", rnd.Uint64())) | |
return strings.ToUpper(buffer.String()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment