首页
社区
课程
招聘
1
[原创] obfuscator-llvm-3.6.1 的 VS2017 win32 修正编译
发表于: 2018-10-11 17:58 7447

[原创] obfuscator-llvm-3.6.1 的 VS2017 win32 修正编译

2018-10-11 17:58
7447

import base64

base64.b64decode('aHR0cHM6Ly9wYXBlci5zZWVidWcub3JnLzE5Mi8=')

因考察 obf-llvm 对代码的展平化效果,想在win上编译obf-llvm。
根据官方简单的mkdir & cd & cmake & vs-compile 遭遇一些错误,需对源码做一些修正。
如下:

----------------
建立2017解决方案
----------------
根据官方说明用cmake通过源码建立2017解决方案
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Download and install CMake. Version 2.8 is the minimum required.
 
Open a shell. Your development tools must be reachable from this shell through the PATH environment variable.
 
Create a directory for containing the build. It is not supported to build LLVM on the source directory. cd to this directory:
 
$ mkdir mybuilddir
$ cd mybuilddir
Execute this command on the shell replacing path/to/llvm/source/root with the path to the root of your LLVM source tree:
 
$ cmake path/to/llvm/source/root
 
这里我们解压释放的源码目录为obf_llvm_361
mkdir mybuilddir
cd mybuilddir
cmake ..\obf_llvm_361

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Download and install CMake. Version 2.8 is the minimum required.
 
Open a shell. Your development tools must be reachable from this shell through the PATH environment variable.
 
Create a directory for containing the build. It is not supported to build LLVM on the source directory. cd to this directory:
 
$ mkdir mybuilddir
$ cd mybuilddir
Execute this command on the shell replacing path/to/llvm/source/root with the path to the root of your LLVM source tree:
 
$ cmake path/to/llvm/source/root
 
这里我们解压释放的源码目录为obf_llvm_361
mkdir mybuilddir
cd mybuilddir
cmake ..\obf_llvm_361


-----------------------------------------------------------------
%ROOTDIR%\obf_llvm_361\lib\Transforms\Obfuscation\CryptoUtils.cpp
-----------------------------------------------------------------
编译解决方案会,执行会 提示 /dev/random 无法读取,window平台理所当然会出错。
由于源码目的市初始化16字节的key,我们改为srand,rand来完成key的随机初始化。 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <time.h>
void tritium_init_rand_key(char * buf,unsigned int buflen) {
    unsigned int i;
    srand(time(NULL));
    for (i = 0; i < buflen; i++) {
        buf[i] = char(rand() & 0xFF);
    }
}
 
#define __tritium__
 
void CryptoUtils::prng_seed() {
#ifdef __tritium__
    LLVMContext &ctx = llvm::getGlobalContext();
    tritium_init_rand_key(key, 16);
    DEBUG_WITH_TYPE("cryptoutils", dbgs() << "cryptoutils seeded with time srand and rand\n");
    memset(ctr, 0, 16);
    // Once the seed is there, we compute the
    // AES128 key-schedule
    aes_compute_ks(ks, key);
    seeded = true;
#else
  //原函数体代码
#endif // __tritium__
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <time.h>
void tritium_init_rand_key(char * buf,unsigned int buflen) {
    unsigned int i;
    srand(time(NULL));
    for (i = 0; i < buflen; i++) {
        buf[i] = char(rand() & 0xFF);
    }
}
 
#define __tritium__
 
void CryptoUtils::prng_seed() {
#ifdef __tritium__
    LLVMContext &ctx = llvm::getGlobalContext();
    tritium_init_rand_key(key, 16);
    DEBUG_WITH_TYPE("cryptoutils", dbgs() << "cryptoutils seeded with time srand and rand\n");
    memset(ctr, 0, 16);
    // Once the seed is there, we compute the
    // AES128 key-schedule
    aes_compute_ks(ks, key);
    seeded = true;
#else
  //原函数体代码
#endif // __tritium__
}


------------------------------------------------------
%ROOTDIR%\obf_llvm_361\lib\Support\Windows\Program.inc
------------------------------------------------------
对于已经在命令行运行了vcvarsall.bat初始化编译环境后,link.exe找不到,这部分代码检测文件是否可执行,
去不去都没啥影响,这里在检测该错误的过程去掉了,这里也去掉(方便确定的确市找不到文件的问题)。
1
2
3
4
5
6
  /* mask by tritium
  if (!sys::fs::can_execute(Program)) {
    if (ErrMsg)
      *ErrMsg = "program not executable";
    return false;
  }*/

1
2
3
4
5
6
  /* mask by tritium
  if (!sys::fs::can_execute(Program)) {
    if (ErrMsg)
      *ErrMsg = "program not executable";
    return false;
  }*/


-----------------------------------------------------
%ROOTDIR%\obf_llvm_361\tools\clang\lib\Driver\Job.cpp
-----------------------------------------------------
这部分代码会导致输入的提示,都是\\,而不是单个\,这里我们直接清除两行代码

[培训]内核驱动高级班,冲击BAT一流互联网大厂工作,每周日13:00-18:00直播授课

收藏
免费 1
支持
分享
赞赏记录
参与人
雪币
留言
时间
PLEBFE
为你点赞~
2023-2-2 03:40
打赏 + 1.00雪花
打赏次数 1 雪花 + 1.00
收起 
赞赏  junkboy   +1.00 2018/10/11
最新回复 (5)
雪    币: 11716
活跃值: (133)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
2
很实用
2018-10-11 19:18
0
雪    币: 12
活跃值: (423)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
3
这个东西关键是 开了 100% 编译速度慢的xxxxxxx一样,开低了没啥用
2018-10-30 15:56
0
雪    币: 12862
活跃值: (9307)
能力值: ( LV9,RANK:280 )
在线值:
发帖
回帖
粉丝
4
MaMy 这个东西关键是 开了 100% 编译速度慢的xxxxxxx一样,开低了没啥用
不管开不开 肉眼识别都能看个大概,更何况有模拟器这种东西。。
2018-10-31 11:06
0
雪    币: 12
活跃值: (423)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
5
hzqst 不管开不开 肉眼识别都能看个大概,更何况有模拟器这种东西。。
hhh,确实没毛病,不好用
混淆的代码相似度太高,肉眼识别还是强
最后于 2018-10-31 13:58 被MaMy编辑 ,原因:
2018-10-31 13:57
0
雪    币: 20
能力值: ( LV1,RANK:0 )
在线值:
发帖
回帖
粉丝
6
想编译但是不会
2020-3-26 21:57
0
游客
登录 | 注册 方可回帖
返回

账号登录
验证码登录

忘记密码?
没有账号?立即免费注册