What you have are hexadecimal values. So what you're getting is what you should be getting. (Except that you should be getting [2, 0, 48, 3, 53] and not [2, 0, 48, 3, 35].)
If you want the list to have what you have in hexadecimal you can try converting it back to hexadecimal.
testByte = b"\x02\x00\x30\x03\x35"
listTestByte = list(testByte)
print(listTestByte) # [2, 0, 48, 3, 53]
listTestByteAsHex = [int(hex(x).split('x')[-1]) for x in listTestByte]
print(listTestByteAsHex) # [2, 0, 30, 3, 35]
Or use string operations, to split at '\x' depending on your purpose.
Answer from sP_ on Stack Overflowbytes but print a string!
python - How to print byte representation of a string? - Stack Overflow
Printing binary strings
Python print bytes - Stack Overflow
Im learning crypto ctf with python and there is something that really can't figure out on my own
i have a flag encrypted with XOR with a key. they are represented as hex. after convert it to bytes, i xor them and then use it Crypto.Util.number.long_to_bytes() to find the flag.
before the XOR operation, the bytes values is like "\xa6\xc8\xb6s<\x9b"\xde{\xc0%2f\xa3\x86}\xf5Z\xcd\xe8c^\x19\xc73\x13"
after i removed the key that was XOR with the flag, the bytes values of flag is
crypto{x0r_i5_ass0c1at1v3}
i checked the var with type() and it's a bytes not a str. How come that before that its bytes values has hex values and then only normale characters? Or maybe those arent hex?
There's no single function to do it, so you would need to do the formatting manually:
s = 'abcd'
print(r'\x' + r'\x'.join(f'{b:02x}' for b in bytes(s, 'utf8')))
Output:
\x61\x62\x63\x64
You can get hex values of a string like this:
string = "abcd"
print(".".join(hex(ord(c))[2:] for c in string))