def pluginMain(): """Run the Karta (matcher) plugin.""" global disas, logger, config_path # init our disassembler handler disas = createDisassemblerHandler(None) # 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")
exported = disas.exports() for segment_idx in range(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 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:
def main(): """Start Thumbs Up IDA plugin - ELF version.""" # Init the logger logger = Logger("Thumb's Up Logger", [("thumbs_up.log", "w", logging.DEBUG)], use_stdout=False, min_log_level=logging.INFO) logger.linkHandler(IdaLogHandler()) # Locate the segments code_segments = filter(lambda x: x.type == 2, sark.segments()) data_segments = filter(lambda x: x.type in (0, 3), sark.segments()) # Sanity checks if len(code_segments) == 0: logger.error("Failed to find any code segment, can't continue...") return # Notify the user about our segment decisions for sc in code_segments: logger.info("Code Segment: 0x%x - 0x%x", sc.startEA, sc.endEA) for sd in data_segments: logger.info("Data Segment: 0x%x - 0x%x", sd.startEA, sd.endEA) # Build up the analyzer analyzer = createAnalyzer(logger, True) # Sanity check if analyzer is None: logger.error("Exiting") return # Finish building the analyzer analyzer.linkFunctionClassifier() analyzer.linkFptrIdentifier() analyzer.linkStringIdentifier() analyzer.linkLocalsIdentifier() analyzer.linkSwitchIdentifier() # Start the analysis logger.info("Starting the analysis") result = analysisStart(analyzer, code_segments, data_segments) if result: logger.info("Successfully finished the analysis") else: logger.error("Encountered an error during the analysis")
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")
def main(): """Start Thumbs Up IDA plugin - Firmware version.""" # Init the logger logger = Logger("Thumbs Up Logger", [("thumbs_up.log", "w", logging.INFO)], use_stdout=False, min_log_level=logging.INFO) logger.linkHandler(IdaLogHandler()) # Locate the segments code_segments = [sc for sc in sark.segments() if sc.type == 2] data_segments = [sc for sc in sark.segments() if sc.type in [0, 3]] # Sanity checks if len(code_segments) == 0: logger.error("Failed to find any code segment, can't continue...") return if len(data_segments) == 0: logger.error("Failed to find any data segment, can't continue...") return # Notify the user about our segment decisions logger.info("Segments, as marked by the disassembler:") for sc in code_segments: logger.info(f"Code Segment: 0x{sc.start_ea:x} - 0x{sc.end_ea:x}") for sd in data_segments: logger.info(f"Data Segment: 0x{sd.start_ea:x} - 0x{sd.end_ea:x}") # Build up the analyzer analyzer = createAnalyzer(logger, False) # Sanity check if analyzer is None: logger.error("Exiting") return # Finish building the analyzer analyzer.linkFunctionClassifier() analyzer.linkFptrIdentifier() analyzer.linkStringIdentifier() analyzer.linkLocalsIdentifier() analyzer.linkSwitchIdentifier() # Notify the user about the code types analyzer.presentCodeTypes() # Start the analysis logger.info("Starting the analysis") result = analysisStart(analyzer, code_segments, data_segments) if result: logger.info("Successfully finished the analysis") else: logger.error("Encountered an error during the analysis")