Hi. Sorry if the question is confusing or weird but I am trying to find a specific number of bytes after finding a different set of bytes. Hopefully with code and my explaination of code, i'll get my question across.
import base64 find_bytes = bytearray(base64.b16decode('46726F4B6E6F')) with open("readfile.raw", "rb") as f: file_bytes = bytearray(f.read()) found_pos = file_bytes.find(find_bytes, 0) with open("foundhex.txt", "w") as found: found.write("Found 46726F4B6E6F at : " + str(found_pos))
Okay so. I have a set of bytes i want to find
find_bytes : 46726F4B6E6F, then with those bytes found i want to find the previous 6 bytes before them. In a RL situation, i wouldn't know what those 6 bytes are, I only know that they are 6 bytes and that they are positioned before
find_bytes. I am unsure how to achieve this. i was thinking use
range() but im not sure how to use it with bytearray or if it is even the correct method.
I hope i explained it properly. please let me know if u need any more clarification.