吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 9954|回复: 22
收起左侧

[原创] 钢琴英雄Synthesia逆向思路分享

  [复制链接]
zyjsuper 发表于 2020-1-18 21:40
本帖最后由 zyjsuper 于 2020-2-29 23:07 编辑

本文旨在分享思路,行文简单,大神飘过。

0x00:运行软件

如图:打开软件后,需要解锁才可以自由使用全部功能。此处联想到关键字“lock”,“unlock”,“unlocked”。

1.png


0x01:动态跟踪
使用x64dbg加载目标程序Synthesia.exe,点击运行按钮,一直来到Synthesia.exe程序模块,如图所示。
2.png

0x02:搜索关键字
在反汇编窗口,右击依次选择"搜索"-->"当前模块"-->"字符串",自动跳转到"引用"选项卡,在下方的"搜索"处填写"unlock".
如图所示:找到"Congratulations!  Synthesia is unlocked!"。


3.png


0x03:分析汇编代码
在上一步中直接双击字符串,会来到反汇编中字符串出现的位置,按"CTRL+K"跳转到上一级调用,按"CTRL+L"跳转到下一级调用。
如图所示:

4.png

汇编代码如下:
[Asm] 纯文本查看 复制代码
0080952A | E8 D1FB0600              | call synthesia.879100                   |
0080952F | 8B5D 08                  | mov ebx,dword ptr ss:[ebp+8]            |
[url=tel:00809532]00809532[/url] | 8BF0                     | mov esi,eax                             | esi:EntryPoint
[url=tel:00809534]00809534[/url] | 8B3D 90F3B500            | mov edi,dword ptr ds:[<&GetDlgItem>]    | edi:EntryPoint
0080953A | B8 E4F0B600              | mov eax,synthesia.B6F0E4                | B6F0E4:L"Synthesia is NOT unlocked"
0080953F | 83FE 01                  | cmp esi,1                               | esi:EntryPoint
[url=tel:00809542]00809542[/url] | 8975 FC                  | mov dword ptr ss:[ebp-4],esi            | esi:EntryPoint
[url=tel:00809545]00809545[/url] | B9 90F0B600              | mov ecx,synthesia.B6F090                | ecx:EntryPoint, B6F090:L"Congratulations!  Synthesia is unlocked!"



关注cmp esi,1这一段,向上撸代码,esi的值来自mov esi,eax即eax,而eax的值来自synthesia.879100这个函数的返回值,由此我们可以得出结论,
如果当synthesia.879100的返回值为1时,程序就会出现"Congratulations!  Synthesia is unlocked!"的提示。


0x04:修改汇编代码
按上一步的分析结果,将synthesia.879100这个函数的返回值修改为1,就会解锁程序。
在call synthesia.879100这个位置按回车键即可来到这个函数的主体,如图所示:


5.png

设计到返回值部分的汇编代码如下:
[Asm] 纯文本查看 复制代码
0087914B | 803D 3A7DC400 00         | cmp byte ptr ds:[C47D3A],0              |
[url=tel:00879152]00879152[/url] | 74 0D                    | je synthesia.879161                     |
[url=tel:00879154]00879154[/url] | 837E 08 01               | cmp dword ptr ds:[esi+8],1              |
[url=tel:00879158]00879158[/url] | 75 07                    | jne synthesia.879161                    |
0087915A | B8 [url=tel:01000000]01000000[/url]              | mov eax,1                               |
0087915F | 5E                       | pop esi                                 | esi:EntryPoint
[url=tel:00879160]00879160[/url] | C3                       | ret                                     |
[url=tel:00879161]00879161[/url] | 33C0                     | xor eax,eax                             |
[url=tel:00879163]00879163[/url] | 5E                       | pop esi                                 | esi:EntryPoint
[url=tel:00879164]00879164[/url] | C3                       | ret                                     |



这段函数主体有两个返回值,mov eax,1和xor eax,eax 两个,即1或者0.
我修改返回值的方法是将xor eax,eax修改为mov eax,1,即两个返回值都为1.
如图所示:

6.png


0x05:编写patch脚本
python的十六进制patch方法最为直接暴力,脚本如下:
[Python] 纯文本查看 复制代码
#!/usr/bin/env python3
# coding=GBK
# Created at 2019/11/9 19:52

from __future__ import print_function
import ctypes, sys
import os,time

binpath= r"C:\Program Files (x86)\Synthesia"
filename = "Synthesia.exe"
backup_path = r"c:\backup"

if(os.path.isdir(backup_path)):
    print("Backup path already exsit!")
else:
    os.mkdir(backup_path)


def backfiles():
    os.system("copy " + filename + " " + backup_path)
    print("File has been backuped to " + backup_path)


#patch文件的偏移位置。
def patch_exe():
    with open (backup_path+"\\" + filename,"rb") as fr:
        data = fr.read()
        data = data.replace(b'\x64\xA1\x2C\x00\x00\x00\x56\x8B\xF1', b'\xB8\x01\x00\x00\x00\xC3\x56\x8B\xF1')
        with open(binpath + '\\' + filename, "wb") as fw:
            fw.write(data)
            print(filename + " has been patached successfully!")

#获取administrator权限
def is_admin():
    try:
        return ctypes.windll.shell32.IsUserAnAdmin()
    except:
        return False

if is_admin():
    os.chdir(binpath)
    try:
        print("-------------First Step--------------\n")
        backfiles()
        time.sleep(3)
    except:
        print("Error occurred in backup procedure!")
    try:
        print("-------------Second Step--------------\n")
        patch_exe()
        time.sleep(3)
    except:
        print("Error occurred in patch procedure!\n")
else:
    if sys.version_info[0] == 3:
        ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, __file__, None, 1)   #python3使用的函数及参数
    else:
        ctypes.windll.shell32.ShellExecuteW(None, u"runas", unicode(sys.executable), unicode(__file__), None, 1)   #python2使用的函数及参数





免费评分

参与人数 12威望 +1 吾爱币 +17 热心值 +11 收起 理由
cxyelu + 1 + 1 自行尝试一番,正好需要
Rapides + 1 + 1 谢谢@Thanks!
有名字的过客 + 1 + 1 已经处理,感谢您对吾爱破解论坛的支持!
yanqin + 1 + 1 我很赞同!
resu + 1 + 1 用心讨论,共获提升!
sunnylds7 + 1 + 1 热心回复!
Hmily + 1 + 7 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
-LX + 1 + 1 谢谢@Thanks!
jamesmeng + 1 + 1 用心讨论,共获提升!
ma4907758 + 1 谢谢@Thanks!
vethenc + 1 + 1 谢谢@Thanks!
FleTime + 1 用心讨论,共获提升!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

cxyelu 发表于 2020-12-29 11:10
再简单点,把

0087914B | 803D 3A7DC400 00         | cmp byte ptr ds:[C47D3A],0              |
00879152 | 74 0D                    | je synthesia.879161                     |
00879154 | 837E 08 01               | cmp dword ptr ds:[esi+8],1              |
00879158 | 75 07                    | jne synthesia.879161                    |
0087915A | B8 01000000              | mov eax,1                               |
0087915F | 5E                       | pop esi                                 | esi:EntryPoint
00879160 | C3                       | ret                                     |
00879161 | 33C0                     | xor eax,eax                             |
00879163 | 5E                       | pop esi                                 | esi:EntryPoint
00879164 | C3                       | ret                                     |

里面的je synthesia.879161和 jne synthesia.879161都nop掉,解锁的时候输入任意字符就行了
yean 发表于 2021-4-19 04:19
终于完成了一次操作。原来只完成4个步骤是不行的,到处看看,终于把第5步弄出来了。
第5步不知道是不是x64dbg这个软件版本不一样的原因,右键补丁后,选择修补文件,这时我把文件名多加了一个数字,这样方便再次修改。
再次打开那个被我修改过的exe运行,结果没有弹出那个试用的窗口了。
泥泥的泥泥 发表于 2020-1-19 00:00
qqvcd010 发表于 2020-1-19 00:34
感谢分享
ironmaneva 发表于 2020-1-19 09:15
钢琴英雄 是要连专用 钢琴键盘?
 楼主| zyjsuper 发表于 2020-1-19 09:28
ironmaneva 发表于 2020-1-19 09:15
钢琴英雄 是要连专用 钢琴键盘?

我也没有专业的设备,应该可以连midi的吧。
hmlhao 发表于 2020-1-19 09:33
感谢楼主分享。。。。。。。。。
wapjltb 发表于 2020-1-19 21:18
感恩分享思路
aassdd2003 发表于 2020-1-20 13:25
感谢分享
yanqin 发表于 2020-3-1 07:45
感恩分享思路!
resu 发表于 2020-4-13 10:48
依葫芦画了个瓢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-25 23:04

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表