Carla Ilane Moreira Bezerra

24 papers B 2Journal 3Unranked 18
YearRankTypeTitle / Venue / Authors
2025 conf
INTERACT (1)
Davi Teixeira Silva, Carla Ilane Moreira Bezerra, José Cezar de Souza Filho, Ingrid Teixeira Monteiro, Anna Beatriz Marques
2025 J jnl
Braz. J. Inf. Syst.
Francisco Luciano Quirino da Silva, Andréia Libório Sampaio, Carla Ilane Moreira Bezerra, Ingrid Teixeira Monteiro
2024 conf
SBCARS
Carla Ilane Moreira Bezerra, Daniel Lucrédio, Johnny Marques
2024 J jnl
Empir. Softw. Eng.
Larissa Rocha, Edna Dias Canedo, Claudia Pinto Pereira, Carla Ilane Moreira Bezerra, Fabiana Freitas Mendes
2023 B conf
CHASE
Larissa Rocha, Edna Dias Canedo, Claudia Pinto Pereira, Carla Ilane Moreira Bezerra, Fabiana Freitas Mendes
2022 conf
SBCARS
Darwin Pinheiro, Carla Ilane Moreira Bezerra, Anderson G. Uchôa
2019 conf
SBSI
Júlio Serafim Martins, Carla Ilane Moreira Bezerra, Anderson G. Uchôa
2018 conf
SBBD
Jordão M. de Souza, Ticiana L. Coelho da Silva, Críston Pereira de Souza, Carla Ilane Moreira Bezerra, Lincoln S. Rocha, José Antônio Fernandes de Macêdo
2017 conf
SESoS/WDES
Emanuel Ferreira Coutinho, Ítalo Santos, Carla Ilane Moreira Bezerra
2017 J jnl
Softw. Qual. J.
Rainara M. Carvalho, Rossana Maria de Castro Andrade, Káthia Marçal de Oliveira, Ismayle de Sousa Santos, Carla Ilane Moreira Bezerra
2016 conf
VaMoS
Carla Ilane Moreira Bezerra, José Maria Monteiro, Rossana M. C. Andrade, Lincoln S. Rocha
2016
Carla Ilane Moreira Bezerra
2015 B conf
ICSR
Carla Ilane Moreira Bezerra, Rossana M. C. Andrade, José Maria Monteiro
2015 conf
SBSI
Paulo Ivo Alves Pordeus, Carla Ilane Moreira Bezerra, Emanuel Ferreira Coutinho
2014 conf
IHM
Carla Ilane Moreira Bezerra, Rossana M. de Castro Andrade, Rainara Maia Santos, Mourad Abed, Káthia Marçal de Oliveira, José Maria Monteiro, Ismayle de Sousa Santos, Houcine Ezzedine
2014 conf
SBSI
Camilo C. Almendra, Carla Ilane Moreira Bezerra, Letícia Mara Fernandes Nunes, Emanuel Ferreira Coutinho
2010 conf
SBQS
Luciana Ferreira Trindade, Carla Ilane Moreira Bezerra, Gabi Telles, Carlo Giovano S. Pires, Luiz Sérgio Plácido da Silva, Cicília Moreira, Joice Barbosa, Paula Luciana Ferreira
2010 conf
SBQS
Ana Sofia C. Marçal, Carla Ilane Moreira Bezerra, Ciro Carneiro Coelho, Carlo Giovano S. Pires, Gabriela Talles de Souza, Luciana Trindade
2009 conf
SBQS
Ana Sofia C. Marçal, Carla Ilane Moreira Bezerra, Carlo Giovano S. Pires, Ciro Carneiro Coelho, Gabriela Telles, Joice Barbosa
2009 conf
SBQS
Carla Ilane Moreira Bezerra, Ciro Carneiro Coelho, Francisca Márcia G. S. Gonçalves, Carlo Giovano S. Pires, Gabriela Telles, Adriano Bessa Albuquerque
2009 conf
CIbSE
Carla Ilane Moreira Bezerra, Ciro Carneiro Coelho, Carlo Giovano S. Pires, Adriano Albuquerque
2008 conf
Australian Software Engineering Conference
Francisca Márcia G. S. Gonçalves, Carla Ilane Moreira Bezerra, Arnaldo Dias Belchior, Ciro Carneiro Coelho, Carlo Giovano S. Pires
2008 conf
Australian Software Engineering Conference
Francisca Márcia G. S. Gonçalves, Carla Ilane Moreira Bezerra, Arnaldo Dias Belchior, Ciro Carneiro Coelho, Carlo Giovano S. Pires
2008 conf
SCSS (1)
Carla Ilane Moreira Bezerra, Ciro Carneiro Coelho, Carlo Giovano S. Pires, Adriano Bessa Albuquerque
redb/extractors/decompiler/_archive/GhidraDecompilerScript-latest.java
← Index redb/extractors/decompiler/_archive/GhidraDecompilerScript-latest.java java
import ghidra.app.script.GhidraScript;
import ghidra.program.model.listing.*;
import ghidra.app.decompiler.*;
import ghidra.program.model.block.*;
import ghidra.program.model.symbol.*;
import ghidra.program.model.pcode.*;
import ghidra.program.model.address.*;
import org.json.JSONObject;
import org.json.JSONArray;
import java.security.MessageDigest;
import java.nio.charset.StandardCharsets;

public class GhidraDecompilerScript extends GhidraScript {
    private DecompInterface decompInterface;
    private BasicBlockModel basicBlockModel;
    
    @Override
    public void run() throws Exception {
        // Get binary hash and filepath from arguments
        String[] args = getScriptArgs();
        if (args.length < 2) {
            System.err.println("{\"error\": \"Both SHA256 and filepath arguments are required\"}");
            return;
        }
        String sha256 = args[0];
        String filepath = args[1];

        // Initialize analysis components
        setupDecompiler();
        basicBlockModel = new BasicBlockModel(currentProgram);

        // Create the main JSON object for output
        JSONObject output = new JSONObject();
        output.put("sha256", sha256);
        output.put("decompiled", new JSONArray());
        output.put("disassembled", new JSONArray());
        output.put("cfg", new JSONArray());

        // Process all functions
        FunctionIterator functions = currentProgram.getFunctionManager().getFunctions(true);
        for (Function function : functions) {
            processFunction(function, output);
        }

        // Output the final JSON to stdout
        System.out.println(output.toString());
    }

    private void setupDecompiler() {
        decompInterface = new DecompInterface();
        DecompileOptions options = new DecompileOptions();
        decompInterface.setOptions(options);
        decompInterface.openProgram(currentProgram);
    }

    private void processFunction(Function function, JSONObject output) {
        Address entry = function.getEntryPoint();
        String functionName = function.getName();
        String functionAddress = entry.toString();

        // Process decompiled code
        processDecompiledCode(function, output.getJSONArray("decompiled"), 
                            functionName, functionAddress);

        // Process disassembled code
        processDisassembledCode(function, output.getJSONArray("disassembled"), 
                              functionName, functionAddress);

        // Process CFG
        processCFG(function, output.getJSONArray("cfg"), functionAddress);
    }

    private void processDecompiledCode(Function function, JSONArray decompArray, 
                                     String functionName, String functionAddress) {
        DecompileResults results = decompInterface.decompileFunction(function, 30, monitor);
        if (results.decompileCompleted()) {
            String decompiledCode = results.getDecompiledFunction().getC();
            String contentHash = calculateHash(decompiledCode);

            JSONObject functionObj = new JSONObject();
            functionObj.put("decompiled_content_hash", contentHash);
            functionObj.put("decompiled_function_name", functionName);
            functionObj.put("decompiled_function_address", functionAddress);
            functionObj.put("decompiled_function", decompiledCode);
            
            decompArray.put(functionObj);
        }
    }

    private void processDisassembledCode(Function function, JSONArray disasmArray, 
                                       String functionName, String functionAddress) {
        try {
            StringBuilder disassembly = new StringBuilder();
            StringBuilder normalized = new StringBuilder();
            int instructionCount = 0;

            Listing listing = currentProgram.getListing();
            AddressSetView functionBody = function.getBody();
            InstructionIterator instructions = listing.getInstructions(functionBody, true);

            while (instructions.hasNext()) {
                try {
                    Instruction instr = instructions.next();
                    String disasmLine = instr.toString();
                    disassembly.append(disasmLine).append("\n");
                    normalized.append(normalizeInstruction(disasmLine)).append("\n");
                    instructionCount++;
                } catch (Exception e) {
                    System.err.println("Error processing instruction in " + functionName + ": " + e.getMessage());
                }
            }

            String disassembledCode = disassembly.toString();
            String contentHash = calculateHash(disassembledCode);

            JSONObject functionObj = new JSONObject();
            functionObj.put("disassembled_content_hash", contentHash);
            functionObj.put("disassembled_function_name", functionName);
            functionObj.put("disassembled_function_address", functionAddress);
            functionObj.put("disassembled_function", disassembledCode);
            functionObj.put("normalized_disassembly", normalized.toString());
            functionObj.put("instruction_count", instructionCount);

            // Set similarity-related fields to null for now
            functionObj.put("minhash_signature", JSONObject.NULL);
            functionObj.put("opcode_frequency_vector", JSONObject.NULL);
            functionObj.put("api_calls_vector", JSONObject.NULL);
            functionObj.put("instruction_embedding", JSONObject.NULL);

            disasmArray.put(functionObj);
        } catch (Exception e) {
            System.err.println("Error processing disassembly for " + functionName + ": " + e.getMessage());
        }
    }

    private void processCFG(Function function, JSONArray cfgArray, String functionAddress) {
        try {
            CodeBlockIterator blocks = basicBlockModel.getCodeBlocksContaining(
                function.getBody(), monitor);

            while (blocks.hasNext()) {
                CodeBlock block = blocks.next();
                String blockInstructions = getBlockInstructions(block);
                String blockId = calculateHash(blockInstructions);

                JSONObject blockObj = new JSONObject();
                blockObj.put("block_id", blockId);
                blockObj.put("function_address", functionAddress);
                blockObj.put("block_instructions", blockInstructions);

                // Get successor blocks
                CodeBlockReferenceIterator successors = block.getDestinations(monitor);
                JSONArray successorAddresses = new JSONArray();
                while (successors.hasNext()) {
                    CodeBlockReference ref = successors.next();
                    successorAddresses.put(ref.getDestinationAddress().toString());
                }
                blockObj.put("successor_blocks", successorAddresses);

                cfgArray.put(blockObj);
            }
        } catch (Exception e) {
            System.err.println("{\"error\": \"Error processing CFG: " + 
                             e.getMessage().replace("\"", "'") + "\"}");
        }
    }

    private String normalizeInstruction(String instruction) {
        return instruction.replaceAll("0x[0-9a-fA-F]+", "IMM")
                        .replaceAll("\\b\\d+\\b", "NUM");
    }

    private String getBlockInstructions(CodeBlock block) {
        StringBuilder instructions = new StringBuilder();
        AddressIterator addresses = block.getAddresses(true);
        while (addresses.hasNext()) {
            Address addr = addresses.next();
            Instruction instr = currentProgram.getListing().getInstructionAt(addr);
            if (instr != null) {
                instructions.append(instr.toString()).append("\n");
            }
        }
        return instructions.toString();
    }

    private String calculateHash(String content) {
        try {
            MessageDigest digest = MessageDigest.getInstance("SHA-256");
            byte[] hash = digest.digest(content.getBytes(StandardCharsets.UTF_8));
            StringBuilder hexString = new StringBuilder();
            for (byte b : hash) {
                hexString.append(String.format("%02x", b));
            }
            return hexString.toString();
        } catch (Exception e) {
            System.err.println("{\"error\": \"Error calculating hash\"}");
            return "";
        }
    }
}