private void DiveByteSimple(ByteString candidate, int level, int searchLength, int currentUtf8Value = 0) { int levelp = level + 1; byte[] charsetBytes; if (currentUtf8Value > 127 && _mappingBytes.ContainsKey(currentUtf8Value)) { charsetBytes = _mappingBytes[currentUtf8Value]; } else { charsetBytes = _validBytes; currentUtf8Value = 0; } foreach (byte b in charsetBytes) { if (levelp < searchLength) { candidate.Append(b); DiveByteSimple(candidate, levelp, searchLength, (currentUtf8Value << 8) + b); candidate.Cursor -= 1; continue; } candidate.Replace(b); if (candidate.CRC32Check()) { _logger.LogResult(candidate.ToString()); } } }
private void DiveByteSimple(ByteString candidate, int level, int searchLength, bool shouldInterruptAtFirstResult = false) { int levelp = level + 1; foreach (byte b in _validBytes) { if (_interruptThreads) { break; } if (levelp < searchLength) { candidate.Append(b); DiveByteSimple(candidate, levelp, searchLength, shouldInterruptAtFirstResult); candidate.Cursor -= 1; continue; } candidate.Replace(b); if (candidate.CRC32Check()) { if (shouldInterruptAtFirstResult) { _logger.LogResult($"False positive found: 0x{candidate.HexSearchValue:x}."); _hexExtract = candidate.HexSearchValue; _interruptThreads = true; } else { _logger.LogResult(candidate.ToString()); } } } }
private void RunCharacterBruteForce(List <Task> tasks, TaskFactory factory, byte[] validStartBytes, string prefix, bool shouldInterruptAtFirstResult = false) { int searchLength = _stringLength - prefix.Length - _options.Suffix.Length - 1; for (var t = 0; t < validStartBytes.Length; t++) { var startingCharacter = Encoding.ASCII.GetString(new byte[1] { validStartBytes[t] }); var task = factory.StartNew(() => { try { ByteString strBuilder = new ByteString(_stringLength, _hexValue, prefix, _options.Suffix); strBuilder.Append(startingCharacter); DiveByteSimple(strBuilder, 0, searchLength, shouldInterruptAtFirstResult); } catch (Exception e) { _logger.Log($"ERROR on thread {startingCharacter}: {e.Message}"); } }); tasks.Add(task); } }
private void RunDictionaries(ByteString candidate, string combinationPattern, bool firstWord) { string currentWord; bool lastWord; int nextDelimiter; bool appendDelimiterByte; int nextActualDel = combinationPattern.IndexOf(_delimiter); int nextFakeDel = combinationPattern.IndexOf("|"); if (nextActualDel == -1) { nextDelimiter = nextFakeDel; } else { if (nextFakeDel == -1) { nextDelimiter = nextActualDel; } else { nextDelimiter = Math.Min(nextActualDel, nextFakeDel); } } appendDelimiterByte = nextActualDel == nextDelimiter; lastWord = nextDelimiter == -1; if (lastWord) { currentWord = combinationPattern; } else { currentWord = combinationPattern.Substring(0, nextDelimiter); if (!currentWord.StartsWith("{")) { candidate.Append(currentWord); if (_delimiterLength > 0 && appendDelimiterByte) { candidate.Append(_delimiterByte); } combinationPattern = combinationPattern[(currentWord.Length + 1)..];
private void RunDictionaries(ByteString candidate, string combinationPattern, bool firstWord) { string wordSize; bool lastWord = false; if (!combinationPattern.Contains(_delimiter)) { wordSize = combinationPattern; lastWord = true; } else { wordSize = combinationPattern.Substring(0, combinationPattern.IndexOf(_delimiter)); if (!wordSize.StartsWith("{")) { candidate.Append(wordSize); if (_delimiterLength > 0) { candidate.Append(_delimiterByte); } combinationPattern = combinationPattern[(wordSize.Length + 1)..];
private void DiveByteSimple(ByteString candidate, int level, int searchLength) { int levelp = level + 1; foreach (byte b in _validBytes) { if (levelp < searchLength) { candidate.Append(b); DiveByteSimple(candidate, levelp, searchLength); candidate.Cursor -= 1; continue; } candidate.Replace(b); if (candidate.CRC32Check()) { _logger.LogResult(candidate.ToString()); } } }