一個.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