Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Kerberos Hash & Fixed Base64 bug #54

Merged
merged 2 commits into from
Mar 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 1 addition & 2 deletions name_that_hash/check_hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ def file_input(self, f):
self.single_hash(line)

def single_hash(self, chash: str):
if "base64" in self.kwargs:

if "base64" in self.kwargs and self.kwargs["base64"]:
logger.trace("decoding as base64")

try:
Expand Down
14 changes: 14 additions & 0 deletions name_that_hash/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1375,6 +1375,20 @@ class HashInfo:
)
],
),
Prototype(
regex=re.compile(
r"\$krb5tgs\$23\$\*(.*)\*\$(.*)",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are actually a couple different hash formats for Kerberos. Hashcat appears to call this one "Kerberos 5 TGS-REP etype 23".
https://hashcat.net/wiki/doku.php?id=example_hashes

Usually, these regexes are more strictly defined, we avoided .* in the past usually.

I looked at hashcat's source code and figured out how they're parsing this:
https://github.com/hashcat/hashcat/blob/master/src/modules/module_13100.c#L115-L116
(and apparently there's another compatible format $krb5tgs$23$checksum$edata2)

Here's a stricter regex that should match $krb5tgs$23$ hashes with account info.

Suggested change
r"\$krb5tgs\$23\$\*(.*)\*\$(.*)",
r"\$krb5tgs\$23\$\*[^*]*\*\$[a-f0-9]{32}\$[a-f0-9]{64,40960}",

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for this! You're right :) We couldn't find it in HashCat, but I've made it a GitHub issue :)

re.IGNORECASE,
),
modes=[
HashInfo(
name=u"Kerberos 5 TGS-REP etype 23",
hashcat=13100,
john="krb5tgs",
extended=False,
),
],
),
Prototype(
regex=re.compile(
r"^\$oldoffice\$[01]\*[a-f0-9]{32}\*[a-f0-9]{32}\*[a-f0-9]{32}$",
Expand Down
5 changes: 5 additions & 0 deletions tests/test_click.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@ def test_file_input():
result = runner.invoke(main, ["-f", "tests/mocks/hashes.txt", '-b64', '-g'])
assert "SHA-1" in result.output
assert "SHA-512" in result.output

def test_file_input():
runner = CliRunner()
result = runner.invoke(main, ["-t", "$krb5tgs$23$*user$realm$test/spn*$63386d22d359fe42230300d56852c9eb$891ad31d09ab89c6b3b8c5e5de6c06a7f49fd559d7a9a3c32576c8fedf705376cea582ab5938f7fc8bc741acf05c5990741b36ef4311fe3562a41b70a4ec6ecba849905f2385bb3799d92499909658c7287c49160276bca0006c350b0db4fd387adc27c01e9e9ad0c20ed53a7e6356dee2452e35eca2a6a1d1432796fc5c19d068978df74d3d0baf35c77de12456bf1144b6a750d11f55805f5a16ece2975246e2d026dce997fba34ac8757312e9e4e6272de35e20d52fb668c5ed"])
assert "Kerberos" in result.output