问答
发起
提问
文章
攻防
活动
Toggle navigation
首页
(current)
问答
商城
实战攻防技术
漏洞分析与复现
NEW
活动
摸鱼办
搜索
登录
注册
使用vmpdump对未完全保护的vmp样本进行处理——以Night Sky为例
技巧性文章,便于处理一些非强加密vmp的样本,便于后续继续分析
查壳可以看到是vmp的壳,根据网上其他的文章可以确定是3.x版本貌似是3.5。根据其他文章介绍虽然加密,但是貌似只对IAT进行了vm,所以可以用该工具模拟出IAT。  使用沙箱定位到代码段调用的API,这里选择MoveFileEx。因为当勒索软件涉及到对文件操作时证明被vmp保护的代码段已经被解密加载到.txt节中,此时是比较好的解密点。 [Automated Malware Analysis Report for update.exe - Generated by Joe Sandbox](https://www.joesandbox.com/analysis/548777/0/html)  运行到OEP后选择MoveFileExW API  来到API函数入口设置硬件端点,硬件断点是为了防止软件断点会影响壳的执行流程  执行后中断在我们设置的硬件端点下。  返回到用户态代码,可以看到call xxxxx int3。这是被vmp3.x保护的导入函数虚拟化特征,该函数会进行一系列运算,最后解析出API并调用  根据其他报告提示该样本的OPE特征为微软VS特征。接下来随意用VS编译一个helloword的64位程序并用IDA观察入口特征  首先找到export选项卡,来到OEP处  在VS编译器中会生成一段安全cookie的hash,该hash值不变可以作为特征串查找OEP附近的代码  回到中断的内存中,点击内存布局中查看  可以看到已经解密代码到.text节中,而不是存在下面的附加节中。  我们只需要在.text节中搜索cookie特征值即可,邮件内存窗口中转到  右键-->特征搜索  搜索后只有一处特征值,该值就是VS编译器OEP附近的设置安全cookie处。如果有多个该技巧可能并不适用  对比后为VS编译器设置安全Cookie的函数  删除其他断点,在安全cookie函数入口处设置硬件断点  重新运行程序中断在函数序言中,此时与真正的OEP很接近了  查看调用栈跟随到调用地址  可以看到来到一块位置代码内容中  内存布局转到,可以发现已经不在.text中,证明OEP已经被vmp保护了。所以我们不能直接dump出干净的OEP,可能需要后续手动修复  使用vmpdump对解密后的程序进行dump `VMPDump.exe 8852 "" -disable-reloc` 注意,dump进程名不能过长,否则会失败  接下来将dump程序拖入IDA,可以看到此时入口点仍为VMP壳节代码中,需要我们自己手动搜索特征修复  搜索cookie的hash值  选择text代码节,这是我们dump出来的解密代码部分  将函数名和函数类型改为初始化cookie  同理,我们搜索\_\_scrt\_common\_main\_seh函数的特征,由于该函数没有常量,我们只能取函数部分字节码做特征搜索  同理需要继续向下定位到main函数  在重命名完成后,需要我们手动修改入口点的OEP。对比正常的VS编译程序修改入口点代码  修改后如下  接下来需要计算跳转的相对偏移,call指令的下一条指令地址-安全cookie初始化函数的地址。又因为vmp壳的代码节在.text的下方,所以相对跳转的值应该取负值,这样就可以从.2fU1节向上跳转到.text节中  计算出该值还需要加1字节  修改相对跳转,  回到入口点可以发现修改成功  同理可以修改main\_seh   最后patch程序即可  重新调试即可  脱壳后的main函数 
发表于 2025-01-07 10:00:02
阅读 ( 734 )
分类:
二进制
0 推荐
收藏
0 条评论
请先
登录
后评论
马喽打金服
3 篇文章
×
发送私信
请先
登录
后发送私信
×
举报此文章
垃圾广告信息:
广告、推广、测试等内容
违规内容:
色情、暴力、血腥、敏感信息等内容
不友善内容:
人身攻击、挑衅辱骂、恶意行为
其他原因:
请补充说明
举报原因:
×
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!