py_xxd.py
#!/usr/local/bin/python3
from binascii import hexlify
output = ""
with open("a.exe", "rb") as file:
i = 0
j = 0
k = 0
output_1 = ""
output_2 = ""
a = file.read(1)
while a != b'':
i += 1
j += 1
k += 1
byte = hexlify(a).decode("ascii")
output_1 = output_1 + byte
if k == 2:
output_1 = output_1 + " "
k = 0
dec_value = int(hexlify(a), 16)
if dec_value >= 32 and dec_value <= 126:
asc = a.decode("utf-8")
else:
asc = "."
output_2 += asc
if i == 16:
print("{:07x}: {} {}".format(j - 16, output_1, output_2))
i = 0
output_1 = ""
output_2 = ""
a = file.read(1)
file.close()
No comments:
Post a Comment