该提不简单
Posted HacTF
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了该提不简单相关的知识,希望对你有一定的参考价值。
无语了,想给你们制造点悬念都没有了,哎!直接去做题吧
解题链接: http://ctf5.shiyanbar.com/crack/3/
关键字:
破解 逆向 调试
破解[crackme1.zip](http://ctf5.shiyanbar.com/crack/3/CrackMe1.zip)压缩包的程序
要求:请找出用户名为hello的注册码
下载并解压题目提供程序
尝试运行程序 :
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-03783b0ace622533.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-4b50051cb7b682d5.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
发现输入错误的时候会有一个 AlertDialog 弹出 , 提示 "密钥无效"
首先使用 bash 的 file 工具查看一下文件类型 :
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-5c9de322a60ce6d1.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
CrackMe1.exe: PE32 executable (GUI) Intel 80386, for MS Windows
打开 IDA , 载入该程序 , 由于我们之前运行该程序的时候注意到了关键字符串 "密钥无效"
这时可以通过搜索定位 "密钥无效"
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-fd81b3ea691ba926.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
双击后面的注释跳转到 图形视图
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-bff93ce90cd531e4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
这里调用了这个函数 : sub_4011D0
当返回值不为 0 的时候 , 就跳转到 密钥无效
的分支
我们继续查看这个函数 : sub_4011D0
直接 f5 反编译为 C代码
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-1fa8128b83314ff7.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-f1055e2682270bd4.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
通过分析可以知道 , 这段代码会将用户输入的用户名的每个字符遍历一遍
把每个字符的序号(从 0 开始算)与这个字符的ASCII码的平方相乘 , 然后整体再加上序号 , 得到的和继续对 0x42 求余 , 最后将结果加上 33 , 然后再转为ASCII码
然后再将上述结果连接在字符串 ‘[email protected]‘ 之后构成注册码
分析清楚了思路 , 然后就是写注册机
#!/usr/bin/env python
username = "Hello"
counter = 0;
password = "[email protected]"
for i in username:
password = password + chr((counter + counter * ord(i) * ord(i)) % 0x42 + 33)
counter = counter + 1
print(password)
运行后结果为 :
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-6f62fd00e230fb68.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
得到 hello 用户的注册码为 : [email protected]!GA0U
![技术分享](http://upload-images.jianshu.io/upload_images/2355077-9dc8ba1a2b6ed97c.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
Paste_Image.png
作者:王一航
链接:http://www.jianshu.com/p/6e7396cdb0f1
來源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
以上是关于该提不简单的主要内容,如果未能解决你的问题,请参考以下文章