A小久 2024-04-15 21:56 采纳率: 40%
浏览 4
已结题

解决ida分析反分析

这段代码没有对ida分析起到作用,是否还有其他强大的代码可用?#include <idc.idc>

void main()
{
auto start_ea = SegStart(SegByName(".text"));
auto end_ea = SegEnd(SegByName(".text"));

for (auto ea = start_ea; ea < end_ea; ea++)
{
    if (GetMnem(ea) == "B" || GetMnem(ea) == "BL")
    {
        // B and BL instructions represent unconditional and conditional branches in ARM64
        auto insn = GetInsn(ea, 0);
        if (insn.size > 0)
        {
            auto opnd_type = GetOpType(insn, 0);
            if (opnd_type == o_imm)
            {
                // The immediate operand holds the branch offset
                auto offset = GetOperandValue(insn, 0);

                // Sign-extend the 26-bit immediate to 64 bits
                if (offset & (1 << 25))
                    offset |= ~((1 << 26) - 1); // Set all higher bits to 1

                auto target_ea = ea + 4 + offset;

                // Check if the target address falls within the code segment
                if (SegStart(SegByName(".text")) <= target_ea && target_ea < SegEnd(SegByName(".text")))
                {
                    // Make sure the target is marked as code
                    if (IsCode(GetFlags(target_ea)))
                    {
                        MakeCode(target_ea);
                        MakeFunction(target_ea);

                        // Create a branch to the target
                        if (GetMnem(ea) == "BL")
                            MakeCode(ea, ICODE_CALL); // For BL (branch with link)
                        else
                            MakeCode(ea, ICODE_JUMP); // For B (unconditional branch)

                        AddCodeXref(ea, target_ea, fl_CN); // Create a code cross-reference
                    }
                }
            }
        }
    }
}

}

img

  • 写回答

4条回答 默认 最新

  • 关注

    上午好☀️☀️☀️️
    本答案参考ChatGPT-3.5

    针对这段代码无法防反分析的问题,以下是一些可能的解决方案:

    1. 使用加密算法对关键代码进行加密,运行时进行解密操作。这种方式可以有效地防止反汇编和静态分析,但是运行时会增加一定的开销和复杂度。

    2. 修改代码结构,使其难以理解。可以通过添加无用代码、分离代码块、使用条件语句等方式进行修改,使得代码难以被理解和分析。

    3. 使用反调试技术。可以使用一些技术手段,如反调试、反反汇编等,使得调试器无法正常运行,从而使得反汇编和分析变得困难。

    4. 使用虚拟化技术。可以使用一些虚拟化技术,如加壳、虚拟机等,来隐藏代码本身的逻辑和结构,使得分析变得更加困难。

    以下是修改后的代码,使用了简单的加密算法对关键代码进行了加密。

    #include <idc.idc>
    void main() {
        auto start_ea = SegStart(SegByName(".text"));
        auto end_ea = SegEnd(SegByName(".text"));
        for (auto ea = start_ea; ea < end_ea; ea++)
        {
            if (GetMnem(ea) == decrypt("Cxjjfm") || GetMnem(ea) == decrypt("CM"))
            {
                auto insn = GetInsn(ea, 0);
                if (insn.size > 0)
                {
                    auto opnd_type = GetOpType(insn, 0);
                    if (opnd_type == o_imm)
                    {
                        auto offset = GetOperandValue(insn, 0);
                        if (offset & (1 << 25))
                            offset |= ~((1 << 26) - 1);
    
                        auto target_ea = ea + 4 + offset;
    
                        if (SegStart(SegByName(".text")) <= target_ea && target_ea < SegEnd(SegByName(".text")))
                        {
                            if (IsCode(GetFlags(target_ea)))
                            {
                                MakeCode(target_ea);
                                MakeFunction(target_ea);
    
                                if (GetMnem(ea) == decrypt("CM"))
                                    MakeCode(ea, ICODE_CALL);
                                else
                                    MakeCode(ea, ICODE_JUMP);
    
                                AddCodeXref(ea, target_ea, fl_CN);
                            }
                        }
                    }
                }
            }
        }
    }
    
    string decrypt(string s) {
        string res = "";
        for (int i = 0; i < s.length(); i++) {
            res += (char)(s[i] - 1);
        }
        return res;
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

问题事件

  • 系统已结题 4月24日
  • 已采纳回答 4月16日
  • 创建了问题 4月15日

悬赏问题

  • ¥15 35114 SVAC视频验签的问题
  • ¥15 impedancepy
  • ¥15 在虚拟机环境下完成以下,要求截图!
  • ¥15 求往届大挑得奖作品(ppt…)
  • ¥15 如何在vue.config.js中读取到public文件夹下window.APP_CONFIG.API_BASE_URL的值
  • ¥50 浦育平台scratch图形化编程
  • ¥20 求这个的原理图 只要原理图
  • ¥15 vue2项目中,如何配置环境,可以在打完包之后修改请求的服务器地址
  • ¥20 微信的店铺小程序如何修改背景图
  • ¥15 UE5.1局部变量对蓝图不可见