Skip to content
This repository has been archived by the owner on Sep 25, 2023. It is now read-only.

Commit

Permalink
Don't doInitialization Unless IDB is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Naville committed Feb 8, 2018
1 parent a88945c commit 0771b52
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
11 changes: 8 additions & 3 deletions lib/Transforms/Obfuscation/IndirectBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ namespace llvm {
struct IndirectBranch : public FunctionPass {
static char ID;
bool flag;
bool initialized;
map<BasicBlock *, unsigned long long> indexmap;
IndirectBranch() : FunctionPass(ID) { this->flag = true; }
IndirectBranch(bool flag) : FunctionPass(ID) { this->flag = flag; }
IndirectBranch() : FunctionPass(ID) { this->flag = true;this->initialized=false;}
IndirectBranch(bool flag) : FunctionPass(ID) { this->flag = flag;this->initialized=false;}
StringRef getPassName() const override { return StringRef("IndirectBranch"); }
bool doInitialization(Module &M) override {
bool initialize(Module &M){
vector<Constant *> BBs;
unsigned long long i = 0;
for (auto F = M.begin(); F != M.end(); F++) {
Expand All @@ -60,6 +61,10 @@ struct IndirectBranch : public FunctionPass {
if (!toObfuscate(flag, &Func, "indibr")) {
return false;
}
if(this->initialized==false){
initialize(*Func.getParent());
this->initialized=true;
}
errs() << "Running IndirectBranch On " << Func.getName() << "\n";
vector<BranchInst *> BIs;
for (inst_iterator I = inst_begin(Func); I != inst_end(Func); I++) {
Expand Down
17 changes: 9 additions & 8 deletions lib/Transforms/Obfuscation/Obfuscation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,20 +89,22 @@ struct Obfuscation : public ModulePass {
}
}
delete FP;
ModulePass *MP =
createAntiHookPass(EnableAllObfuscation || EnableAntiHooking);
MP->doInitialization(M);
MP->runOnModule(M);
delete MP;
if(EnableAllObfuscation || EnableAntiHooking){
ModulePass *MP =
createAntiHookPass(EnableAllObfuscation || EnableAntiHooking);
MP->doInitialization(M);
MP->runOnModule(M);
delete MP;
}
if(EnableAllObfuscation || EnableAntiDebugging){
// We don't want to link in the IR if the user doesn't want ADB
MP = createAntiDebuggingPass(EnableAllObfuscation || EnableAntiDebugging);
ModulePass *MP = createAntiDebuggingPass(EnableAllObfuscation || EnableAntiDebugging);
MP->doInitialization(M);
MP->runOnModule(M);
delete MP;
}
// Now Encrypt Strings
MP = createStringEncryptionPass(EnableAllObfuscation ||
ModulePass *MP = createStringEncryptionPass(EnableAllObfuscation ||
EnableStringEncryption);
MP->runOnModule(M);
delete MP;
Expand Down Expand Up @@ -140,7 +142,6 @@ struct Obfuscation : public ModulePass {
errs() << "Doing Post-Run Cleanup\n";
FunctionPass *P = createIndirectBranchPass(EnableAllObfuscation ||
EnableIndirectBranching);
P->doInitialization(M);
vector<Function *> funcs;
for (Module::iterator iter = M.begin(); iter != M.end(); iter++) {
funcs.push_back(&*iter);
Expand Down

0 comments on commit 0771b52

Please sign in to comment.