public void Crack(string hash) { if (!Initialized) { return; } ProcessBlock block = GetFreeBlock(); ConnectionManager.Instance.Broadcast(new ProcessingBlockNotifyPacket(block.BlockId, BlockState.Processing)); Cracker cracker = new Cracker(hash, block); cracker.OnCompleted += OnCompleted; if (ProcessingThread != null) { //MessageBox.Show(ProcessingThread.ThreadState.ToString()); ProcessingThread = null; } ProcessingThread = new Thread(new ThreadStart(cracker.Run)); ProcessingThread.Start(); //MessageBox.Show("cracking " + block.BlockId); }
void OnCompleted(ProcessBlock block, Exception exc) { if (exc is HashFoundException) { this.Initialized = false; SetProcessingState(block.BlockId, BlockState.Finished); ConnectionManager.Instance.Broadcast(new HashFoundPacket(exc.Message)); //ConnectionManager.Instance.Broadcast(new ProcessingBlockNotifyPacket(block.BlockId, BlockState.Finished)); //ConnectionManager.Instance.Broadcast(new MessagePacket(string.Format("{0}: Block {1} - {2}", ConnectionManager.Instance.ListenPort, block.BlockId, BlockState.Finished))); MessageBox.Show(exc.Message); //ProcessingThread.Abort(); return; } else if (exc is HashNotFoundException) { ConnectionManager.Instance.Broadcast(new ProcessingBlockNotifyPacket(block.BlockId, BlockState.Finished)); //ConnectionManager.Instance.Broadcast(new MessagePacket(string.Format("{0}: Block {1} - {2}", ConnectionManager.Instance.ListenPort, block.BlockId, block.State.ToString()))); SetProcessingState(block.BlockId, BlockState.Finished); this.Crack(Hash); } }
void OnCompleted(ProcessBlock block, Exception exc) { if (exc is HashFoundException) { this.Initialized = false; SetProcessingState(block.BlockId, BlockState.Finished); ConnectionManager.Instance.Broadcast(new HashFoundPacket(exc.Message)); //ConnectionManager.Instance.Broadcast(new ProcessingBlockNotifyPacket(block.BlockId, BlockState.Finished)); //ConnectionManager.Instance.Broadcast(new MessagePacket(string.Format("{0}: Block {1} - {2}", ConnectionManager.Instance.ListenPort, block.BlockId, BlockState.Finished))); MessageBox.Show(exc.Message); //ProcessingThread.Abort(); return; } else if(exc is HashNotFoundException) { ConnectionManager.Instance.Broadcast(new ProcessingBlockNotifyPacket(block.BlockId, BlockState.Finished)); //ConnectionManager.Instance.Broadcast(new MessagePacket(string.Format("{0}: Block {1} - {2}", ConnectionManager.Instance.ListenPort, block.BlockId, block.State.ToString()))); SetProcessingState(block.BlockId, BlockState.Finished); this.Crack(Hash); } }
public Cracker(string hash, ProcessBlock block) { this.block = block; decrypter = new MD5Decrypter(hash, new DecrypterRange(block.BlockId, ProcessingManager.BlockSize, Convert.ToUInt32(MD5Decrypter.CharRange.Length))); stopNumber = decrypter.Range.GetCombinationsAmount(); }