首页 > 技术文章 > ollvm 使用——“Cannot open /dev/random”错误的解决方法

suanguade 2019-05-23 17:30 原文

找到

\obfuscator-llvm-4.0\lib\Transforms\Obfuscation\CryptoUtils.cpp

这个文件,

新增两个头文件

#include <windows.h>
#include <wincrypt.h>

 

bool CryptoUtils::prng_seed() 

找到这个函数

把整个函数体全部注释掉后,新增代码

 1     bool bRet = false;
 2     do 
 3     {
 4         HCRYPTPROV Rnd;
 5         LPCSTR UserName = "MyKeyContainer";
 6         if (CryptAcquireContextA(&Rnd, UserName, NULL, PROV_RSA_FULL, 0))
 7         {
 8 
 9         }
10         else
11         {
12             break;
13         }
14 
15         if (CryptGenRandom(Rnd, 16, (BYTE*)key))
16         {
17             bRet = true;
18         }
19         else
20         {
21             break;
22         }
23 
24         if (CryptReleaseContext(Rnd, 0))
25         {
26 
27         }
28         else
29         {
30             break;
31         }
32     } while (false);
33     if (bRet)
34     {
35         memset(ctr, 0, 16);
36 
37         // Once the seed is there, we compute the
38         // AES128 key-schedule
39         aes_compute_ks(ks, key);
40 
41         seeded = true;
42     }
43     else
44     {
45         errs() << "Windows CryptGenRandom Error \n";
46     }

保证能取到随机数即可,

重新编译,会重新编90+个工程,

然后就不会再出错误了

 

推荐阅读