关键点:
- 利用COM组件创建计划任务;
- 图标为pdf的exe文件;
MD5:ef98ed09bedea8daef9d09ec62ffe9cc

将exe文件的图标修改了,修改为pdf文件,通过将exe文件伪装为pdf的个人简历用于钓鱼(使用Resource Hacker可以修改
ChaCha20 Encrypt
使用IDA分析,主函数中前面存在大量数据,猜测有加密

分析可以发现

很典型的chacha20
// Function to rotate a 32-bit integer left
static inline uint32_t rotate_left(uint32_t value, int count) {
return (value << count) | (value >> (32 - count));
}
// Quarter round function
static void quarter_round(uint32_t *a, uint32_t *b, uint32_t *c, uint32_t *d) {
*a += *b; *d = rotate_left(*d ^ *a, 16);
*c += *d; *b = rotate_left(*b ^ *c, 12);
*a += *b; *d = rotate_left(*d ^ *a, 8);
*c += *d; *b = rotate_left(*b ^ *c, 7);
}
// Function to generate a single ChaCha20 block
static void chacha20_block(uint32_t *state, uint8_t *output) {
uint32_t x[16];
memcpy(x, state, sizeof(x));
for (int i = 0; i < CHACHA20_ROUNDS; i += 2) {
quarter_round(&x[0], &x[4], &x[8], &x[12]);
quarter_round(&x[1], &x[5], &x[9], &x[13]);
quarter_round(&x[2], &x[6], &x[10], &x[14]);
quarter_round(&x[3], &x[7], &x[11], &x[15]);
}
for (int i = 0; i < 16; i++) {
((uint32_t *)output)[i] = x[i] + state[i];
}
}
// Function to initialize the ChaCha20 state
void chacha20_init_state(uint32_t *state, const uint8_t key[32], uint32_t counter, const uint8_t nonce[12]) {
static const uint32_t sigma[4] = {
0x61707865, 0x3320646e, 0x79622d32, 0x6b206574 // "expand 32-byte k"
};
memcpy(state, sigma, sizeof(sigma));
memcpy(state + 4, key, 32);
state[12] = counter; // Counter
memcpy(state + 13, nonce, 12);
}
// ChaCha20 encrypt/decrypt function
void ChaCha20XOR(uint8_t key[32], uint32_t counter, uint8_t nonce[12], uint8_t *in, uint8_t *out, int inlen) {
int i, j;
uint32_t s[16];
uint8_t block[CHACHA20_BLOCK_SIZE];
chacha20_init_state(s, key, counter, nonce);
for (i = 0; i < inlen; i += CHACHA20_BLOCK_SIZE) {
chacha20_block(s, block);
s[12]++;
for (j = 0; j < CHACHA20_BLOCK_SIZE && (i + j) < inlen; j++) {
out[i + j] = in[i + j] ^ block[j];
}
}
}
动态调试解密之后的数据

C:\\Windows\\System32\\cmd.exe /c C:\\Users\\陈帅-南京航天航空大学电子信息-个人简历.pdf


从 [https://panbaiclu.com/Guide/structure](https://panbaiclu.com/Guide/structure)处获取陈帅-南京航天航空大学电子信息-个人简历.pdf的数据,为了后续写入

创建新线程为了打开正确的pdf文件,然后1070行的判断使用的两个函数分别是检测反调试与反虚拟机的
反虚拟机和反调试

反调试检测的是进程中特定名称的进程是否存在,而这些进程名称已经用chacha20加密;后续的反虚拟机也是如此

检测的方式较为简单,遍历当前系统所有进程,然后一一对比
反调检测的进程包含:
| ollydbg.exe | x64dbg.exe | idag.exe | idaw.exe | idaq.exe |
|---|---|---|---|---|
| idaq64.exe | ImmunityDebugger.exe | Wireshark.exe | dumpcap.exe | HookExplorer.exe |
| ImportREC.exe | LordPE.exe | PEiD.exe | PETools.exe | procexp.exe |
| procexp64.exe | procmon.exe | windbg.exe | ResourceHacker.exe | ProcessHacker.exe |
| QzhddrUpdate.exe | QzhddrSrv.exe | QzhddrGuard.exe | iSafeClient.exe | nedr-agent.exe |
| antivirus.exe | nedr-etd.exe | procdump64.exe |

这部分为反虚拟机的,检测的方式与上面反调方式一样,多了一个检测HKEY_LOCAL_MACHINE\HARDWARE\DESCRIPTION\System\SystemBiosVersion注册表值的检测


其中检测注册表值用的是RegGetValueA函数
检测的进程包括:
| vmtoolsd.exe | vmware-tray.exe | vmware.exe | VGAuthService.exe | vm3dservice.exe |
|---|---|---|---|---|
| VirtualBox.exe | VBoxManage.exe | VirtualBoxVM.exe | vboxtray.exe |

检测了如果存在调试or虚拟环境的可能,会使用SetFileInformationByHandle函数将自身进行清理

持久化与组件下载

GetUserNameW函数获取当前系统用户名称,然后调用网络连接函数

初步进行网络通信,进行上线操作

使用InternetOpenUrlW函数打开链接获取远程资源
[https://panbaiclu.com/APIs/BaiduSearchAPI](https://panbaiclu.com/APIs/BaiduSearchAPI)
[https://panbaiclu.com/Metadata/indexes](https://panbaiclu.com/Metadata/indexes)

使用COM组件{0F87369F-0A4E-4CFC-0BD3-3E730E615472}创建计划任务,让"C:\Users\user\AppData\Local\Microsoft\Feeds\msfeedsync.exe"自启动

将从远程获取的资源写入msfeedsync.exe中,属于先创建计划任务,然后创建文件

这里的步骤也是进行了两次,同时还在"C:\Users\user\AppData\Roaming\SCSCloudService\scs64.exe"创建了一个,这个也创建了计划任务
但是由于URL失效导致后续部分丢失

等到所有操作都进行了之后,会和上面检测到调试与虚拟化一样,执行同样操作,将自身进行清除