Created
December 19, 2020 04:29
-
-
Save namidairo/6d8ec1685b2ea72b62ae9860df4b0ee3 to your computer and use it in GitHub Desktop.
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Data.HashFunction; | |
using System.Data.HashFunction.FNV; | |
using System.IO; | |
using System.Threading.Tasks; | |
namespace WemFNVBrute | |
{ | |
class Program | |
{ | |
public static HashSet<ulong> testList = new HashSet<ulong>(); | |
public static HashSet<string> stringList = new HashSet<string>(); | |
public static List<string> resultsList = new List<string>(); | |
public static IFNVConfig config = FNVConfig.GetPredefinedConfig(64); | |
public static IFNV1a hash = FNV1aFactory.Instance.Create(config); | |
static void Main(string[] args) | |
{ | |
// Test out a known value first. | |
var dingdongHash = hash.ComputeHash("base\\characters\\common\\skin\\character_mat_instance\\female\\penis\\female_penis_01_ca_pale.mi"); | |
ulong dingDong = BitConverter.ToUInt64(dingdongHash.Hash, 0); | |
if (dingDong != 5872448753792831583) | |
{ | |
System.Console.WriteLine("Hash error?"); | |
Environment.Exit(0); | |
} | |
else | |
{ | |
Console.WriteLine("Test Hash OK, starting"); | |
} | |
foreach (string line in File.ReadLines("missinghashes.txt")) | |
{ | |
ulong newHash = ulong.Parse(line); | |
testList.Add(newHash); | |
} | |
ulong total = 1500000000; | |
ulong totalthreads = 4; | |
Task[] taskArray = new Task[totalthreads]; | |
for (ulong i = 0; i < (ulong)taskArray.Length; i++) | |
{ | |
ulong v = (total / totalthreads); | |
ulong taskmin = i * v; | |
ulong taskmax = taskmin + v; | |
taskArray[i] = Task<bool>.Factory.StartNew(() => DoBrute(taskmin, taskmax)); | |
System.Console.WriteLine("Starting thread {0} from {1} to {2}", i, taskmin, taskmax); | |
} | |
foreach (var i in taskArray) | |
{ | |
i.Wait(); | |
} | |
File.WriteAllLines("Cyberpunk2077.log", resultsList); | |
} | |
public static bool DoBrute(ulong min, ulong max) | |
{ | |
ulong progress = 0; | |
ulong total = max - min; | |
for (ulong i = min; i < max; i++) | |
{ | |
if (progress % 10000000 == 0) | |
{ | |
Console.WriteLine("{0} of {1}", progress, total); | |
} | |
var testPath = String.Format("base\\sound\\soundbanks\\{0}.wem", i); | |
var testHash = hash.ComputeHash(testPath); | |
ulong testHashLong = BitConverter.ToUInt64(testHash.Hash, 0); | |
if (testList.Contains(testHashLong)) | |
{ | |
var successString = String.Format("{0},{1}", testPath, testHashLong); | |
Console.WriteLine(successString); | |
resultsList.Add(successString); | |
} | |
progress++; | |
} | |
return true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment