K. R. Rao

78 papers B 5C 4Misc 7Journal 54Unranked 8
YearRankTypeTitle / Venue / Authors
2022 J jnl
Signal Process. Image Commun.
Shiba Kuanar, Vassilis Athitsos, Dwarikanath Mahapatra, K. R. Rao
2022 J jnl
Vis. Comput.
Shiba Kuanar, Dwarikanath Mahapatra, Monalisa Bilas, K. R. Rao
2021 J jnl
Signal Process. Image Commun.
Shiba Kuanar, K. R. Rao, Christopher Conly, Ninad Gorey
2019 J jnl
J. Intell. Fuzzy Syst.
Preethi S. Nair, K. R. Rao, Madhu S. Nair
2019 J jnl
Circuits Syst. Signal Process.
Shiba Kuanar, K. R. Rao, Monalisa Bilas, Jonathan Bredow
2019 B conf
ICIP
Shiba Kuanar, Vassilis Athitsos, Dwarikanath Mahapatra, K. R. Rao, Zahid Akhtar, Dipankar Dasgupta
2019 J jnl
CoRR
Shiba Kuanar, K. R. Rao, Dwarikanath Mahapatra, Monalisa Bilas
2018 Misc conf
ICASSP
Shiba Kuanar, Vassilis Athitsos, Nityananda Pradhan, Arabinda Mishra, K. R. Rao
2018 C conf
PCS
Shiba Kuanar, Christopher Conly, K. R. Rao
2018 conf
ICME Workshops
Shiba Kuanar, K. R. Rao, Christopher Conly
2017 J jnl
CoRR
Tuan Ho, Ioannis D. Schizas, K. R. Rao, Madhukar Budagavi
2017 B conf
ICIP
Tuan Ho, Ioannis D. Schizas, K. R. Rao, Madhukar Budagavi
2011 J jnl
Int. J. Wavelets Multiresolution Inf. Process.
Aruna Ravi, K. R. Rao
2010 J jnl
EURASIP J. Image Video Process.
Lei Zhang, Sebastiano Battiato, Zhou Wang, Raimondo Schettini, K. R. Rao
2010 J jnl
Int. J. Wavelets Multiresolution Inf. Process.
Theju Jacob, K. R. Rao, Do Nyeon Kim
2009 J jnl
Algorithms
Do Nyeon Kim, K. R. Rao
2008 J jnl
IEICE Trans. Fundam. Electron. Commun. Comput. Sci.
Sangseok Park, K. R. Rao
2007 C conf
ISCAS
Yodchanan Wongsawat, Soontorn Oraintara, K. R. Rao
2006 conf
EUSIPCO
Yodchanan Wongsawat, Soontorn Oraintara, K. R. Rao
2006 J jnl
IEEE Trans. Speech Audio Process.
Yoshikazu Yokotani, Ralf Geiger, G. D. T. Schuller, Soontorn Oraintara, K. R. Rao
2006 J jnl
J. Vis. Commun. Image Represent.
Soon-kak Kwon, A. Tamhankar, K. R. Rao
2006 J jnl
J. Electronic Imaging
Lin Tong, K. R. Rao
2006 B conf
NOSSDAV
Nandakishore Ramaswamy, K. R. Rao
2005 J jnl
IEEE Trans. Broadcast.
Soon-kak Kwon, K. R. Rao, Oh Jun Kwon, Tai Suk Kim
2005 conf
ISCAS (6)
Yodchanan Wongsawat, K. R. Rao, Soontorn Oraintara
2004 B conf
GLOBECOM
Yoshikazu Yokotani, Soontorn Oraintara, Ralf Geiger, Gerald Schuller, K. R. Rao
2001 J jnl
IEEE Signal Process. Lett.
Vladimir Britanak, K. R. Rao
2001 J jnl
IEEE Signal Process. Lett.
Vladimir Britanak, K. R. Rao
2001 J jnl
J. Electronic Imaging
Seong-Whan Kim, Shan Suthaharan, Heung-Kyu Lee, K. R. Rao
2000 J jnl
J. Vis. Commun. Image Represent.
Krit Panusopone, K. R. Rao
1997 Misc conf
ICASSP
Krit Panusopone, K. R. Rao
1997 conf
ICIP (3)
Young Huh, Krit Panusopone, K. R. Rao
1997 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Ricardo L. de Queiroz, C. K. Choi, Young Huh, K. R. Rao
1996 Misc conf
ICASSP
Krit Panusopone, K. R. Rao
1996 J jnl
IEEE Trans. Signal Process.
Ricardo L. de Queiroz, Truong Q. Nguyen, K. R. Rao
1996 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Young Huh, Krit Panusopone, K. R. Rao
1996 J jnl
IEEE Trans. Signal Process.
Ricardo L. de Queiroz, K. R. Rao
1995 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Young Huh, J. J. Hwang, K. R. Rao
1995 J jnl
IEEE Trans. Image Process.
Ricardo L. de Queiroz, K. R. Rao
1995 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Suresh Verkatraman, Jae Y. Nam, K. R. Rao
1995 J jnl
J. Vis. Commun. Image Represent.
Ricardo L. de Queiroz, K. R. Rao
1995 J jnl
IEEE Trans. Signal Process.
Ricardo L. de Queiroz, K. R. Rao
1995 Misc conf
ICASSP
Ricardo L. de Queiroz, K. R. Rao
1995 B conf
ICIP
Ricardo L. de Queiroz, K. R. Rao
1994 conf
ICIP (3)
Young Huh, J. J. Hwang, K. R. Rao
1994 C conf
ISCAS
Ricardo L. de Queiroz, Truong Q. Nguyen, K. R. Rao
1994 conf
ICIP (1)
Ricardo L. de Queiroz, K. R. Rao
1994 J jnl
J. Vis. Commun. Image Represent.
Chansik Hwang, Jae-kyoon Kim, K. R. Rao
1993 conf
ICASSP (3)
Ricardo L. de Queiroz, K. R. Rao
1993 C conf
ISCAS
Ricardo L. de Queiroz, K. R. Rao
1993 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Wei Gong, K. R. Rao, Michael T. Manry
1993 J jnl
IEEE Trans. Signal Process.
Ricardo L. de Queiroz, K. R. Rao
1992 J jnl
J. Electronic Imaging
Ricardo L. de Queiroz, K. R. Rao
1992 J jnl
J. Electronic Imaging
Wei Gong, K. R. Rao, Michael T. Manry
1991 J jnl
IEEE Trans. Signal Process.
Anshu J. Gupta, K. R. Rao
1991 J jnl
J. Vis. Commun. Image Represent.
Jae Y. Nam, K. R. Rao
1991 J jnl
IEEE Trans. Circuits Syst. Video Technol.
Jae Y. Nam, K. R. Rao
1990 J jnl
IEEE Trans. Acoust. Speech Signal Process.
Anshu J. Gupta, K. R. Rao
1990 Misc conf
ICASSP
Bowonkoon Chitprasert, K. R. Rao
1990 J jnl
IEEE Trans. Commun.
Bowonkoon Chitprasert, K. R. Rao
1989 Misc conf
ICASSP
Anshu J. Gupta, K. R. Rao
1988 J jnl
IEEE Trans. Acoust. Speech Signal Process.
O. Rath, K. R. Rao, K. Yeung
1985 J jnl
IEEE Trans. Commun.
S. Kappagantula, K. R. Rao
1985 J jnl
IEEE Trans. Commun.
R. Srinivasan, K. R. Rao
1984 Misc conf
ICASSP
R. Srinivasan, K. R. Rao
1984 J jnl
IEEE Trans. Syst. Man Cybern.
R. Srinivasan, K. R. Rao
1984 J jnl
IEEE J. Sel. Areas Commun.
C. E. Li, K. R. Rao
1984 conf
ICC (1)
R. Srinivasan, K. R. Rao
1982 J jnl
IEEE Trans. Commun.
Avudh Ploysongsang, K. R. Rao
1982 J jnl
IEEE Trans. Computers
Farhad Kamangar, K. R. Rao
1981 J jnl
IEEE Trans. Commun.
Farhad Kamangar, K. R. Rao
1980 J jnl
IEEE Trans. Commun.
Venkat Devarajan, K. R. Rao
1977 J jnl
IEEE Trans. Syst. Man Cybern.
K. R. Rao, M. A. Narasimhan, W. J. Gorzinski
1976 J jnl
IEEE Trans. Syst. Man Cybern.
Thomas E. Milson, K. R. Rao
1975 J jnl
IEEE Trans. Computers
K. R. Rao, M. A. Narasimhan, Krishnaiah Revuluri
1974 J jnl
IEEE Trans. Computers
Krishnaiah Revuluri, K. R. Rao, M. A. Narasimhan, Nasir Ahmed
1974 J jnl
IEEE Trans. Computers
Nasir Ahmed, T. Raj Natarajan, K. R. Rao
1972 J jnl
Inf. Control.
Nasir Ahmed, R. B. Schultz, K. R. Rao
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 "";
        }
    }
}