字节中的语法错误(“”.format(), encoding="utf-8")
Syntax error in bytes(" ".format(), encoding="utf-8")
当运行这个:
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)
我明白了...
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
语法错误在哪里?检查了一些 bytes() 和 format() 文档,但找不到任何线索。
有些括号顺序错误。
尝试
bytes("{}:{}:{}".format(hash1,nonce,hash2), encoding = "utf-8")
而不是
(bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
你可以试试这个:
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)
当运行这个:
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)
我明白了...
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
语法错误在哪里?检查了一些 bytes() 和 format() 文档,但找不到任何线索。
有些括号顺序错误。
尝试
bytes("{}:{}:{}".format(hash1,nonce,hash2), encoding = "utf-8")
而不是
(bytes("{}:{}:{}".format(hash1, nonce, hash2)), encoding='utf-8')
你可以试试这个:
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)