Toggle navigation
Toggle navigation
This project
Loading...
Sign in
공재호
/
JJS_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이한솔
2020-06-13 21:51:46 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cd3f69db4ca66a8e7890ddf27ac02b3ca707fb84
cd3f69db
1 parent
904925d0
전처리 Pass 추가
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
src/llvm/lib/Transforms/Obfuscation/CMakeLists.txt
src/llvm/lib/Transforms/Obfuscation/PreProcess.cpp
src/llvm/lib/Transforms/Obfuscation/CMakeLists.txt
View file @
cd3f69d
add_llvm_library
(
LLVMObfuscation MODULE
ReturnObfuscation.cpp
PreProcess.cpp
DEPENDS
intrinsics_gen
...
...
src/llvm/lib/Transforms/Obfuscation/PreProcess.cpp
0 → 100644
View file @
cd3f69d
#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/Instructions.h"
#include "llvm/Support/Alignment.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/IR/CFG.h"
#include <fstream>
#include <iostream>
using
namespace
llvm
;
namespace
{
struct
PreProcess
:
public
FunctionPass
{
static
char
ID
;
PreProcess
()
:
FunctionPass
(
ID
)
{
}
bool
runOnFunction
(
Function
&
F
)
override
{
Module
*
mod
=
F
.
getParent
();
std
::
vector
<
Instruction
*>
instructions
;
std
::
vector
<
BasicBlock
*>
RetBlocks
;
bool
inserted
=
false
;
std
::
ofstream
functionFile
(
"functions.txt"
,
std
::
ios_base
::
app
);
if
(
functionFile
.
is_open
())
{
functionFile
<<
F
.
getName
().
str
()
<<
"
\n
"
;
functionFile
.
close
();
}
for
(
auto
&
BB
:
F
)
{
for
(
auto
&
I
:
BB
)
{
if
(
I
.
getOpcode
()
==
Instruction
::
Ret
)
{
instructions
.
push_back
(
&
I
);
}
}
}
for
(
auto
&
I
:
instructions
)
{
BasicBlock
*
BB
=
I
->
getParent
();
// One Instruction Basic Block has only one ret instructions
if
(
!
BB
->
size
()
<
2
)
{
BasicBlock
*
retblock
=
BB
->
splitBasicBlock
(
I
->
getIterator
(),
"obfuscatedreturn"
);
}
else
{
BB
->
setName
(
"obfuscatedreturn"
);
}
}
return
true
;
}
};
// end of struct Hello
}
// end of anonymous namespace
char
PreProcess
::
ID
=
0
;
static
RegisterPass
<
PreProcess
>
X
(
"preprocess"
,
"Hello World Pass"
,
false
/* Only looks at CFG */
,
false
/* Analysis Pass */
);
\ No newline at end of file
Please
register
or
login
to post a comment