0

When running this:

import hashlib

hash1 = hashlib.md5(b'admin:Pentester Academy:asdds').hexdigest()
hash2 = hashlib.md5(b'GET:/lab/webapp/digest/1').hexdigest()
nonce = "526f295f84bcafc67598cd8e760a9cc5"

response_unhashed = (bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
response_md5hashed = hashlib.md5(response_unhashed).hexdigest()

print(response_md5hashed)

I get this...

   Traceback (most recent call last):
  File "C:\Users\Adrian\Desktop\Infosec\Notes\Programming\example.py", line 7
    response_unhashed = (bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
                                                         ^
SyntaxError: invalid syntax

Where's the syntax error? Checked some of the bytes() and format() documentation but couldn't find any clues.

2 Answers2

0

There are parentheses that are in wrong order.

Try

bytes("{}:{}:{}".format(hash1,nonce,hash2), encoding = "utf-8")

Instead of

(bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
0

You can try this:

import hashlib
hash1 = hashlib.md5(b'admin:Pentester Academy:asdds').hexdigest()
hash2 = hashlib.md5(b'GET:/lab/webapp/digest/1').hexdigest()
nonce = "526f295f84bcafc67598cd8e760a9cc5"

response_unhashed = bytes("{}:{}:{}".format(hash1,nonce,hash2), encoding = "utf-8")
response_md5hashed = hashlib.md5(response_unhashed).hexdigest()

print(response_md5hashed)