Skip to content

Commit

Permalink
change registration
Browse files Browse the repository at this point in the history
  • Loading branch information
SsageParuders committed Jul 30, 2022
1 parent 214d722 commit 323855c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Obfuscation/src/BogusControlFlow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ STATISTIC(NumAddedBasicBlocks, "e. Number of added basic blocks in this module")
STATISTIC(FinalNumBasicBlocks, "f. Final number of basic blocks in this module");

// Options for the pass
const int defaultObfRate = 100, defaultObfTime = 4;
const int defaultObfRate = 70, defaultObfTime = 2;

static cl::opt<int> ObfProbRate("bcf_prob", cl::desc("Choose the probability [%] each basic blocks will be obfuscated by the -bcf pass"), cl::value_desc("probability rate"), cl::init(defaultObfRate), cl::Optional);

Expand Down
2 changes: 1 addition & 1 deletion Obfuscation/src/FunctionWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
#include "FunctionWrapper.h"

static cl::opt<int> ProbRate("fw_prob",cl::desc("Choose the probability [%] For Each CallSite To Be Obfuscated By FunctionWrapper"),cl::value_desc("Probability Rate"), cl::init(100), cl::Optional);
static cl::opt<int> ProbRate("fw_prob",cl::desc("Choose the probability [%] For Each CallSite To Be Obfuscated By FunctionWrapper"),cl::value_desc("Probability Rate"), cl::init(50), cl::Optional);

static cl::opt<int> ObfTimes("fw_times",cl::desc("Choose how many time the FunctionWrapper pass loop on a CallSite"),cl::value_desc("Number of Times"), cl::init(3), cl::Optional);

Expand Down
22 changes: 14 additions & 8 deletions Obfuscation/src/PMRegistration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ llvm::PassPluginLibraryInfo getSsagePluginInfo() {
return {
LLVM_PLUGIN_API_VERSION, "Ssage", LLVM_VERSION_STRING,
[](PassBuilder &PB) {
outs() << "Version is " << 12 << "\n";
outs() << "Version is " << 14 << "\n";
// for opt
PB.registerPipelineParsingCallback(
[&](StringRef Name, FunctionPassManager &FPM,
Expand Down Expand Up @@ -60,16 +60,22 @@ llvm::PassPluginLibraryInfo getSsagePluginInfo() {
MPM.addPass(StringEncryptionPass(false)); // 先进行字符串加密 出现字符串加密基本块以后 再进行基本块分割和其他混淆 加大解密难度
MPM.addPass(FunctionWrapperPass(false)); // 函数包装
MPM.addPass(IndirectBranchPass(false)); // 间接指令
});
// 自动注册 需要添加 -O1 参数 然则可能部分pass不生效
PB.registerVectorizerStartEPCallback(
[](llvm::FunctionPassManager &FPM, // 函数Pass 作用于某个函数内
llvm::OptimizationLevel Level){
llvm::FunctionPassManager FPM;
FPM.addPass(SplitBasicBlockPass(false)); // 优先进行基本块分割
FPM.addPass(FlatteningPass(false)); // 对于控制流平坦化 不提前开启LowerSwitch 只在控制流平坦化内调用LegacyLowerSwitch
FPM.addPass(BogusControlFlowPass(false)); // 虚假控制流
FPM.addPass(FlatteningPass(false)); // 对于控制流平坦化 不提前开启LowerSwitch 只在控制流平坦化内调用LegacyLowerSwitch
MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
});
outs() << "";
// 这里的注册时机不好 启用以下方案 改用上面的方案
// 自动注册 需要添加 -O1 参数 然则可能部分pass不生效
// PB.registerVectorizerStartEPCallback(
// [](llvm::FunctionPassManager &FPM, // 函数Pass 作用于某个函数内
// llvm::OptimizationLevel Level){
// FPM.addPass(SplitBasicBlockPass(false)); // 优先进行基本块分割
// FPM.addPass(FlatteningPass(false)); // 对于控制流平坦化 不提前开启LowerSwitch 只在控制流平坦化内调用LegacyLowerSwitch
// FPM.addPass(BogusControlFlowPass(false)); // 虚假控制流
// });
outs() << "Made By SsageParuders\n";
}};
}

Expand Down

0 comments on commit 323855c

Please sign in to comment.