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

Huawei/H3C/HP/Comware devices hash algorithms #3963

Open
bodik opened this issue Mar 5, 2024 · 2 comments
Open

Huawei/H3C/HP/Comware devices hash algorithms #3963

bodik opened this issue Mar 5, 2024 · 2 comments

Comments

@bodik
Copy link

bodik commented Mar 5, 2024

Based on virtual appliance firmware analysis we have found the algorithm which is used to generate $h$6$ hash used by Huawei/H3C/HP devices. We'r not sure if it's worthy to implement in hashcat, but someone might find it handy even here.

Sample hash

can be found in HP documentation

plaintext: abc
hash: $h$6$4tWqOiqovcWddOKv$XyFMVgaE46fGiqsZEHbcr+BM/m9tDkvahDbqU7HoNrvmALk2u31z9c/tuUmX7IiQhWRwN5qoZquW82A8XYaDWA==

PoC

algorithm uses sha512(password + salt + password) scheme where password includes terminating null-byte

import hashlib
import base64

password = b"abc\0"
orighash = "$h$6$4tWqOiqovcWddOKv$XyFMVgaE46fGiqsZEHbcr+BM/m9tDkvahDbqU7HoNrvmALk2u31z9c/tuUmX7IiQhWRwN5qoZquW82A8XYaDWA=="

salt = orighash.split('$')[3].encode()
h = hashlib.new('sha512')

h.update(password)
h.update(salt)
h.update(password)
digest = h.digest()

computed = '$h$6$' + salt.decode() + '$' + base64.b64encode(digest).decode()

print(f"orighash   {orighash}")
print(f"computed   {computed}")
@bodik
Copy link
Author

bodik commented Mar 5, 2024

cracking can be emulated by supplying crafted hex wordlist from stdin with hash type 1700

@Thedemon007
Copy link

@bodik you know some of PBKDF2(password, 256 key size, 5000 iterations, Sha256, salt) hash ? from some Huawei ONT/ONU? check this: https://hashcat.net/forum/thread-11881.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants