1.前言
分析该加密文件时,发现此次病毒保留了LIVE1.0版本的加密后文件的命名方式,同时使用了LIVE2.0版本的文件加密方式,故分析此次木马的版本介于LIVE1.0与LIVE2.0之间,命名此木马为LIVE1.5版本。
2. 背景
近期收到某建筑公司消息,称公司服务器文件被加密导致系统无法正常,团队工程师通过远程连接进行分析后提取到了勒索病毒的源头。
3.恶意文件基础信息
文件名 |
admin.exe |
大小 |
318.67 KiB |
操作系统 |
Windows(Server 2003) |
架构 |
AMD64 |
模式 |
64 位 |
类型 |
控制台 |
字节序 |
LE |
MD5 |
0c029e5a29312f5af38087d77a8b881 |
SHA256 |
f2d0f5ae4053be74c6a06237f11a022adc4aa0dbda5cd126ec5793ab3ddae718 |
3.1 配置信息
在执行文件的末尾明文存储了文件运行的相关信息
{'MinDate': <int64 1699574400>, 'MaxDate': <int64 1702944000>, 'AppendedExtension': <'LIVE'>, 'NoteFilename': <'FILE RECOVERY_ID_436BF0.txt'>, 'DropNoteInSpecificDirectories': <true>, 'DirectoriesToDropNoteIn': <@as []>, 'IncludeFiles': <false>, 'FileSet': <['FILE RECOVERY_ID_436BF0.txt']>, 'IncludeDirectories': <false>, 'DirectorySet': <['C:\\Program Files', 'C:\\Program Files (x86)', 'C:\\ProgramData', 'C:\\Windows', 'C:\\msys64', 'C:\\Users\\All Users']>, 'IncludeExtensions': <false>, 'NoneSet': <['exe', 'dll', 'ini', 'tmp', 'url', 'lnk', 'ps1', 'nls', 'shs', 'themepack', 'bin', 'msp', 'wpx', 'bat', 'sys', 'spl', 'scr', 'icl', 'rom', 'msc', 'ico', 'LIVE']>, 'FastSet': <@as []>, 'IntermittentSet': <@as []>, 'FullSet': <['txt', 'log']>, 'EncryptHiddenFiles': <true>, 'EncryptHiddenDirectories': <false>, 'BufferSize': <4096>, 'Percent': <0.02>, 'Segmentation': <512.0>}
MinDate
与MaxDate
是Unix时间戳,翻译为GMT+8时间如下,程序在此段时间以外不会运行
2023-11-10 08:00:00 - 2023-12-19 08:00:00
3.2 勒索信
勒索信明文存在文件末尾
具体内容如下
Hello
Your file has been encrypted and cannot be used
To return to the file under the working conditions, you need to decrypt the tools
Decolling all data according to the instructions
Don't try to change or restore the file yourself, which will destroy them
If necessary, you can decrypt a test file for free. Free test decryption is only available for files less than 3MB in size.
To restore files, you need a decryption tool. Please contact us by email.
Please add the file name of this document to the email and send it to me. 【FILE RECOVERY_ID xxxxxx】
I will tell you the amount you need to pay. After the payment is completed, we will make the decryption tool and send it to you.
Customer service mailbox:
locked@onionmail.org
locked@onionmail.org
You can also contact us through intermediary agencies (such as data recovery companies)
If you refuse to pay, you will be attacked constantly. Your privacy -sensitive data will also be announced on Internet.
!! We are a team that pays attention to credibility, so you can pay safely and restore data.
LIVE TEAMI
3.3 加密文件特征
在LIVE1.0版本中,会在加密文件的尾部存储progarm_id,但是在LIVE1.5版本中,此功能被阉割,加密之后文件大小不会发生改变,仅文件名添加后缀.LIVE
。
加密的本质是异或单字节加密,当原文件的后缀名是txt
或者log
时,文件执行全加密,其余文件执行快速加密,即仅对文件的前0x1000个Byte进行加密。
加密后
解密后
密钥
加密的密钥也明文存在文件的末尾,运行时读取此密钥进行加密,密钥的长度为8Byte。
4.逆向分析
4.1函数program_main
函数定义了命令行参数
4.2 函数encryption_Initialize
此函数为加密的初始函数,初始化了key与初始iv的值。
__int64 __fastcall encryption_Initialize(__int64 a1)
{
__int64 result; // rax
unsigned int v2; // eax
unsigned int v3; // ebx
const char *v4; // rax
const char **v5; // [rsp+40h] [rbp-40h] BYREF
const char **v6; // [rsp+48h] [rbp-38h]
_BYTE *v7; // [rsp+50h] [rbp-30h]
__int64 v8; // [rsp+C0h] [rbp+40h]
FILE *v9; // [rsp+C8h] [rbp+48h]
FILE *v10; // [rsp+D0h] [rbp+50h]
int v11; // [rsp+DCh] [rbp+5Ch]
void *v12; // [rsp+E0h] [rbp+60h]
int v13; // [rsp+ECh] [rbp+6Ch]
void *Buffer; // [rsp+F0h] [rbp+70h]
FILE *Stream; // [rsp+F8h] [rbp+78h]
v5 = 0i64;
if ( !a1 )
return g_return_if_fail_warning(0i64, "encryption_Initialize", "path != NULL");
Buffer = 0i64;
v13 = 0;
v12 = 0i64;
v11 = 0;
v10 = (FILE *)g_fopen(a1, "rb");
Stream = v10;
v9 = v10;
if ( v10 )
{
v8 = g_malloc0_n(8i64, 1i64);
g_free(encryption_key);
encryption_key = v8;
encryption_key_length1 = 8;
encryption_key_size_ = 8;
fseek(Stream, -4, 2);
Buffer = (void *)g_malloc0_n(4i64, 1i64);
fread(Buffer, 1ui64, 4ui64, Stream);
v13 = program_ToInt32(Buffer, 4i64);
fseek(Stream, -8 - v13, 2);
v12 = (void *)g_malloc0_n(4i64, 1i64);
fread(v12, 1ui64, 4ui64, Stream);
v11 = program_ToInt32(v12, 4i64);
fseek(Stream, -8 - v13 - v11 - 8, 2);
fread((void *)encryption_key, 1ui64, encryption_key_length1, Stream);
fflush(Stream);
g_free(v12);
g_free(Buffer);
fclose(Stream);
v7 = (_BYTE *)g_malloc0_n(8i64, 1i64);
*v7 = 70;
v7[1] = 69;
v7[2] = -61;
v7[3] = -9;
v7[4] = -65;
v7[5] = -109;
v7[6] = -18;
v7[7] = -96;
g_free(encryption_iv);
encryption_iv = (__int64)v7;
encryption_iv_length1 = 8;
result = 8i64;
encryption_iv_size_ = 8;
}
return result;
}
4.3 函数progarm_Iterate
它遍历一个目录及其子目录,加密符合特定条件的文件。该函数接受目录路径、配置信息和等作为参数,并返回空值。该函数的目的是遍历目录树并加密符合特定条件的文件,如文件名、扩展名等。函数还检查文件是否为目录,如果符合条件,则对其进行加密。如果文件是目录,则函数会递归调用自身以遍历子目录。
4.4 函数program_Filter
这段代码是一个基于文件扩展名和名称进行筛选的函数。它接受文件名、文件扩展名以及要排除的扩展名和名称的列表。该函数的目的是根据文件的扩展名和名称确定是否应包含或排除给定的文件。函数首先提取文件的扩展名并将其转换为小写。然后,它检查文件的扩展名是否在要包含或排除的扩展名列表中。如果文件的扩展名在要排除的扩展名列表中,函数返回0,表示不加密此文件。除此之外,函数返回1,表示应该加密该文件。
__int64 __fastcall program_Filter(__int64 a1, int a2, __int64 a3, int a4, int a5, __int64 a6, int a7)
{
int index_of; // eax
__int64 v9; // [rsp+38h] [rbp-38h]
__int64 v10; // [rsp+48h] [rbp-28h]
BOOL v11; // [rsp+5Ch] [rbp-14h]
int v12; // [rsp+68h] [rbp-8h]
unsigned int v13; // [rsp+6Ch] [rbp-4h]
if ( a1 )
{
index_of = string_last_index_of(a1, ".", 0i64);
v10 = string_substring(a1, (unsigned int)(index_of + 1), 0xFFFFFFFFi64);
v9 = g_utf8_strdown(v10, -1i64);
g_free(v10);
v11 = a5 == vala_string_array_contains(a6, a7, v9);
if ( a2 )
{
if ( v11 )
v12 = 1;
else
v12 = vala_string_array_contains(a3, a4, a1);
v13 = v12;
}
else
{
v13 = v11 & ((unsigned int)vala_string_array_contains(a3, a4, a1) == 0);
}
g_free(v9);
return v13;
}
else
{
g_return_if_fail_warning(0i64, "program_Filter", "basename != NULL");
return 0i64;
}
}
4.5 函数_lambda4
此函数对文件进行分类,根据配置文件判断某一文件是否需要加密,用什么方式加密。
'FullSet': <['txt', 'log']>
'IntermittentSet': <@as []>
在NoneSet
集合中的后缀将不会被加密,在FullSet
集合中的后缀将使用全加密。(encryption_Full
),其余文件使用快速加密(encryption_Fast
)
LIVE1.5版本相比LIVE1.0版本多了一种加密方式encryption_Intermittent
,但是在配置文件中,没有文件后缀调用此加密方式。
当encryption_Full
与encryption_Intermittent
都不满足的使用会调用encryption_Fast
,大致逻辑如下:
if ( !(unsigned int)vala_string_array_contains(FastSet, v17[0], v32) )
{
IntermittentSet = settings_get_IntermittentSet(a2, &v15);
if ( (unsigned int)vala_string_array_contains(IntermittentSet, v15, v27) )
encryption_Intermittent(a1, &v16, v8, &v16);
else
encryption_Full(a1, (__int64)&v16);
return result;
}
encryption_Fast(a1, BufferSize, (__int64)&v16);
4.6 函数encryption_Full
此函数仅打开文件,将文件内容交给encryption_OFB_Encrypt
处理,最后写入新文件。
由于缓冲区大小为4096,函数将以4096为一块读取文件加密后输出到文件再次读取下一块加密。
while ( 1 )
{
v30 = Stream;
v8 = ftell(Stream);
if ( v47 <= v8 )
break;
v29 = Stream;
Buffer = v46;
v27 = v38;
v45 = fread(v46, 1ui64, v38, Stream);
v26 = v46;
v25 = v38;
if ( v46 )
v9 = (void *)vala_array_dup13(v26, (int)v45);
else
v9 = 0i64;
v24 = v9;
v23 = v45;
g_free(v14);
v14 = v24;
v13 = v23;
v36 = v23;
v22 = encryption_key;
v21 = encryption_key_length1;
encryption_OFB_Encrypt(&v14, &v13, encryption_key, encryption_key_length1, &v12, (unsigned int *)&v11);
v36 = v13;
v31 = v11;
v20 = Stream;
fseek(Stream, -(int)v45, 1);
v19 = Stream;
v18 = v14;
v17 = v13;
fwrite(v14, 1ui64, v13, Stream);
}
4.7 函数encryption_OFB_Encrypt
此函数为加密的主要逻辑encryption_Full和encryption_Fast都会调用此函数进行文件加密。
__int64 __fastcall encryption_OFB_Encrypt(_QWORD *a1,int *a2,__int64 a3,unsigned int a4,_QWORD *a5,unsigned int *a6)
{
v6 = *a2;v7 = *a2 + 7;
if ( v6 < 0 ) v6 = v7;
v9 = v6 >> 3;v13 = 0;v12 = 1;
while ( 1 ){
if ( !v12 ) ++v13;
v12 = 0;
if ( v13 >= v9 ) break;
encryption_Xor(*a5, *a6, a3, a4);
v11 = 0;v10 = 1;
while ( 1 ){
if ( !v10 ) ++v11;
v10 = 0;
if ( v11 > 7 ) break;
*(_BYTE *)(*a1 + 8 * v13 + v11) ^= *(_BYTE *)(*a5 + v11);
}
}
return encryption_Xor(*a5, *a6, a3, a4);
}
4.8 函数encryption_Xor
此函数辅助encryption_OFB_Encrypt
对文件进行加密,大致逻辑如下:
void encryption_Xor( unsigned char *key, const int key_len, unsigned char *data )
{
for(int i = 0; i < 8; i++ ){
key[ i ] ^= data[ i ];
key[ i ] += 13;
}
}
4.9 函数encryption_Fast
encryption_Fast
与encryption_Full
的区别是,encryption_Fast
只会加密文件的前0x1000个Byte。