Ubuntu16.04下llvm obfuscator的使用

xiaoxiao2021-07-04  235

安装llvm obfuscator 在创建的build目录下执行: sudo make install 新建一个快速排序的例子quicksort.c: #define _CRT_SECURE_NO_WARNNINGS #include<stdio.h> #include<math.h> #include<stdlib.h> #include<string.h> #include<stdarg.h> #include<time.h> /*有的头文件是其它函数需要的*/ int compare(const void *, const void *); void showarry(int a[], int n); int main() { int a[N] = { 1, 5, 65, 34, 6, 7, 76, 45, 43, 45 }; showarry(a,N); printf("\n"); int b[N]; int * pi; memcpy(b, a, N * sizeof(int)); qsort(b, N, sizeof(int), compare); showarry(b, N); printf("\n"); pi = (int *)malloc(N * sizeof(int)); memcpy(pi, b, N * sizeof(int)); showarry(pi, N); free(pi); getchar(); return 0; } int compare(const void * p1, const void * p2) { const int * a1 = (int *)p1; const int * a2 = (int *)p2; if (*a1 < *a2) return 1; else if (*a1 == *a2) return 0; else return -1; } void showarry(int a[], int n) { int index; for (index = 1; index < n; index++) { printf("%d\t", a[index]); if (index % 4 == 0) printf("\n"); } } 使用混淆手段来编译这个C文件:

首先使用编译时候添加选项开启字符串加密:

clang -mllvm -sobf quicksort.c -o q1

开启控制流扁平化:

clang -mllvm -fla quicksort.c -o q2

开启指令替换:

clang -mllvm -sub quicksort.c -o q3

指定随机数生成器种子:

clang -mllvm -bcf quicksort.c -o q4

通过编译并对比执行结果,可以看到四种方法所生成的可执行体的大小不同:

参考文献 https://blog.csdn.net/c_million/article/details/52694392 https://github.com/AllocAndInit/ollvm5.0.1
转载请注明原文地址: https://www.6miu.com/read-4821278.html

最新回复(0)