Giter VIP home page Giter VIP logo

Comments (6)

KomiMoe avatar KomiMoe commented on August 28, 2024

忘了。好像是有兼容性问题?

from arkari.

pomelohan avatar pomelohan commented on August 28, 2024

大佬,goron中有IPObfuscationContext.cpp,但是你移植过来的就删掉了,这个具体是干什么的,请大佬解答解答

IPObfuscationContext 主要是用来生成 MySecret 的信息的,具体可以参考原版 Control Flow Flattening 和 IndirectCall 这两个 Pass 中的代码,这个移植作者采用的方案是直接不使用生成的 SecretArg,而是使用 0 代替;而在原版中的逻辑是只有当 SecretArg 生成失败了才会使用 0 代替,因此这样直接导致了 goron 特色消失

from arkari.

BRYNHILDRINTHEDARKNESS avatar BRYNHILDRINTHEDARKNESS commented on August 28, 2024

大佬,goron中有IPObfuscationContext.cpp,但是你移植过来的就删掉了,这个具体是干什么的,请大佬解答解答

IPObfuscationContext 主要是用来生成 MySecret 的信息的,具体可以参考原版 Control Flow Flattening 和 IndirectCall 这两个 Pass 中的代码,这个移植作者采用的方案是直接不使用生成的 SecretArg,而是使用 0 代替;而在原版中的逻辑是只有当 SecretArg 生成失败了才会使用 0 代替,因此这样直接导致了 goron 特色消失

MySecret具体是什么东西呢?如果使用了MySecret,goron会有什么不同

from arkari.

pomelohan avatar pomelohan commented on August 28, 2024

举个栗子,下面代码取自 goron IndirectCall

    const IPObfuscationContext::IPOInfo *SecretInfo = nullptr;
    if (IPO) {
      SecretInfo = IPO->getIPOInfo(&Fn);
    }

    Value *MySecret;
    if (SecretInfo) {
      MySecret = SecretInfo->SecretLI;
    } else {
      MySecret = ConstantInt::get(Type::getInt32Ty(Ctx), 0, true);
    }
      Constant *X;
      if (SecretInfo) {
        X = ConstantExpr::getSub(SecretInfo->SecretCI, EncKey);
      } else {
        X = ConstantExpr::getSub(Zero, EncKey);
      }

      Value *Secret = IRB.CreateSub(X, MySecret);
      Value *DestAddr = IRB.CreateGEP(EncDestAddr, Secret);

      Value *FnPtr = IRB.CreateBitCast(DestAddr, FTy->getPointerTo());

以上就是原版的 goron 逻辑,追踪到 IPObfuscationContext 中可以看到下面的代码

  // Load Secret Token from the secret argument
  IntegerType *I32Ty = Type::getInt32Ty(NF->getContext());
  IRBuilder<> IRB(&NF->getEntryBlock().front());
  Value *Ptr = IRB.CreateBitCast(NF->arg_begin(), I32Ty->getPointerTo());
  LoadInst *MySecret = IRB.CreateLoad(Ptr);

你可以把 MySecret 当成一个密钥;至于有什么不同,当然是增加攻击者攻击的难度,下面引用 @61bcdefg 大佬的一句话解释:

会给被混淆的函数加个参数,当作解密的key

这个版本中直接丢掉了 IPObfuscationContext,四舍五入就是 key = 0

from arkari.

BRYNHILDRINTHEDARKNESS avatar BRYNHILDRINTHEDARKNESS commented on August 28, 2024

举个栗子,下面代码取自 goron IndirectCall

    const IPObfuscationContext::IPOInfo *SecretInfo = nullptr;
    if (IPO) {
      SecretInfo = IPO->getIPOInfo(&Fn);
    }

    Value *MySecret;
    if (SecretInfo) {
      MySecret = SecretInfo->SecretLI;
    } else {
      MySecret = ConstantInt::get(Type::getInt32Ty(Ctx), 0, true);
    }
      Constant *X;
      if (SecretInfo) {
        X = ConstantExpr::getSub(SecretInfo->SecretCI, EncKey);
      } else {
        X = ConstantExpr::getSub(Zero, EncKey);
      }

      Value *Secret = IRB.CreateSub(X, MySecret);
      Value *DestAddr = IRB.CreateGEP(EncDestAddr, Secret);

      Value *FnPtr = IRB.CreateBitCast(DestAddr, FTy->getPointerTo());

以上就是原版的 goron 逻辑,追踪到 IPObfuscationContext 中可以看到下面的代码

  // Load Secret Token from the secret argument
  IntegerType *I32Ty = Type::getInt32Ty(NF->getContext());
  IRBuilder<> IRB(&NF->getEntryBlock().front());
  Value *Ptr = IRB.CreateBitCast(NF->arg_begin(), I32Ty->getPointerTo());
  LoadInst *MySecret = IRB.CreateLoad(Ptr);

你可以把 MySecret 当成一个密钥;至于有什么不同,当然是增加攻击者攻击的难度,下面引用 @61bcdefg 大佬的一句话解释:

会给被混淆的函数加个参数,当作解密的key

这个版本中直接丢掉了 IPObfuscationContext,四舍五入就是 key = 0

原来如此,大佬能否将IPObfuscationContext也适配进llvm17呢

from arkari.

pomelohan avatar pomelohan commented on August 28, 2024

举个栗子,下面代码取自 goron IndirectCall

    const IPObfuscationContext::IPOInfo *SecretInfo = nullptr;
    if (IPO) {
      SecretInfo = IPO->getIPOInfo(&Fn);
    }

    Value *MySecret;
    if (SecretInfo) {
      MySecret = SecretInfo->SecretLI;
    } else {
      MySecret = ConstantInt::get(Type::getInt32Ty(Ctx), 0, true);
    }
      Constant *X;
      if (SecretInfo) {
        X = ConstantExpr::getSub(SecretInfo->SecretCI, EncKey);
      } else {
        X = ConstantExpr::getSub(Zero, EncKey);
      }

      Value *Secret = IRB.CreateSub(X, MySecret);
      Value *DestAddr = IRB.CreateGEP(EncDestAddr, Secret);

      Value *FnPtr = IRB.CreateBitCast(DestAddr, FTy->getPointerTo());

以上就是原版的 goron 逻辑,追踪到 IPObfuscationContext 中可以看到下面的代码

  // Load Secret Token from the secret argument
  IntegerType *I32Ty = Type::getInt32Ty(NF->getContext());
  IRBuilder<> IRB(&NF->getEntryBlock().front());
  Value *Ptr = IRB.CreateBitCast(NF->arg_begin(), I32Ty->getPointerTo());
  LoadInst *MySecret = IRB.CreateLoad(Ptr);

你可以把 MySecret 当成一个密钥;至于有什么不同,当然是增加攻击者攻击的难度,下面引用 @61bcdefg 大佬的一句话解释:

会给被混淆的函数加个参数,当作解密的key

这个版本中直接丢掉了 IPObfuscationContext,四舍五入就是 key = 0

原来如此,大佬能否将IPObfuscationContext也适配进llvm17呢

可以询问项目的原作者或者自己移植,我暂时对这个不感兴趣 & 没有时间

from arkari.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.