From 8c03aa7bf5fb3bbf321bc8af63f39e4befeaf1c0 Mon Sep 17 00:00:00 2001
From: hope <397386153@qq.com>
Date: Sun, 17 Mar 2024 14:33:19 +0800
Subject: [PATCH] Site updated: 2024-03-17 14:33:18
---
Fuzzing101-Xpdf/index.html | 4 +-
archives/2024/03/index.html | 2 +-
archives/2024/index.html | 2 +-
archives/index.html | 2 +-
"babku\345\210\206\346\236\220/index.html" | 4 +-
categories/index.html | 93 ++--
.../index.html" | 8 +-
index.html | 32 +-
local-search.xml | 14 +-
sitemap.xml | 7 +
.../index.html" | 401 ++++++++++++++++++
tags/index.html | 2 +-
wannacry/index.html | 43 +-
13 files changed, 553 insertions(+), 61 deletions(-)
create mode 100644 "tags/WannaCry\345\210\206\346\236\220/index.html"
diff --git a/Fuzzing101-Xpdf/index.html b/Fuzzing101-Xpdf/index.html
index 7a8dca5..e4684df 100644
--- a/Fuzzing101-Xpdf/index.html
+++ b/Fuzzing101-Xpdf/index.html
@@ -512,9 +512,9 @@
+
-
+ WannaCry分析
上一篇
diff --git a/archives/2024/03/index.html b/archives/2024/03/index.html
index 6c81bc2..c27fa3e 100644
--- a/archives/2024/03/index.html
+++ b/archives/2024/03/index.html
@@ -254,7 +254,7 @@
-
+ WannaCry分析
diff --git a/archives/2024/index.html b/archives/2024/index.html
index cb71576..1a5e6b4 100644
--- a/archives/2024/index.html
+++ b/archives/2024/index.html
@@ -254,7 +254,7 @@
-
+ WannaCry分析
diff --git a/archives/index.html b/archives/index.html
index 9dde9c4..2140588 100644
--- a/archives/index.html
+++ b/archives/index.html
@@ -254,7 +254,7 @@
-
+ WannaCry分析
diff --git "a/babku\345\210\206\346\236\220/index.html" "b/babku\345\210\206\346\236\220/index.html"
index d3a376e..d1ded35 100644
--- "a/babku\345\210\206\346\236\220/index.html"
+++ "b/babku\345\210\206\346\236\220/index.html"
@@ -430,8 +430,8 @@ 结论
-
-
+
+ WannaCry分析
下一篇
diff --git a/categories/index.html b/categories/index.html
index 7f0bcc6..ea07ecc 100644
--- a/categories/index.html
+++ b/categories/index.html
@@ -844,6 +844,57 @@
+
+
+
+
+
-
-
-
-
diff --git a/index.html b/index.html
index 64fbf0a..e6402d3 100644
--- a/index.html
+++ b/index.html
@@ -365,14 +365,14 @@
diff --git a/local-search.xml b/local-search.xml
index f9fd5c3..1011374 100644
--- a/local-search.xml
+++ b/local-search.xml
@@ -54,13 +54,25 @@
-
+ WannaCry分析
/wannacry/
样本情况
- 样本名称:WannaCry
- 大小:3,514,368 bytes
- MD5:84C82835A5D21BBCF75A61706D8AB549
查壳
PEiD
使用PEiD观察到WannaCry使用VC++编写

Exeinfo
使用Exeinfo观察到WannaCry未加壳

基础分析
基础静态分析
查看字符串
首先检索字符串,发现WannaCry采用了Windows的加解密函数,并且字符串中出现了RSA与AES的字样。可能用到这些加密算法,并且还有通过cmd
执行的命令。

使用PEiD识别加密算法
PEiD自带了许多插件,其中Krypto ANALyzer是一种加密货币分析工具

使用KANAL分析出下面几种算法
- ADLER32:校验和而算法,用于数据完整性检验
- CRC32:是一种循环冗余校验码,用于数据完整性校验和错误检测
- CryptDecrypt:是一组Windows API函数,用于加密和解密数据。可以在加密的数据块上执行解密操作,并将结果存储在相同的缓冲区中。
- CryptEncrypt:是一组Windows API函数,用于加密和解密数据。可以在未加密的数据块上执行加密操作,并将结果存储在相同的缓冲区中。
- RIJNDAEL:是一种块密码算法
- ZIP2与ZLIB:是压缩算法

查看导入表
可以看到wannacry
没有输出表的信息,只有输入表的信息

输入表中可以观察到引用了
KERNEL32.dll
:是一个Windows操作系统中非常重要的系统动态链接库文件,它包含了大量的系统核心函数,文件读写以及进程控制等函数USER32.dll
:是Windows操作系统中的一个动态链接库文件,包含了许多用户界面相关的函数。ADVAPI32.dll
:是Windows操作系统中的一个动态链接库文件,包含了许多安全和系统管理相关的函数。例如控制注册表等函数MSVCRT.dll
:是Microsoft Visual C++运行时库中的一个动态链接库文件,包含了许多与C和C++语言相关的函数。

KERNEL32.dll
发现大量的文件操作函数

资源读写函数

USER32.dll
只有一个宽字节写的函数

ADVAPI32.dll
含有注册表操作的函数,说明Wannacry会修改注册表

MSVCRT.dll
一些C/C++相关函数

使用Resource Hacker查看资源
Wannacry中存在三个资源,分别为XIA、Version Info以及Manifest

XIA
XIA中存在一个PK头,即压缩包资源

压缩包里有许多文件以及可执行文件,可能是用于感染的

基础动态分析
Process Monitor
使用Process Monitor分析进程树,发现wannacry会生成创建五个进程,四个自定义进程,以及一个cmd.exe用于执行系统命令

Reshot
使用Reshot观察注册表被修改的情况,添加了新的键,并且键名为WanaCrypt0r

值为”wd”=”C:\Users\pwn\Desktop\勒索软件样本(13个)附解压密码\勒索软件样本(1)\Wannacry”

文件监控
使用火绒剑进行文件监控,创建了脚本文件,应该是配合上述的cmd.exe执行相应的操作

释放了许多可执行文件

深入分析
WannaCry
WannaCry用于做勒索的前期准备,不是具体的勒索行为,改程序的各函数功能入下图。

TaskStart.dll
TaskStart.dll宏观操作如下图,其中加密行为在sub_100057c0函数

sub_100057c0
接下来就详细分析具体的勒索行为
首先初使用CryptAcquireContextA函数始化加密的上下文环境

使用CryptImportKey函数导入攻击者的密钥,该密钥为公钥

使用CryptGenKey导入密钥句柄,并且规定加密的方式为RSA

使用CryptExportKey函数,在本机导出公钥

使用CryptExportKey函数在本机导出私钥,并且攻击者使用自己的公钥,将本地生成的私钥进行加密

这里总的来说,就是攻击者会在受害者机器上利用API生成公私钥对,用于后续加密文件。但是为了防止用户自己将文件解密,因此攻击者会使用自己手上的公钥,将在本地生成的密钥给加密,这样只有利用攻击者手上的私钥才能进行解密。如下图所示

程序会利用SHGetFolderPathW函数获取桌面的路径,因此该程序会优先加密桌面的文件

利用FindNextFileW函数遍历桌面的文件

程序会对文件后缀进行匹配,遇到.exe和.dll文件会选择跳过不加密

将所有符合条件的文件都存放到内存中,完成后续的加密以及修改后缀名的行为

将每个文件的后缀名新增.WNCRY的后缀

Wannacry并不是在原始文件上进行修改的,而是会新建一个文件,将加密后的数据填充到里面,该文件的名称就是原有的名称加上.WNCRY

在加密之前会使用CryptGenRandom函数生成一个随机数

利用CryptEncrypt函数,使用刚刚在本地生成的公钥,将该随机数进行加密

利用上面生成的随机数进行AES加密,并且加密后立刻将生成的随机数清空

那么加密的操作就比较简单了,就是不断读取原始的文件数据,经过AES加密,加密的密钥是刚刚生成的随机数,然后将加密后的结果写入刚刚新建的文件中。

在完成加密后,WannaCry还会对原始文件进行加密,加密的操作与上述流程一致

在加密完桌面程序后,则是加密其他路径的文件,完成全磁盘的加密,所有加密操作都如上述一致,并且最后会把原始文件进行删除
总结
加密流程
首先攻击者会准备一个RSA的公钥,接着会在被攻击的主机上生成一对公钥与私钥,本地生成的私钥会被攻击者的公钥进行RSA加密,然后攻击者会生成一组随机值,接着读取原文件的数据,将随机值作为AES的密钥,将原始文件的数据进行AES加密,并将加密后的数据写入到*.wnry文件中。并且为了防止原始文件被获取,WannaCry会将原始文件也加密,接着将原始文件删除。
因此程序的加密流程是
- 读取原始文件的数据流
- 将数据流进行AES加密
- 将加密后的数据流写入到其他文件
- 并将原始文件删除
加密使用的API
用于读写文件
CreateFileW
WriteFile
ReadFile
用于加密文件
- CryptAcquireContextA
- CryptImportKey
- CryptGenKey
- CryptEncrypt
- CryptDestroyKey
- CryptGenRandom
]]>
+
+
+ 病毒分析
+
+
+
+
+
+
+ WannaCry分析
+
+
diff --git a/sitemap.xml b/sitemap.xml
index 958ec23..4a11f5f 100644
--- a/sitemap.xml
+++ b/sitemap.xml
@@ -599,6 +599,13 @@
0.2
+
+ https://h0pe-ay.github.io/tags/WannaCry%E5%88%86%E6%9E%90/
+ 2024-03-17
+ weekly
+ 0.2
+
+
diff --git "a/tags/WannaCry\345\210\206\346\236\220/index.html" "b/tags/WannaCry\345\210\206\346\236\220/index.html"
new file mode 100644
index 0000000..407c059
--- /dev/null
+++ "b/tags/WannaCry\345\210\206\346\236\220/index.html"
@@ -0,0 +1,401 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 标签 - WannaCry分析 - hope
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/tags/index.html b/tags/index.html
index 74348f7..ad5e0b1 100644
--- a/tags/index.html
+++ b/tags/index.html
@@ -236,7 +236,7 @@
diff --git a/wannacry/index.html b/wannacry/index.html
index e6b3754..1075336 100644
--- a/wannacry/index.html
+++ b/wannacry/index.html
@@ -17,12 +17,12 @@
-
+
-
+
-
+
@@ -65,12 +65,13 @@
+
- hope
+ WannaCry分析 - hope
@@ -253,7 +254,7 @@
-
+
@@ -333,7 +334,7 @@
-
+ WannaCry分析
@@ -476,6 +477,34 @@