社区应用 最新帖子 精华区 社区服务 会员列表 统计排行
  • 691阅读
  • 4回复

[分享]一个MBR硬盘锁分析实录

楼层直达
z3960 
级别: FLY版主
发帖
786303
飞翔币
211574
威望
215717
飞扬币
2615136
信誉值
8

[font=-apple-system, BlinkMacSystemFont, &quot]基本信息[font=-apple-system, BlinkMacSystemFont, &quot]  [font=-apple-system, BlinkMacSystemFont, &quot]报告名称:一个MBR硬盘锁分析实录                                                   [font=-apple-system, BlinkMacSystemFont, &quot]  [font=-apple-system, BlinkMacSystemFont, &quot]作者: Virus4                                                         [font=-apple-system, BlinkMacSystemFont, &quot]  [font=-apple-system, BlinkMacSystemFont, &quot]报告更新日期:2021-3-15                                            [font=-apple-system, BlinkMacSystemFont, &quot]                                          [font=-apple-system, BlinkMacSystemFont, &quot]  [font=-apple-system, BlinkMacSystemFont, &quot]样本类型: 系统破坏,MBR硬盘锁                                                  [font=-apple-system, BlinkMacSystemFont, &quot]  [font=-apple-system, BlinkMacSystemFont, &quot]样本文件信息:[font=-apple-system, BlinkMacSystemFont, &quot]                        [font=-apple-system, BlinkMacSystemFont, &quot](是的,壳都没有)[font=-apple-system, BlinkMacSystemFont, &quot]  [font=-apple-system, BlinkMacSystemFont, &quot]可能受到威胁的系统:    XP                        [font=-apple-system, BlinkMacSystemFont, &quot]简介           最近一直很闲,把逆向抓回来重新看看,正好在论坛上看到有人求分析的帖子,就决定分析看看。由于里面有大量反调试以及垃圾代码,分析起来很困难,本篇重点主要在如何调试以及追踪到算法代码,对程序行为的分析偏少。一个MBR硬盘锁,非常猖狂 - 『病毒样本区』 - 吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn     被感染系统症状       [font=-apple-system, BlinkMacSystemFont, &quot] [font=-apple-system, BlinkMacSystemFont, &quot]程序运行后,单击启动按钮,系统本身会受到破坏,MBR扇区被更改。重启后效果如上图,如果用OD调试会被检测到,会有“惩戒行为”,直接将MBR破坏掉。[font=-apple-system, BlinkMacSystemFont, &quot]但在我这里测试,即便是正常修改MBR扇区,输入了正确的密码也是进不去系统的...所以找到密码的意义也不是很大了。[font=-apple-system, BlinkMacSystemFont, &quot]详细分析[font=-apple-system, BlinkMacSystemFont, &quot]首先在虚拟机里执行程序,报内存错误,初步猜测是可能有反虚拟机的功能(也有可能就是程序不行,不过在网上的沙箱中是有成功运行的实例的)[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]我们用OD跑一下程序,确定到主函数[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]我不知道有更好的方法没有..我的方法就是纯试错,主函数F7进去以后,把每个Call都F8过去一遍最终找到可以用跳转跳过的报错call[font=-apple-system, BlinkMacSystemFont, &quot]试错流程为[font=-apple-system, BlinkMacSystemFont, &quot]004E7454 ->004F39E->004FF9A5->00432697->00422A5E->004082FF[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]最终定位到这里,我们可以看到00408322有一个跳转没有实现,这里我们强制使这个跳转实现,改为jmp即可使程序正常运行。[font=-apple-system, BlinkMacSystemFont, &quot]我自己调试的过程中,是没有第一次就找对call的,我甚至F7进了下面的call,然后进入了一个套路很深的循环,再也没出来过,最后也确定不下来哪个call最终报了错(有一个call 有时候报错,有时候不报错的情况)[font=-apple-system, BlinkMacSystemFont, &quot]就只好往回找补,最后找到了这个跳转可以修改正常使用。[font=-apple-system, BlinkMacSystemFont, &quot]程序终于可以正常跑起来了,在字符串搜索中找到一个有用的字符串下段,结果发现被"惩戒“”了[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]虚拟机直接蓝屏,启动扇区应该是直接被破坏了 [font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]这时我的思路是 肯定有个函数是反调试的,我们更改一下这个反调试的结果,让关键call失效即可。[font=-apple-system, BlinkMacSystemFont, &quot]用字符串定位,可以发现字符串上方都有一个跳转,都修改为jmp[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]这个地方有点奇怪,在我最初逆向的时候,修改完程序是会报错的,但是写这篇文章做复现的时候却没问题了...[font=-apple-system, BlinkMacSystemFont, &quot]总之这里有另外一个思路..是我当初遇到报错后想到的。[font=-apple-system, BlinkMacSystemFont, &quot]我用ARK工具检查了一下程序的进程,发现有多个线程,大胆猜测它是多线程执行多个函数的,也许可以找到这个反调试的函数,通过修改线程函数地址,来跳过反调试函数。[font=-apple-system, BlinkMacSystemFont, &quot]bp CreateThread 之后,通过栈进行追溯,可以找到 CreateThread的调用地址[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]通过对函数地址进行观察追踪,这面发现有如下几个函数[font=-apple-system, BlinkMacSystemFont, &quot]0040C0BD 这个函数如果没记错的话是 修改系统注册表以及结束杀软进程的(taskkill能过什么杀软的自保呢...)[font=-apple-system, BlinkMacSystemFont, &quot]0041942A 这个函数就是反调试的函数了[font=-apple-system, BlinkMacSystemFont, &quot]0041A247[font=-apple-system, BlinkMacSystemFont, &quot]0042153C 这两个函数我大致看了下没跟进去,有很多垃圾代码,一层call接着另一层,大佬们有兴趣的可以看看...[font=-apple-system, BlinkMacSystemFont, &quot]我们可以看到CreateThread的第三个参数为ThreadFunction,即为线程执行的函数,我们可以把执行反调试的函数替换为0040C0BD,让他再执行一遍去。[font=-apple-system, BlinkMacSystemFont, &quot]这样我们就跳过了对OD进行反调试的检测。[font=-apple-system, BlinkMacSystemFont, &quot]走到这里我们距离算法的位置已经不远了,我们通过对特定字符串进行追踪(如rn F5:, 这些字符串是在重启后的界面中可以看到的,可以判断是对MBR进行写入)[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]从这个位置向上翻,就可以看到算法了。[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]可以看到有大量的浮点运算。[font=-apple-system, BlinkMacSystemFont, &quot]算法如下:[font=-apple-system, BlinkMacSystemFont, &quot][font=-apple-system, BlinkMacSystemFont, &quot]我们把数字扔进Excel里,方便进行说明[font=-apple-system, BlinkMacSystemFont, &quot]通过计算得出12组结果,然后依次相加(减)。[font=-apple-system, BlinkMacSystemFont, &quot]前五组结果规律相同[font=-apple-system, BlinkMacSystemFont, &quot]以第一行为例[font=-apple-system, BlinkMacSystemFont, &quot]第一组结果为 (B1+C1)*A1,第二组为 D1*E1[font=-apple-system, BlinkMacSystemFont, &quot]到第五行为止。共10组结果。[font=-apple-system, BlinkMacSystemFont, &quot]第十一组为D1*A3,第十二组为E2单独一个数[font=-apple-system, BlinkMacSystemFont, &quot]密码为R1+R2...+R11-R12.[font=-apple-system, BlinkMacSystemFont, &quot]可得最终结果
11741626793
[font=-apple-system, BlinkMacSystemFont, &quot]但是其实结果已经没有多大意义了...系统已经被破坏的启动不了了。即便输入密码也没多大用...[font=-apple-system, BlinkMacSystemFont, &quot]到这里就分析的差不多了,分析的时候觉得斗智斗勇,写帖子下来真觉得索然无味啊... (有种这好像也没多难怎么花了那么久的感觉...)[font=-apple-system, BlinkMacSystemFont, &quot]预防及修复措施[font=-apple-system, BlinkMacSystemFont, &quot]此类病毒其实大多数杀软都能进行查杀,多以外挂进行伪装,诱导用户关闭杀软。本样本双后缀名,诱导隐藏后缀名的用户双击而已。[font=-apple-system, BlinkMacSystemFont, &quot]Vista以上系统更是需要UAC权限才能修改MBR。[font=-apple-system, BlinkMacSystemFont, &quot]如果不幸中了该类病毒,可以通过Winhex等工具查看磁盘头来获取密码。也可以通过 DiskGenius等工具对MBR进行修复。[font=-apple-system, BlinkMacSystemFont, &quot]总结[font=-apple-system, BlinkMacSystemFont, &quot]随着系统安全权限的不断完善。病毒的发展似乎从技术型越发成长为盈利型。[font=-apple-system, BlinkMacSystemFont, &quot]目前各式锁机勒索病毒无论在移动还是PC终端上都十分流行。不过一般都有挽救的余地。[font=-apple-system, BlinkMacSystemFont, &quot]作者是小白一枚,帖子技术含量不高,还请各位大佬见教..中间还有很多疑惑和不解的问题,比如大量垃圾代码如何有效跳过,同时又不忽略一些重要的信息。[font=-apple-system, BlinkMacSystemFont, &quot]调试过程中我还遇到过F7进call 就报错,但是在call的位置下断点就可以成功进去的情况。也有像jmp改完就报错,但是第二次又不复现的情况...(我一开始以为是反调试手段,但是感觉好像是程序写的不够稳定?)
我不喜欢说话却每天说最多的话,我不喜欢笑却总笑个不停,身边的每个人都说我的生活好快乐,于是我也就认为自己真的快乐。可是为什么我会在一大群朋友中突然地就沉默,为什么在人群中看到个相似的背影就难过,看见秋天树木疯狂地掉叶子我就忘记了说话,看见天色渐晚路上暖黄色的灯火就忘记了自己原来的方向。
srwam 
级别: 超级版主
发帖
710062
飞翔币
170
威望
25627
飞扬币
3206927
信誉值
0

只看该作者 1 发表于: 2021-03-16
来看看
srwam 
级别: 超级版主
发帖
710062
飞翔币
170
威望
25627
飞扬币
3206927
信誉值
0

只看该作者 2 发表于: 2021-03-16
了解一下
级别: 超级版主
发帖
883609
飞翔币
253127
威望
224883
飞扬币
2704060
信誉值
0

只看该作者 3 发表于: 2021-03-17
来看一下
级别: 超级版主
发帖
883609
飞翔币
253127
威望
224883
飞扬币
2704060
信誉值
0

只看该作者 4 发表于: 2021-03-17
不错,了解了