Van-Truong Pham

45 papers C 1Journal 31Unranked 13
YearRankTypeTitle / Venue / Authors
2026 J jnl
Biomed. Signal Process. Control.
Viet-Thanh Nguyen, Gia-Bao Truong, Van-Truong Pham, Thi-Thao Tran
2025 J jnl
Image Vis. Comput.
Van Quang Nguyen, Thi-Thao Tran, Gia-Bao Truong, Nhu-Linh Than, Ngoc-Khai Hoang, Dinh-Hieu Nguyen, Van-Truong Pham
2025 J jnl
J. Imaging Inform. Medicine
Viet-Tien Pham, Tu Ngoc Vu, Hoang-Minh-Quang Le, Van-Truong Pham, Thi-Thao Tran
2025 J jnl
Pattern Anal. Appl.
Ngoc-Khai Hoang, Dinh-Hieu Nguyen, Thi-Thao Tran, Van-Truong Pham
2025 J jnl
J. Imaging Inform. Medicine
Minh-Nhat Trinh, Thi-Thao Tran, Do-Hai-Ninh Nham, Men-Tzung Lo, Van-Truong Pham
2025 conf
IUKM (1)
Quang-Huy Ho, Thi-Nhu-Quynh Nguyen, Duy-Thai Nguyen, Minh-Quang Phan, Thi-Thao Tran, Van-Truong Pham
2025 J jnl
Biomed. Signal Process. Control.
Ngoc-Du Tran, Thi-Thao Tran, Quang-Huy Nguyen, Manh-Hung Vu, Van-Truong Pham
2025 J jnl
Neurocomputing
Duy-Thai Nguyen, Van-Quoc-Viet Nguyen, Thi-Thao Tran, Van-Truong Pham
2025 J jnl
Appl. Intell.
Nhu-Linh Than, Van Quang Nguyen, Gia-Bao Truong, Van-Truong Pham, Thi-Thao Tran
2025 J jnl
Cogn. Comput.
Van-Quang Nguyen, Thi-Thao Tran, Manh-Hung Vu, Van-Truong Pham, Men-Tzung Lo
2025 J jnl
Multim. Tools Appl.
Dinh-Hieu Nguyen, Ngoc-Khai Hoang, Van-Truong Pham, Thi-Thao Tran
2025 J jnl
Comput. Electr. Eng.
Gia-Bao Truong, Thi-Thao Tran, Nhu-Linh Than, Van Quang Nguyen, Nguyen Thi Hue, Van-Truong Pham
2024 J jnl
CoRR
Viet-Thanh Nguyen, Van-Truong Pham, Thi-Thao Tran
2024 J jnl
IEEE Trans. Instrum. Meas.
Manh-Hung Vu, Van-Quang Nguyen, Thi-Thao Tran, Van-Truong Pham, Men-Tzung Lo
2024 J jnl
CoRR
Ngoc-Du Tran, Thi-Thao Tran, Quang-Huy Nguyen, Manh-Hung Vu, Van-Truong Pham
2024 J jnl
CoRR
Thi-Nhu-Quynh Nguyen, Quang-Huy Ho, Duy-Thai Nguyen, Hoang-Minh-Quang Le, Van-Truong Pham, Thi-Thao Tran
2024 J jnl
CoRR
Dinh-Phu Tran, Quoc-Anh Nguyen, Van-Truong Pham, Thi-Thao Tran
2023 conf
APSIPA ASC
Binh-Duong Dinh, Thanh-Thu Nguyen, Thi-Thao Tran, Van-Truong Pham
2023 J jnl
CoRR
Binh-Duong Dinh, Thanh-Thu Nguyen, Thi-Thao Tran, Van-Truong Pham
2023 conf
ICSSE
Thi-Thao Tran, Dinh-Thien Vu, Thi-Hue Nguyen, Van-Truong Pham
2023 conf
ICSSE
Van-Quang Nguyen, Manh-Hung Vu, Van-Truong Pham, Thi-Thao Tran
2023 J jnl
EAI Endorsed Trans. Ind. Networks Intell. Syst.
Thanh Viet Le, Van Yem Vu, Van-Truong Pham, Thi-Thao Tran
2023 J jnl
Biomed. Signal Process. Control.
Do-Hai-Ninh Nham, Minh-Nhat Trinh, Viet-Dung Nguyen, Van-Truong Pham, Thi-Thao Tran
2023 J jnl
EAI Endorsed Trans. Ind. Networks Intell. Syst.
Thanh Viet Le, Hoang-Minh-Quang Le, Van Yem Vu, Thi-Thao Tran, Van-Truong Pham
2023 conf
RIVF
Thanh-Thu Nguyen, Binh-Duong Dinh, Thi-Thao Tran, Van-Truong Pham
2023 conf
ICSSE
Ngoc-Tu Vu, Viet-Tien Pham, Van-Truong Pham, Thi-Thao Tran
2023 conf
RIVF
Viet-Tien Pham, Ngoc-Tu Vu, Van-Truong Pham, Thi-Thao Tran
2023 conf
ICCAIS
Manh-Hung Vu, Van-Truong Pham
2023 conf
ICCAIS
Ngoc-Tu Vu, Viet-Tien Pham, Thi-Thao Tran, Van-Truong Pham
2022 conf
RIVF
Minh-Nhat Trinh, Do-Hai-Ninh Nham, Van-Truong Pham, Thi-Thao Tran
2022 J jnl
Multim. Tools Appl.
Thi-Thao Tran, Van-Truong Pham
2022 conf
ICCAIS
Ngoc-Du Tran, Huy-Hoang Le, Van-Truong Pham, Thi-Thao Tran
2022 conf
RIVF
Trung-Kien Le, Hoang-Minh-Quang Le, Thi-Thao Tran, Van-Truong Pham
2022 conf
ICCAIS
Dinh-Phu Tran, Quoc-Anh Nguyen, Van-Truong Pham, Thi-Thao Tran
2021 J jnl
Artif. Intell. Medicine
Van-Truong Pham, Thi-Thao Tran, Pa-Chun Wang, Po-Yu Chen, Men-Tzung Lo
2021 J jnl
Signal Image Video Process.
Van-Truong Pham, Thi-Thao Tran, Pa-Chun Wang, Men-Tzung Lo
2019 J jnl
IEEE J. Biomed. Health Informatics
Thi-Thao Tran, Van-Truong Pham, Chen Lin, Hui-Wen Yang, Yung-Hung Wang, Kuo-Kai Shyu, Wen-Yih Isaac Tseng, Mao-Yuan Marine Su, Lian-Yu Lin, Men-Tzung Lo
2016 J jnl
Eng. Appl. Artif. Intell.
Van-Truong Pham, Thi-Thao Tran, Kuo-Kai Shyu, Chen Lin, Pa-Chun Wang, Men-Tzung Lo
2014 J jnl
J. Vis. Commun. Image Represent.
Thi-Thao Tran, Van-Truong Pham, Kuo-Kai Shyu
2014 J jnl
Mach. Vis. Appl.
Van-Truong Pham, Thi-Thao Tran, Kuo-Kai Shyu, Lian-Yu Lin, Yung-Hung Wang, Men-Tzung Lo
2014 J jnl
Signal Image Video Process.
Thi-Thao Tran, Van-Truong Pham, Kuo-Kai Shyu
2013 J jnl
Mach. Vis. Appl.
Thi-Thao Tran, Van-Truong Pham, Kuo-Kai Shyu
2012 J jnl
Mach. Vis. Appl.
Kuo-Kai Shyu, Van-Truong Pham, Thi-Thao Tran, Po-Lei Lee
2010 J jnl
IEEE Trans. Ind. Electron.
Kuo-Kai Shyu, Juu-Kuh Lin, Van-Truong Pham, Ming-Ji Yang, Te-Wei Wang
2008 C conf
ICARCV
Thi-Thao Tran, Po-Lei Lee, Van-Truong Pham, Kuo-Kai Shyu
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 "";
        }
    }
}