From d8a8d4e209ebea2c826bcbb04eef2071c361b732 Mon Sep 17 00:00:00 2001 From: brandon Date: Fri, 26 Feb 2021 00:24:19 +0000 Subject: [PATCH] Fixed file input bug where only first hash was dealt with --- name_that_hash/prettifier.py | 10 ++++++---- name_that_hash/runner.py | 1 - tests/mocks/hashes.txt | 2 ++ tests/test_click.py | 6 ++++++ 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 tests/mocks/hashes.txt diff --git a/name_that_hash/prettifier.py b/name_that_hash/prettifier.py index 7427765..a28b77f 100644 --- a/name_that_hash/prettifier.py +++ b/name_that_hash/prettifier.py @@ -22,8 +22,9 @@ def __init__(self, kwargs, api=False): self.hashcat = kwargs["no_hashcat"] def greppable_output(self, objs: List): + print("helloooooooooooooooooooo") logger.debug("Greppable output") - logger.debug(objs) + logger.debug(f"Objects is {objs}") """ takes the prototypes and turns it into json returns the json @@ -31,10 +32,11 @@ def greppable_output(self, objs: List): Doesn't print it, it prints in main """ outputs_as_dict = {} - logger.debug(outputs_as_dict) for i in objs: - logger.debug(i) - outputs_as_dict.update(i[0].hash_obj) + logger.debug(f"In for loop with object {i}") + for y in i: + outputs_as_dict.update(y.hash_obj) + logger.debug(f"Output_as_dicts is now {outputs_as_dict}") return json.dumps(outputs_as_dict, indent=2) def pretty_print(self, objs): diff --git a/name_that_hash/runner.py b/name_that_hash/runner.py index 4ac0a23..2d56a52 100644 --- a/name_that_hash/runner.py +++ b/name_that_hash/runner.py @@ -131,7 +131,6 @@ def set_logger(kwargs): logger_dict = {1: "WARNING", 2: "DEBUG", 3: "TRACE"} level = logger_dict[kwargs["verbose"]] logger.add(sink=sys.stderr, level=level, colorize=sys.stderr.isatty()) - logger.debug("TEST") logger.opt(colors=True) except Exception as e: logger.remove() diff --git a/tests/mocks/hashes.txt b/tests/mocks/hashes.txt new file mode 100644 index 0000000..c302a67 --- /dev/null +++ b/tests/mocks/hashes.txt @@ -0,0 +1,2 @@ +NWJhYTYxZTRjOWI5M2YzZjA2ODIyNTBiNmNmODMzMWI3ZWU2OGZkOA== +b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86 diff --git a/tests/test_click.py b/tests/test_click.py index ebf3f8a..abc973b 100644 --- a/tests/test_click.py +++ b/tests/test_click.py @@ -43,3 +43,9 @@ def test__b64(): runner = CliRunner() result = runner.invoke(main, ["-t", "NWY0ZGNjM2I1YWE3NjVkNjFkODMyN2RlYjg4MmNmOTk=", '-b64']) assert "MD5" in result.output + +def test_file_input(): + runner = CliRunner() + result = runner.invoke(main, ["-f", "tests/mocks/hashes.txt", '-b64', '-g']) + assert "SHA-1" in result.output + assert "SHA-512" in result.output