diff --git a/getnetguids.py b/getnetguids.py index b989aac..99e17bc 100644 --- a/getnetguids.py +++ b/getnetguids.py @@ -6,7 +6,7 @@ import csv import hashlib -guid_regex = re.compile("[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}") +guid_regex = re.compile(b"[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}") def format_guid_from_hex(hex_string): @@ -19,7 +19,7 @@ def format_guid_from_hex(hex_string): def read_blob(blob): if len(blob) == 0: return "" - first_byte = ord(blob[0]) + first_byte = blob[0] if first_byte & 0x80 == 0: # easy one raw_string = blob[1:][:first_byte] @@ -43,7 +43,7 @@ def get_assembly_guids(assembly_path): txt_start = None txt_end = None for section in pe.sections: - if section.Name.startswith(".text\x00"): + if section.Name.startswith(b".text\x00"): txt_start = section.PointerToRawData txt_end = txt_start + section.SizeOfRawData except pefile.PEFormatError: @@ -71,18 +71,18 @@ def get_assembly_guids(assembly_path): else: offsets_to_test = [mdo - txt_start] - offsets_to_test.extend([l.start() for l in re.finditer("\x42\x53\x4a\x42", text_section)][::-1]) + offsets_to_test.extend([l.start() for l in re.finditer(b"\x42\x53\x4a\x42", text_section)][::-1]) del file_data for i_offset in offsets_to_test: i = text_section[i_offset:] try: - if "\x42\x53\x4a\x42" not in i: + if b"\x42\x53\x4a\x42" not in i: continue - if not i.startswith("\x42\x53\x4a\x42"): + if not i.startswith(b"\x42\x53\x4a\x42"): continue - meta_data_offset = i.find("\x42\x53\x4a\x42") + meta_data_offset = i.find(b"\x42\x53\x4a\x42") clr_version_length = struct.unpack("