public StatisticsGenerator(StatusContainer status, P2PQuickWatchPresentation quickWatch, KeySearcher keySearcher, KeySearcherSettings settings, DistributedBruteForceManager distributedBruteForceManager) { this.status = status; this.quickWatch = quickWatch; this.keySearcher = keySearcher; this.distributedBruteForceManager = distributedBruteForceManager; lastDateOfGlobalStatistics = DateTime.Now; HighestChunkCalculated = -1; stopWatch = new Stopwatch(); var keyPattern = new KeyPattern.KeyPattern(keySearcher.ControlMaster.GetKeyPattern()) { WildcardKey = settings.Key }; var keysPerChunk = Math.Pow(2, settings.ChunkSize); var keyPatternPool = new KeyPatternPool(keyPattern, new BigInteger(keysPerChunk)); TotalAmountOfChunks = keyPatternPool.Length; status.PropertyChanged += StatusPropertyChanged; elapsedTimeTimer = new Timer(1000); elapsedTimeTimer.Elapsed += ElapsedTimeTimerTick; elapsedTimeTimer.Start(); trafficUpdateTimer = new Timer(10000); trafficUpdateTimer.Elapsed += TrafficUpdateTimerTick; trafficUpdateTimer.Start(); }
public DistributedBruteForceManager(KeySearcher keySearcher, KeyPattern.KeyPattern keyPattern, KeySearcherSettings settings, KeyQualityHelper keyQualityHelper, P2PQuickWatchPresentation quickWatch, KeyPoolTreePresentation keyPoolTreePresentation) { this.keySearcher = keySearcher; this.settings = settings; this.keyQualityHelper = keyQualityHelper; this.quickWatch = quickWatch; _keyPoolTreePresentation = keyPoolTreePresentation; // TODO when setting is still default (21), it is only displayed as 21 - but the settings-instance contains 0 for that key! if (settings.ChunkSize == 0) { settings.ChunkSize = 21; } StopWatch = new Stopwatch(); status = new StatusContainer(keySearcher); status.IsCurrentProgressIndeterminate = true; keyGenerator = new StorageKeyGenerator(keySearcher, settings); patternPool = new KeyPatternPool(keyPattern, new BigInteger(Math.Pow(2, settings.ChunkSize))); StatisticsGenerator = new StatisticsGenerator(status, quickWatch, keySearcher, settings, this); quickWatch.Dispatcher.BeginInvoke(DispatcherPriority.Normal, new Action(UpdateStatusContainerInQuickWatch)); _keyPoolTreePresentation.PatternPool = patternPool; _keyPoolTreePresentation.KeyQualityHelper = keyQualityHelper; _keyPoolTreePresentation.KeyGenerator = keyGenerator; _keyPoolTreePresentation.StatusContainer = status; }
public StatusContainer(KeySearcher keySearcher) { this.keySearcher = keySearcher; EstimatedFinishDate = "-"; DhtOverheadInPercent = "-"; TopList = new ObservableCollection <ResultEntry>(); TotalAmountOfParticipants = 1; CurrentOperation = "Idle"; }
/// <summary> /// This constructor is used to setup the parameters used for code generation. /// </summary> /// <param name="keySearcher">The KeySearcher instance (only used for GuiLogMessages).</param> /// <param name="encryptedData">The byte array which contains the data which should be encrypted.</param> /// <param name="iv">The IV vector</param> /// <param name="encryptionController">The IControlEncryption instance of the encryption plugin to use.</param> /// <param name="controlCost">The IControlCost instance of the cost function plugin to use.</param> /// <param name="approximateNumberOfKeys">A maximum bound which indicates on how many key bruteforcing at once the OpenCL code should be layed out.</param> public KeySearcherOpenCLCode(KeySearcher keySearcher, byte[] encryptedData, byte[] iv, IControlEncryption encryptionController, IControlCost controlCost, int approximateNumberOfKeys) { this.keySearcher = keySearcher; this.encryptedData = encryptedData; this.iv = iv; this.encryptionController = encryptionController; this.controlCost = controlCost; this.approximateNumberOfKeys = approximateNumberOfKeys; }
public KeySearcherSettings(KeySearcher ks, OpenCLManager oclManager) { keysearcher = ks; RefreshDevicesList(oclManager); CoresAvailable.Clear(); for (int i = -1; i < Environment.ProcessorCount; i++) { CoresAvailable.Add((i + 1).ToString()); } CoresUsed = Environment.ProcessorCount - 1; chunkSize = 21; KeyManager = new SimpleKeyManager(""); }
public KeyPoolTree(BigInteger length, KeySearcher keySearcher, KeyQualityHelper keyQualityHelper, StorageKeyGenerator identifierGenerator, StatusContainer statusContainer, StatisticsGenerator statisticsGenerator) { this.keySearcher = keySearcher; this.statusContainer = statusContainer; this.statisticsGenerator = statisticsGenerator; Identifier = identifierGenerator.Generate(); statusUpdater = new StatusUpdater(statusContainer, identifierGenerator.GenerateStatusKey()); skippedReservedNodes = false; updateIntervalMod = 5; if (statisticsGenerator != null) { statisticsGenerator.MarkStartOfNodeSearch(); } rootNode = NodeFactory.CreateNode(keyQualityHelper, null, 0, length - 1, Identifier); if (statisticsGenerator != null) { statisticsGenerator.MarkEndOfNodeSearch(); } currentNode = rootNode; }
public ConnectionHelper(KeySearcher keySearcher, KeySearcherSettings settings) { this.keySearcher = keySearcher; this.settings = settings; }
public StorageKeyGenerator(KeySearcher keySearcher, KeySearcherSettings settings) { this.keySearcher = keySearcher; this.settings = settings; }
public KeyPoolTree(KeyPatternPool patternPool, KeySearcher keySearcher, KeyQualityHelper keyQualityHelper, StorageKeyGenerator identifierGenerator, StatusContainer statusContainer, StatisticsGenerator statisticsGenerator) : this(patternPool.Length, keySearcher, keyQualityHelper, identifierGenerator, statusContainer, statisticsGenerator) { }
public static void PushToDatabase(StatusContainer status, long bruteForceTime, string identifier, KeySearcherSettings settings, KeySearcher keySearcher) { if (string.IsNullOrEmpty(settings.EvaluationHost)) { return; } var connectionString = "Data Source=" + settings.EvaluationHost + ";"; connectionString += "User ID=" + settings.EvaluationUser + ";"; connectionString += "Password="******";"; connectionString += "Initial Catalog=" + settings.EvaluationDatabase; var sqlConnection = new SqlConnection(); try { sqlConnection.ConnectionString = connectionString; sqlConnection.Open(); // You can get the server version // SQLConnection.ServerVersion } catch (Exception ex) { sqlConnection.Dispose(); keySearcher.GuiLogMessage("DB Error: " + ex.Message, NotificationLevel.Error); return; } var globalProgress = status.GlobalProgress.ToString(CultureInfo.CreateSpecificCulture("en-US")); var dhtTimeInMilliseconds = status.DhtOverheadInReadableTime.TotalMilliseconds.ToString(CultureInfo.CreateSpecificCulture("en-US")); var sqlStatement = string.Format("INSERT INTO [statistics] ([host],[date],[localFinishedChunks],[currentChunk],[globalProgress],[totalAmountOfParticipants],[totalDhtRequests],[requestsPerNode],[retrieveRequests],[removeRequests],[storeRequests],[dhtTimeInMilliseconds],[dhtOverheadInPercent],[storedBytes],[retrievedBytes],[totalBytes],[sentBytesByLinkManager],[receivedBytesByLinkManager],[totalBytesByLinkManager],[bruteForceTimeInMilliseconds],[identifier],[processID]) " + "VALUES ('{0}', GetDate(), {1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, '{11}', {12}, {13}, {14}, {15}, {16}, {17}, {18}, '{19}', {20});", Environment.MachineName, status.LocalFinishedChunks, status.CurrentChunk, globalProgress, status.TotalAmountOfParticipants, status.TotalDhtRequests, status.RequestsPerNode, status.RetrieveRequests, status.RemoveRequests, status.StoreRequests, dhtTimeInMilliseconds, status.DhtOverheadInPercent, status.StoredBytes, status.RetrievedBytes, status.TotalBytes, status.SentBytesByLinkManager, status.ReceivedBytesByLinkManager, status.TotalBytesByLinkManager, bruteForceTime, identifier, Process.GetCurrentProcess().Id); try { var command = new SqlCommand(sqlStatement, sqlConnection); command.ExecuteNonQuery(); } catch (Exception ex) { keySearcher.GuiLogMessage("DB Error: " + ex.Message, NotificationLevel.Error); } finally { sqlConnection.Close(); sqlConnection.Dispose(); } }