(path: str)
Recursively load all FLIRT signatures under a specific path.

    :param path:    Location of FLIRT signatures.
Recursively load all FLIRT signatures under a specific path.
Recursively load all FLIRT signatures under a specific path .
def load_signatures(path: str) -> None:
    """
    Recursively load all FLIRT signatures under a specific path.

    :param path:    Location of FLIRT signatures.
    """

    FLIRT_SIGNATURES_BY_ARCH.clear()
    LIBRARY_TO_SIGNATURES.clear()
    STRING_TO_LIBRARIES.clear()

    for root, _, filenames in os.walk(path):
        for filename in filenames:
            if filename.endswith(".sig"):
                # parse it
                sig_path = os.path.join(root, filename)
                with open(sig_path, "rb") as f:
                    flirt = nampa.parse_flirt_file(f)

                # is there a meta data file?
                meta_path = os.path.join(root, filename[:-4] + ".meta")
                if os.path.isfile(meta_path):
                    # yes!
                    with open(meta_path, "r") as f:
                        meta = json.load(f)

                    arch = meta.get("arch", None)
                    platform = meta.get("platform", None)
                    os_name = meta.get("os", None)
                    os_version = meta.get("os_version", None)
                    compiler = meta.get("compiler", None)
                    compiler_version = meta.get("compiler_version", None)
                    unique_strings = meta.get("unique_strings", None)

                else:
                    # nope... we need to extract information from the signature file
                    # TODO: Convert them to angr-specific strings
                    arch = flirt.header.arch
                    platform = flirt.header.os_types
                    os_name = None
                    os_version = None
                    unique_strings = None
                    compiler = None
                    compiler_version = None

                signature = FlirtSignature(
                    arch,
                    platform,
                    flirt.header.library_name.decode("utf-8"),
                    sig_path,
                    unique_strings=unique_strings,
                    compiler=compiler,
                    compiler_version=compiler_version,
                    os_name=os_name,
                    os_version=os_version,
                )

                FLIRT_SIGNATURES_BY_ARCH[arch].append(signature)

    # fill in LIBRARY_TO_SIGNATURES and STRING_TO_LIBRARIES
    for sigs in FLIRT_SIGNATURES_BY_ARCH.values():
        for sig in sigs:
            LIBRARY_TO_SIGNATURES[sig.sig_name].append(sig)
            if sig.unique_strings:
                for us in sig.unique_strings:
                    STRING_TO_LIBRARIES[us].add(sig.sig_name)
def load_signatures ( path : str ) -> None : FLIRT_SIGNATURES_BY_ARCH . clear ( ) LIBRARY_TO_SIGNATURES . clear ( ) STRING_TO_LIBRARIES . clear ( ) for root , _ , filenames in os . walk ( path ) : for filename in filenames : if filename . endswith ( ".sig" ) : # parse it sig_path = os . path . join ( root , filename ) with open ( sig_path , "rb" ) as f : flirt = nampa . parse_flirt_file ( f ) # is there a meta data file? meta_path = os . path . join ( root , filename [ : - 4 ] + ".meta" ) if os . path . isfile ( meta_path ) : # yes! with open ( meta_path , "r" ) as f : meta = json . load ( f ) arch = meta . get ( "arch" , None ) platform = meta . get ( "platform" , None ) os_name = meta . get ( "os" , None ) os_version = meta . get ( "os_version" , None ) compiler = meta . get ( "compiler" , None ) compiler_version = meta . get ( "compiler_version" , None ) unique_strings = meta . get ( "unique_strings" , None ) else : # nope... we need to extract information from the signature file # TODO: Convert them to angr-specific strings arch = flirt . header . arch platform = flirt . header . os_types os_name = None os_version = None unique_strings = None compiler = None compiler_version = None signature = FlirtSignature ( arch , platform , flirt . header . library_name . decode ( "utf-8" ) , sig_path , unique_strings = unique_strings , compiler = compiler , compiler_version = compiler_version , os_name = os_name , os_version = os_version , ) FLIRT_SIGNATURES_BY_ARCH [ arch ] . append ( signature ) # fill in LIBRARY_TO_SIGNATURES and STRING_TO_LIBRARIES for sigs in FLIRT_SIGNATURES_BY_ARCH . values ( ) : for sig in sigs : LIBRARY_TO_SIGNATURES [ sig . sig_name ] . append ( sig ) if sig . unique_strings : for us in sig . unique_strings : STRING_TO_LIBRARIES [ us ] . add ( sig . sig_name )