def build_prince_command(self, task, chunk): binary = "../../prince/pp64." if Initialize.get_os() != 1: binary = "./" + binary + "bin" else: binary += "exe" pre_args = " -s " + str(chunk['skip']) + " -l " + str( chunk['length']) + ' ' pre_args += get_wordlist( update_files(task['attackcmd']).replace(task['hashlistAlias'], '')) post_args = " --machine-readable --quiet --status --remove --restore-disable --potfile-disable --session=hashtopolis" post_args += " --status-timer " + str(task['statustimer']) post_args += " --outfile-check-timer=" + str(task['statustimer']) post_args += " --outfile-check-dir=../../hashlist_" + str( task['hashlistId']) post_args += " -o ../../hashlists/" + str( task['hashlistId'] ) + ".out --outfile-format=" + self.get_outfile_format() + " " post_args += " --remove-timer=" + str(task['statustimer']) post_args += " ../../hashlists/" + str(task['hashlistId']) post_args += get_rules_and_hl(update_files(task['attackcmd']), task['hashlistAlias']).replace( task['hashlistAlias'], '') return binary + pre_args + " | " + self.callPath + post_args + task[ 'cmdpars']
def run_speed_benchmark(self, task): args = " --machine-readable --quiet --progress-only" args += " --restore-disable --potfile-disable --session=hashtopolis -p \"" + str(chr(9)) + "\" " if task['usePrince']: args += get_rules_and_hl(update_files(task['attackcmd']), task['hashlistAlias']).replace(task['hashlistAlias'], "../../hashlists/" + str(task['hashlistId'])) + ' ' args += " example.dict" + ' ' + task['cmdpars'] else: args += update_files(task['attackcmd']).replace(task['hashlistAlias'], "../../hashlists/" + str(task['hashlistId'])) + ' ' + task['cmdpars'] if 'useBrain' in task and task['useBrain']: args += " -S" args += " -o ../../hashlists/" + str(task['hashlistId']) + ".out" full_cmd = self.callPath + args if Initialize.get_os() == 1: full_cmd = full_cmd.replace("/", '\\') try: logging.debug("CALL: " + full_cmd) output = subprocess.check_output(full_cmd, shell=True, cwd=self.cracker_path) except subprocess.CalledProcessError as e: logging.error("Error during speed benchmark, return code: " + str(e.returncode)) send_error("Speed benchmark failed!", self.config.get_value('token'), task['taskId'], None) return 0 output = output.decode(encoding='utf-8').replace("\r\n", "\n").split("\n") benchmark_sum = [0, 0] for line in output: if not line: continue line = line.split(":") if len(line) != 3: continue # we need to do a weighted sum of all the time outputs of the GPUs benchmark_sum[0] += int(line[1]) benchmark_sum[1] += float(line[2])*int(line[1]) return str(benchmark_sum[0]) + ":" + str(float(benchmark_sum[1]) / benchmark_sum[0])