Exemple #1
0
def pluginMain():
    """Run the Karta (identifier) plugin."""
    global logger, disas

    # Use the basic logger on the init phase
    init_logger = Logger(LIBRARY_NAME)
    init_logger.linkHandler(logging.FileHandler(constructInitLogPath(), "w"))
    disas = createDisassemblerHandler(init_logger)
    # In case of a dependency issue, disas will be None
    if disas is None:
        return

    # Can now safely continue on
    logger = Logger(LIBRARY_NAME, [],
                    use_stdout=False,
                    min_log_level=logging.INFO)
    initUtils(logger, disas)
    logger.info("Started the Script")

    # Init the strings list (Only once, because it's heavy to calculate)
    logger.info("Building a list of all of the strings in the binary")

    # Start identifying the libraries
    logger.info("Going to identify the open (and closed) source libraries")
    identifyLibraries()

    # Finished successfully
    logger.info("Finished Successfully")
Exemple #2
0
def pluginMain():
    """Run the Karta (matcher) plugin."""
    global disas, logger, config_path

    # Use the basic logger on the init phase
    init_logger = Logger(LIBRARY_NAME)
    init_logger.linkHandler(logging.FileHandler(constructInitLogPath(), "w"))
    disas = createDisassemblerHandler(init_logger)
    # In case of a dependency issue, disas will be None
    if disas is None:
        return

    # Get the configuration values from the user
    config_values = disas.configForm()
    if config_values is None:
        return

    # store them / use them now for initialization
    config_path = config_values["config_path"]
    if config_values["is_windows"]:
        setWindowsMode()

    working_path = os.path.split(disas.databaseFile())[0]

    log_files = []
    #    log_files += [(os.path.join(working_path, "%s_debug.log"   % (LIBRARY_NAME)), "w", logging.DEBUG)]
    log_files += [(os.path.join(working_path, "%s_info.log" % (LIBRARY_NAME)),
                   "w", logging.INFO)]
    log_files += [(os.path.join(working_path,
                                "%s_warning.log" % (LIBRARY_NAME)), "w",
                   logging.WARNING)]
    logger = Logger(LIBRARY_NAME,
                    log_files,
                    use_stdout=False,
                    min_log_level=logging.INFO)
    initUtils(logger, disas)
    logger.info("Started the Script")

    # Active the matching mode
    setMatchingMode()

    # Init the strings list (Only once, because it's heavy to calculate)
    logger.info("Building a list of all of the strings in the binary")

    # Start matching the libraries
    logger.info("Going to locate and match the open source libraries")
    matchLibraries()

    # Finished successfully
    logger.info("Finished Successfully")

    # Notify the user about the logs
    disas.messageBox("Saved the logs to directory: %s" % (working_path))
def pluginMain():
    """Run the Karta (identifier) plugin."""
    global logger, disas

    logger = Logger(LIBRARY_NAME, [],
                    use_stdout=False,
                    min_log_level=logging.INFO)
    initUtils(logger, createDisassemblerHandler(logger))
    disas = getDisas()
    logger.info("Started the Script")

    # Init the strings list (Only once, because it's heavy to calculate)
    logger.info("Building a list of all of the strings in the binary")

    # Start identifying the libraries
    logger.info("Going to identify the open (and closed) source libraries")
    identifyLibraries()

    # Finished successfully
    logger.info("Finished Successfully")
Exemple #4
0
        if ".text" not in disas.segmentName(segment_idx):
            continue
        for function_ea in disas.segmentFunctions(segment_idx):
            src_ctx = disas.analyzeFunction(function_ea, True)
            # check if static or not
            if src_ctx.name not in exported:
                src_ctx.markStatic()
            contexts.append(src_ctx)
    functionsToFile(disas.inputFile(), contexts)
    logger.info("Finished Successfully")


# Create a basic logger for the init phase
init_logger = Logger(LIBRARY_NAME)
init_logger.linkHandler(logging.FileHandler(constructInitLogPath(), "w"))
disas = createDisassemblerHandler(init_logger)
# In case of a dependency issue, disas will be None
if disas is None:
    exit()
# Always init the utils before we start (now with the real logger too)
logger = Logger(LIBRARY_NAME, use_stdout=False)
initUtils(logger, disas)
# Register our contexts
registerContexts(SourceContext, BinaryContext, IslandContext)
# Start to analyze the file
try:
    logger.linkHandler(logging.FileHandler(constructLogPath(), "w"))
    analyzeFile()
except Exception:
    logger.error(traceback.format_exc())
# Exit the disassembler
        setWindowsMode()
    # build the list of exported (non-static) functions
    exported = disas.exports()
    for segment_idx in xrange(disas.numSegments()):
        if ".text" not in disas.segmentName(segment_idx):
            continue
        for function_ea in disas.segmentFunctions(segment_idx):
            src_ctx = disas.analyzeFunction(function_ea, True)
            # check if static or not
            if src_ctx.name not in exported:
                src_ctx.markStatic()
            contexts.append(src_ctx)
    functionsToFile(disas.inputFile(), contexts)
    logger.info("Finished Successfully")


# create a logger
logger = Logger(LIBRARY_NAME, use_stdout=False)
# Always init the utils before we start
initUtils(logger, createDisassemblerHandler(logger))
# Register our contexts
registerContexts(SourceContext, BinaryContext, IslandContext)
# Start to analyze the file
try:
    logger.linkHandler(logging.FileHandler(constructLogPath(), "w"))
    analyzeFile()
except Exception:
    logger.error(traceback.format_exc())
# Exit the disassembler
getDisas().exit()