public string Build(AbstractJob job, TempFilePaths paths) { var inventory = _inventoryManager.GetCurrent(); return(job switch { SpeedStatJob ssj => $"{_force}-b -m {ssj.HashTypeId} --machine-readable", TemplateBruteforceJob tmj => $"{_force}{_options} --keyspace -a 3 " + BuildAttackConfiguration(tmj), TemplateWordListJob twl => $"{_force}{_options} --keyspace {BuildRule(twl.RuleId, inventory)}" + $" \"{Path.Combine(_workedFolders.WordlistPath, inventory.Map[twl.WordlistId].Name)}\"", HashListJob hlj => $"{_force}--left -m {hlj.HashTypeId} {BuildFilePaths(paths)}", BruteforceJob bfj => $"{_force}{_options} --skip={bfj.Skip} --limit={bfj.Limit} -m {bfj.HashTypeId} " + $" --outfile=\"{paths.OutputFile}\" " + $"{BuildFilePaths(paths)} -a 3 " + BuildAttackConfiguration(bfj), WordListJob wlj => $"{_force}{_options} --skip={wlj.Skip} --limit={wlj.Limit} -m {wlj.HashTypeId} " + BuildRule(wlj.RuleId, inventory) + $" --outfile=\"{paths.OutputFile}\" " + $"{BuildFilePaths(paths)} \"{Path.Combine(_workedFolders.WordlistPath, inventory.Map[wlj.WordlistId].Name)}\"", _ => throw new InvalidOperationException($"Can't build hascat arguments for {job}") });
public override PrepareJobResult Prepare() { if (job.JobId == null) { return new PrepareJobResult { Error = $"JobId полученной задачи с типом {job.Type} = null, такое мы не выполняем", IsReadyForExecution = false } } ; paths = SettingsProvider.CurrentSettings.TempDirectoryPath.BuildTempFilePaths(); var hashfile = ClientProxyProvider.Client.GetHashFile(job.HashId).Result; if (string.IsNullOrEmpty(hashfile?.Data)) { return(new PrepareJobResult { Error = $"Пустой hashfile: HashId ={job.HashId}, JobId={job.JobId}", IsReadyForExecution = false }); } string arguments; try { arguments = new ArgumentsBuilder().BuildArguments(job, paths); } catch (Exception e) { return(new PrepareJobResult { Error = $"Не смогли сгенерить аргументы для задачи JobId:{job.JobId}, Error: {e}", IsReadyForExecution = false }); } File.WriteAllBytes(paths.HashFile, Convert.FromBase64String(hashfile.Data)); var potFile = ClientProxyProvider.Client.GetPotFile(job.HashId).Result; File.WriteAllBytes(paths.PotFile, Convert.FromBase64String(potFile?.Data ?? string.Empty)); ClientProxyProvider.Client.SendJobStart(job.JobId).ConfigureAwait(false); return(new PrepareJobResult { IsReadyForExecution = true, HashCatArguments = arguments }); }
public JobHandler( T job, string agentId, TempFilePaths paths, IHashCatCommandExecutorBuilder executorBuilder, IKrakerApi krakerApi) { _job = job; _agentId = agentId; _krakerApi = krakerApi; _paths = paths; _executor = executorBuilder.Build(job, paths); _hashCatTask = Task.FromResult(ExecutionResult.FromError(0, "There isn't a task")); }
public override PrepareJobResult Prepare() { if (job.HashId == null) { return new PrepareJobResult { IsReadyForExecution = false, Error = $"Нет hashId у работы с типом {job.Type}" } } ; var hashfile = ClientProxyProvider.Client.GetHashFile(job.HashId).Result; if (string.IsNullOrEmpty(hashfile?.Data)) { return(new PrepareJobResult { Error = $"Пустой hashfile: HashId ={job.HashId}, JobId={job.JobId}", IsReadyForExecution = false }); } paths = SettingsProvider.CurrentSettings.TempDirectoryPath.BuildTempFilePaths(); File.WriteAllBytes(paths.HashFile, Convert.FromBase64String(hashfile.Data)); File.WriteAllText(paths.PotFile, string.Empty); string arguments; try { arguments = new ArgumentsBuilder().BuildArguments(job, paths); } catch (Exception e) { return(new PrepareJobResult { Error = $"Не смогли сгенерить аргументы для задачи JobId:{job.JobId}, Error: {e}", IsReadyForExecution = false }); } return(new PrepareJobResult { IsReadyForExecution = true, HashCatArguments = arguments }); }
public HashCatCommandExecutor Build(AbstractJob job, TempFilePaths paths) { var arguments = _argumentsBuilder.Build(job, paths); return(new (arguments, _settings, _logger, _workingDirectoty, job)); }