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

Commit

Permalink
[IndirectBranch]Filter out EntryBlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Naville committed Jan 18, 2018
1 parent 7b1b01d commit 4f9f244
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Transforms/Obfuscation/IndirectBranch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,11 @@ struct IndirectBranch : public FunctionPass {
unsigned long long i = 0;
for (auto F = M.begin(); F != M.end(); F++) {
for (auto BB = F->begin(); BB != F->end(); BB++) {
indexmap[&*BB] = i++;
BBs.push_back(BlockAddress::get(&*BB));
BasicBlock *BBPtr=&*BB;
if(BBPtr!=&(BBPtr->getParent()->getEntryBlock())){
indexmap[BBPtr] = i++;
BBs.push_back(BlockAddress::get(BBPtr));
}
}
}
ArrayType *AT =
Expand Down Expand Up @@ -82,7 +85,7 @@ struct IndirectBranch : public FunctionPass {
}
GlobalVariable *LoadFrom = NULL;

if (BI->isConditional()) {
if (BI->isConditional() || indexmap.find(BI->getSuccessor(0))==indexmap.end()) {
// Create a new GV
Constant *BlockAddressArray =
ConstantArray::get(AT, ArrayRef<Constant *>(BlockAddresses));
Expand Down

1 comment on commit 4f9f244

@Naville
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saying, the GVs created enable hackers to hijack our program easier. We need to move them to __TEXT so os-level protection will bliss us (Hopefully)

Please sign in to comment.