一个.net写的木马样本,内嵌了两个资源,分别是:
- LAN_Core (.net dll程序,用于解密png中的assembly)
- ESgFXCQfRbAmmGdIaVSZ.png (用图片隐写技术嵌入了另一个.net程序)
主程序通过调用LAN_Core的f20方法,将自身资源png图片传入
这里的MyProperty 其实就是ESgFXCQfRbAmmGdIaVSZ.png的资源名
再来看看LAN_Core.f20函数做了什么?
1.获取参数传入的资源名称对应的Bitmap对象
2.将Bitmap对象作为参数传给了x3241243213213函数,这个函数从png图片中提取加密的数据,返回byte[]数组
3.将bytes数组传给f13函数,这个函数用来异或解密数组中的数据
现在想拿到解密出来的assembly数据,有两种方式:
方式一:自己新建一个c#项目,将png添加到资源,然后把LAN_CORE中的相关函数拷贝进来,按照f20函数的调用过程实现,如下demo所示
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Collections.Generic;
using System.Drawing;
using System.Reflection;
using System.Resources;
namespace WindowsFormsApplication1
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
byte[] rawAssembly = f13(x3241243213213(f15("ESgFXCQfRbAmmGdIaVSZ")));
Assembly assembly = AppDomain.CurrentDomain.Load(rawAssembly);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
// Token: 0x0600000B RID: 11 RVA: 0x00002A00 File Offset: 0x00000C00
public static Bitmap f15(string f16)
{
ResourceManager resourceManager = new ResourceManager("WindowsFormsApplication1.Properties.Resources", Assembly.GetEntryAssembly());
return (Bitmap)resourceManager.GetObject(f16);
}
private static byte[] f13(byte[] ghet32412424124)
{
checked
{
byte[] array = new byte[ghet32412424124.Length - 16 - 1 + 1];
Array.Copy(ghet32412424124, 16, array, 0, array.Length);
int num = array.Length - 1;
for (int i = 0; i <= num; i++)
{
byte[] array2 = array;
int num2 = i;
array2[num2] ^= ghet32412424124[i % 16];
}
return array;
}
}
// Token: 0x0600000D RID: 13 RVA: 0x00002A94 File Offset: 0x00000C94
private static byte[] x3241243213213(Bitmap t2341234124312)
{
List<byte> list = new List<byte>();
checked
{
int num = t2341234124312.Width - 1;
for (int i = 0; i <= num; i++)
{
int num2 = t2341234124312.Height - 1;
for (int j = 0; j <= num2; j++)
{
Color pixel = t2341234124312.GetPixel(i, j);
Color color = Color.FromArgb(0, 0, 0, 0);
bool flag = !pixel.Equals(color);
if (flag)
{
list.InsertRange(list.Count, new byte[]
{
pixel.R,
pixel.G,
pixel.B
});
}
}
}
return list.ToArray();
}
}
}
}
方法二: 直接在主exe程序中单步进Invoke函数
接着单步进入
继续步入
到Invoke实现函数里面,下面红框的地方下断 让程序跑起来
命中其中一个断点后,步入
继续步入
此时就到了LAN_CORE这个DLL的F20函数中了
经过解密函数,我们将解密后的rawAssembly内容,通过内存窗口查看
可以看到是个PE文件,默认是选中所有rawAssembly数据的,直接右键保存选中即可
样本md5:E10BC1816979208BB89BF14AE2281174