Weilin Luo

64 papers A* 13A 4C 2Misc 1Journal 30Unranked 14
YearRankTypeTitle / Venue / Authors
2026 A* conf
AAAI
Jingyuan Ma, Damai Dai, Zihang Yuan, Rui Li, Weilin Luo, Bin Wang, Qun Liu, Lei Sha, Zhifang Sui
2026 A* conf
AAAI
Yixin Yang, Qingxiu Dong, Linli Yao, Fangwei Zhu, Weilin Luo, Bin Wang, Zhifang Sui
2025 J jnl
CoRR
Weilin Luo, Xueyi Liang, Haotian Deng, Yanan Liu, Hai Wan
2025 J jnl
J. Frankl. Inst.
Weilin Luo, Chengyu Lin
2025 J jnl
CoRR
Weidong Zhan, Yue Wang, Nan Hu, Liming Xiao, Jingyuan Ma, Yuhang Qin, Zheng Li, Yixin Yang, Sirui Deng, Jinkun Ding, Wenhan Ma, Rui Li, Weilin Luo, Qun Liu, Zhifang Sui
2025 J jnl
Inf. Sci.
Yanan Liu, Hai Wan, Jianfeng Du, Yao Wang, Kunxun Qi, Weilin Luo
2025 J jnl
Proc. ACM Softw. Eng.
Weilin Luo, Tingchen Han, Junming Qiu, Hai Wan, Jianfeng Du, Bo Peng, Guohui Xiao, Yanan Liu
2025 A conf
CIKM
Junming Qiu, Rongzhen Ye, Weilin Luo, Kunxun Qi, Hai Wan, Yue Yu
2025 C conf
ISNN
Yang Chen, Huiyi Luo, Weilin Luo
2024 A* conf
AAAI
Hai Wan, Pingjia Liang, Jianfeng Du, Weilin Luo, Rongzhen Ye, Bo Peng
2024 J jnl
J. Syst. Softw.
Weilin Luo, Polong Chen, Hai Wan, Hongzhen Zhong, Shaowei Cai, Zhanhao Xiao
2024 conf
NIER@ICSE
Weilin Luo, Weiyuan Fang, Junming Qiu, Hai Wan, Yanan Liu, Rongzhen Ye
2024 J jnl
Circuits Syst. Signal Process.
Weilin Luo, Xiaobai Li, Hao Li, Hongbin Jin, Ruijuan Yang
2024 A* conf
ICLR
Chang Liu, Zhichen Dong, Haobo Ma, Weilin Luo, Xijun Li, Bowen Pang, Jia Zeng, Junchi Yan
2024 A conf
ISSTA
Weilin Luo, Pingjia Liang, Junming Qiu, Polong Chen, Hai Wan, Jianfeng Du, Weiyuan Fang
2024 J jnl
CoRR
Xijun Li, Fangzhou Zhu, Hui-Ling Zhen, Weilin Luo, Meng Lu, Yimin Huang, Zhenan Fan, Zirui Zhou, Yufei Kuang, Zhihai Wang, Zijie Geng, Yang Li, Haoyang Liu, Zhiwu An, Muming Yang, Jianshu Li, Jie Wang, Junchi Yan, Defeng Sun, Tao Zhong, Yong Zhang, Jia Zeng, Mingxuan Yuan, Jianye Hao, Jun Yao, Kun Mao
2023 A* conf
AAAI
Rongzhen Ye, Tianqu Zhuang, Hai Wan, Jianfeng Du, Weilin Luo, Pingjia Liang
2023 A* conf
ASE
Bo Peng, Pingjia Liang, Tingchen Han, Weilin Luo, Jianfeng Du, Hai Wan, Rongzhen Ye, Yuhang Zheng
2023 J jnl
CoRR
Chao Yu, Xuejing Zheng, Hankz Hankui Zhuo, Hai Wan, Weilin Luo
2023 A* conf
ASE
Weilin Luo, Yuhang Zheng, Rongzhen Ye, Hai Wan, Jianfeng Du, Pingjia Liang, Polong Chen
2022 conf
ICTA
Chi Chen, Kuan Hu, Weilin Luo, Kang Yin, Ruiyuan Kang, Ying Zhao, Fei Yang
2022 J jnl
CoRR
Rongzhen Ye, Tianqu Zhuang, Hai Wan, Jianfeng Du, Weilin Luo, Pingjia Liang
2022 A* conf
AAAI
Weilin Luo, Pingjia Liang, Jianfeng Du, Hai Wan, Bo Peng, Delong Zhang
2022 A* conf
ASE
Weilin Luo, Hai Wan, Delong Zhang, Jianfeng Du, Hengdi Su
2022 A* conf
AAAI
Weilin Luo, Rongzhen Ye, Hai Wan, Shaowei Cai, Biqing Fang, Delong Zhang
2022 J jnl
IEEE Trans. Syst. Man Cybern. Syst.
Weilin Luo, Jinhu Lü, Kexin Liu, Lei Chen
2022 J jnl
IEEE Trans. Circuits Syst. I Regul. Pap.
Guoliang Zhu, Kexin Liu, Haibo Gu, Weilin Luo, Jinhu Lü
2022 J jnl
IEEE Trans. Circuits Syst. I Regul. Pap.
Weilin Luo, Lei Chen, Kexin Liu, Haibo Gu, Jinhu Lü
2022 A* conf
IJCAI
Weilin Luo, Hai Wan, Jianfeng Du, Xiaoda Li, Yuze Fu, Rongzhen Ye, Delong Zhang
2021 conf
ACL/IJCNLP (1)
Hai Wan, Haicheng Chen, Jianfeng Du, Weilin Luo, Rongzhen Ye
2021 A conf
ICCAD
Weilin Luo, Hai Wan, Hongzhen Zhong, Ou Wei, Biqing Fang, Xiaotong Song
2021 A* conf
ICSE
Weilin Luo, Hai Wan, Xiaotong Song, Binhao Yang, Hongzhen Zhong, Yin Chen
2021 J jnl
CoRR
Weilin Luo, Hai Wan, Xiaotong Song, Binhao Yang, Hongzhen Zhong, Yin Chen
2021 A* conf
ICDE
Xijun Li, Weilin Luo, Mingxuan Yuan, Jun Wang, Jiawen Lu, Jie Wang, Jinhu Lü, Jia Zeng
2021 J jnl
CoRR
Xijun Li, Weilin Luo, Mingxuan Yuan, Jun Wang, Jiawen Lu, Jie Wang, Jinhu Lu, Jia Zeng
2021 J jnl
IEEE Trans. Reliab.
Weilin Luo, Ou Wei, Hai Wan
2021 J jnl
CoRR
Hongzhen Zhong, Hai Wan, Weilin Luo, Zhanhao Xiao, Jia Li, Biqing Fang
2021 conf
SPAC
Weilin Luo, Fan Zhang
2021 J jnl
IEEE Access
Weilin Luo, Shunqiang Duan, Jiwen Zheng
2020 J jnl
IEEE Access
Weilin Luo, Hongbin Jin, Hao Li, Xi Fang, Ronghua Zhou
2020 C conf
APSEC
Hongzhen Zhong, Hai Wan, Weilin Luo, Zhanhao Xiao, Jia Li, Biqing Fang
2019 J jnl
CoRR
Weilin Luo, Hai Wan, Hongzhen Zhong, Ou Wei
2019 J jnl
CoRR
Peilin Chen, Hai Wan, Shaowei Cai, Weilin Luo, Jia Li
2019 conf
ICCA
Weilin Luo, Tieshan Li
2017 J jnl
Neurocomputing
Weilin Luo, Bingbing Hu, Tieshan Li
2017 conf
ISNN (2)
Weilin Luo, Hongchao Cong
2017 A conf
ISSRE
Weilin Luo, Ou Wei
2016 J jnl
Algorithms
Weilin Luo, Hongchao Cong
2016 conf
ICACI
Ye Tian, Tieshan Li, Baobin Miao, Weilin Luo
2013 J jnl
Neurocomputing
Baobin Miao, Tieshan Li, Weilin Luo
2013 J jnl
Microelectron. Reliab.
Weilin Luo, Chao Lyu, Lixin Wang, Liqiang Zhang
2013 conf
ISNN (2)
Baobin Miao, Tieshan Li, Weilin Luo, Xiaori Gao
2013 conf
ICONS
Baobin Miao, Tieshan Li, Weilin Luo
2013 conf
ISNN (2)
Weilin Luo, Wenjing Lv, Zaojian Zou
2011 conf
ISNN (2)
Weilin Luo, Zaojian Zou
2010 J jnl
Int. J. Model. Identif. Control.
Tieshan Li, Wei Li, Weilin Luo
2006 J jnl
IEEE Trans. Veh. Technol.
Jitendra K. Tugnait, Weilin Luo
2004 J jnl
IEEE Trans. Signal Process.
Jitendra K. Tugnait, Weilin Luo
2003 conf
ICASSP (4)
Weilin Luo, Jitendra K. Tugnait
2003 conf
ICASSP (4)
Jitendra K. Tugnait, Weilin Luo
2003 J jnl
IEEE Commun. Lett.
Jitendra K. Tugnait, Weilin Luo
2002 Misc conf
ICASSP
Weilin Luo, Jitendra K. Tugnait
2002 conf
ISCAS (1)
Weilin Luo, Jitendra K. Tugnait
2002 J jnl
IEEE Trans. Signal Process.
Jitendra K. Tugnait, Weilin Luo
redb/extractors/decompiler/_archive/GhidraDecompilerScript-v2.java
← Index redb/extractors/decompiler/_archive/GhidraDecompilerScript-v2.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 {
        System.err.println("{\"debug\": \"Script starting\"}");

        // 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];

        // Add debug output after setup
        System.err.println("{\"debug\": \"Processing file: " + 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);
        }

        System.err.println("{\"debug\": \"Preparing final 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) {
        try {
            Address entry = function.getEntryPoint();
            String functionName = function.getName();
            String functionAddress = entry.toString();

            // Process each analysis type independently
            boolean hasAnyResults = false;

            try {
                if (processDecompiledCode(function, output.getJSONArray("decompiled"),
                                        functionName, functionAddress)) {
                    hasAnyResults = true;
                }
            } catch (Exception e) {
                System.err.println(String.format(
                    "{\"error\": \"Decompilation failed for function %s: %s\"}",
                    functionName, e.getMessage().replace("\"", "'")));
            }

            try {
                if (processDisassembledCode(function, output.getJSONArray("disassembled"),
                                        functionName, functionAddress)) {
                    hasAnyResults = true;
                }
            } catch (Exception e) {
                System.err.println(String.format(
                    "{\"error\": \"Disassembly failed for function %s: %s\"}",
                    functionName, e.getMessage().replace("\"", "'")));
            }

            try {
                if (processCFG(function, output.getJSONArray("cfg"), functionAddress)) {
                    hasAnyResults = true;
                }
            } catch (Exception e) {
                System.err.println(String.format(
                    "{\"error\": \"CFG extraction failed for function %s: %s\"}",
                    functionName, e.getMessage().replace("\"", "'")));
            }

            if (!hasAnyResults) {
                System.err.println(String.format(
                    "{\"warning\": \"No results obtained for function %s\"}",
                    functionName));
            }

        } catch (Exception e) {
            System.err.println(String.format(
                "{\"error\": \"Failed to process function: %s\"}",
                e.getMessage().replace("\"", "'")));
        }
    }

    private boolean processDecompiledCode(Function function, JSONArray decompArray,
                                        String functionName, String functionAddress) {
        try {
            DecompileResults results = decompInterface.decompileFunction(function, 30, monitor);
            if (results == null || !results.decompileCompleted()) {
                System.err.println(String.format(
                    "{\"warning\": \"Decompilation incomplete for function %s\"}",
                    functionName));
                return false;
            }

            String decompiledCode = results.getDecompiledFunction().getC();
            if (decompiledCode == null || decompiledCode.trim().isEmpty()) {
                System.err.println(String.format(
                    "{\"warning\": \"Empty decompilation result for function %s\"}",
                    functionName));
                return false;
            }

            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);
            return true;

        } catch (Exception e) {
            throw new RuntimeException("Decompilation error: " + e.getMessage(), e);
        }
    }

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

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

            while (instructions.hasNext()) {
                try {
                    Instruction instr = instructions.next();
                    if (instr != null) {
                        String disasmLine = instr.toString();
                        if (disasmLine != null && !disasmLine.trim().isEmpty()) {
                            disassembly.append(disasmLine).append("\n");
                            normalized.append(normalizeInstruction(disasmLine)).append("\n");
                            instructionCount++;
                            hasValidInstructions = true;
                        }
                    }
                } catch (Exception e) {
                    System.err.println(String.format(
                        "{\"warning\": \"Skipped invalid instruction in %s: %s\"}",
                        functionName, e.getMessage().replace("\"", "'")));
                }
            }

            if (!hasValidInstructions) {
                System.err.println(String.format(
                    "{\"warning\": \"No valid instructions found in function %s\"}",
                    functionName));
                return false;
            }

            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);

            // Initialize similarity fields as null
            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);
            return true;

        } catch (Exception e) {
            throw new RuntimeException("Disassembly error: " + e.getMessage(), e);
        }
    }

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

            boolean hasValidBlocks = false;

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

                    if (blockInstructions == null || blockInstructions.trim().isEmpty()) {
                        continue;
                    }

                    String blockId = calculateHash(blockInstructions);

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

                    // Process successors with error handling
                    JSONArray successorAddresses = new JSONArray();
                    try {
                        CodeBlockReferenceIterator successors = block.getDestinations(monitor);
                        while (successors.hasNext()) {
                            try {
                                CodeBlockReference ref = successors.next();
                                if (ref != null && ref.getDestinationAddress() != null) {
                                    successorAddresses.put(ref.getDestinationAddress().toString());
                                }
                            } catch (Exception e) {
                                System.err.println(String.format(
                                    "{\"warning\": \"Skipped invalid successor in block %s: %s\"}",
                                    blockId, e.getMessage().replace("\"", "'")));
                            }
                        }
                    } catch (Exception e) {
                        System.err.println(String.format(
                            "{\"warning\": \"Error processing successors for block %s: %s\"}",
                            blockId, e.getMessage().replace("\"", "'")));
                    }

                    blockObj.put("successor_blocks", successorAddresses);
                    cfgArray.put(blockObj);
                    hasValidBlocks = true;

                } catch (Exception e) {
                    System.err.println(String.format(
                        "{\"warning\": \"Skipped invalid block in function %s: %s\"}",
                        functionAddress, e.getMessage().replace("\"", "'")));
                }
            }

            return hasValidBlocks;

        } catch (Exception e) {
            throw new RuntimeException("CFG extraction error: " + e.getMessage(), e);
        }
    }

    private String getBlockInstructions(CodeBlock block) {
        StringBuilder instructions = new StringBuilder();
        try {
            AddressIterator addresses = block.getAddresses(true);
            while (addresses.hasNext()) {
                try {
                    Address addr = addresses.next();
                    if (addr != null) {
                        Instruction instr = currentProgram.getListing().getInstructionAt(addr);
                        if (instr != null) {
                            instructions.append(instr.toString()).append("\n");
                        }
                    }
                } catch (Exception e) {
                    System.err.println(String.format(
                        "{\"warning\": \"Skipped invalid instruction at address %s: %s\"}",
                        addresses.next(), e.getMessage().replace("\"", "'")));
                }
            }
        } catch (Exception e) {
            System.err.println(String.format(
                "{\"warning\": \"Error getting block instructions: %s\"}",
                e.getMessage().replace("\"", "'")));
        }
        return instructions.toString();
    }

    private String normalizeInstruction(String instruction) {
        try {
            if (instruction == null || instruction.trim().isEmpty()) {
                return "";
            }
            return instruction.replaceAll("0x[0-9a-fA-F]+", "IMM")
                            .replaceAll("\\b\\d+\\b", "NUM")
                            .replaceAll("[\\[\\]\\+\\-\\*/%&|^]+", "_OP_");
        } catch (Exception e) {
            System.err.println(String.format(
                "{\"warning\": \"Error normalizing instruction: %s\"}",
                e.getMessage().replace("\"", "'")));
            return instruction;
        }
    }

    private String calculateHash(String content) {
        try {
            if (content == null || content.trim().isEmpty()) {
                return "";
            }
            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(String.format(
                "{\"error\": \"Error calculating hash: %s\"}",
                e.getMessage().replace("\"", "'")));
            return "";
        }
    }
}