Skip to content

Commit

Permalink
Fixed file input bug where only first hash was dealt with
Browse files Browse the repository at this point in the history
  • Loading branch information
bee-san committed Feb 26, 2021
1 parent cad2793 commit d8a8d4e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
10 changes: 6 additions & 4 deletions name_that_hash/prettifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ 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
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):
Expand Down
1 change: 0 additions & 1 deletion name_that_hash/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions tests/mocks/hashes.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
NWJhYTYxZTRjOWI5M2YzZjA2ODIyNTBiNmNmODMzMWI3ZWU2OGZkOA==
b109f3bbbc244eb82441917ed06d618b9008dd09b3befd1b5e07394c706a8bb980b1d7785e5976ec049b46df5f1326af5a2ea6d103fd07c95385ffab0cacbc86
6 changes: 6 additions & 0 deletions tests/test_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit d8a8d4e

Please sign in to comment.