Ejemplo n.º 1
0
        private void CheckVariations(IReadOnlyList <string> variation)
        {
            string currentVariation;
            IEnumerable <string> generatedStrings;
            var  results = new List <RaiderResult>();
            uint currentHash;

            foreach (var word in WordsBetweenVariations)
            {
                currentVariation = string.Join(word, variation);
                generatedStrings = GenerateStringsToCheck(currentVariation);

                foreach (var generatedString in generatedStrings)
                {
                    currentHash = HashFactory.Hash(generatedString);
                    if (Hashes.Contains(currentHash))
                    {
                        results.Add(new RaiderResult {
                            Hash = currentHash, Value = generatedString, IsKnown = true
                        });
                    }
                }
            }

            if (results.Any())
            {
                Sender.UpdateFormDuringBruteforce(results);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Appends the provided Archive to the index and writes new elements into the Database.</summary>
        private async Task AppendArchiveAsync(Archive stagingArchive)
        {
            // Hashes
            // To prevent any issues, rebuild the hash index by looping through each filenode and
            // reapplying the correct values/relations
            var newHashes = new List <FileHash>();

            foreach (var file in stagingArchive.GetFileNodes())
            {
                if (file.Hash is null)
                {
                    continue;
                }

                // For each hash in the staging archive, check if it already exists in the file index.
                // If so, update the pointer of the file node
                // in the staging archive to use the existing object. If not, add the hash to the index

                if (Hashes.Contains(file.Hash))
                {
                    file.Hash = AddFileHash(file.Hash);
                    file.Hash.AddNode(file);
                }
                else
                {
                    AddFileHash(file.Hash);
                    newHashes.Add(file.Hash);
                }
            }
            await Database.BatchInsertFileHashAsync(newHashes);

            // All filenodes are unique to a archive so they can be added to the DB in any case
            var dbInsertList = stagingArchive.GetFileDirectories();

            dbInsertList.AddRange(stagingArchive.GetFileNodes());
            await Database.BatchInsertFileNodeAsync(dbInsertList);

            stagingArchive.Volume = await AddLogicalVolume(stagingArchive.Volume, true);

            await AddArchiveAsync(stagingArchive, true);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Checks if digest value contains given hash.
 /// </summary>
 /// <param name="hash">The hash.</param>
 /// <returns>True if there is a match in the digest value, otherwise false.</returns>
 public bool Contains(uint hash)
 {
     return(Hashes.Contains(hash));
 }