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

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 2880|回复: 12
收起左侧

[原创] 【2021春节】解题领红包之四{逆向 高级题}

[复制链接]
zhangbaida 发表于 2021-2-27 22:19
本帖最后由 zhangbaIDA 于 2021-2-27 23:30 编辑

今年过年比较忙,做了几个初级题。今天才发现原来高级题是python的题目。正好最近也在学习python,就拿过来研究一下。
发现代码不多,稍微加几行代码就可以逆向计算出注册码了。

由于用的是python3.8.5的版本,题目是python2的。就稍微改了一下才可以运行。

[Python] 纯文本查看 复制代码
print("Welcome to Processor's debugger!")
print("Please input you flag now!")

input = input()

if not input:
    print("Are you kidding me?")    #所有的print都要加()不然在python中报错
    exit(0)

lenth = len(input)
if lenth <= 10:
    print("Short flag!")
    exit(0)

print("len:%d" % (lenth))
print("OK,let's debug it! You can 'Step' by 'Space'!")
print("--------------INFO--------------")


def debuginfo(dic, num):
    print("eax: %d" % (dic['eax']))
    print("ebx: %d" % (dic['ebx']))
    print("ecx: %d" % (dic['ecx']))
    print("zf: %d" % (dic['zf']))
    print("--------------INFO--------------" + str(num))     #此处加了一个行号,打印看的更清楚


index = 0
idx = 0
arr = [
    2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
    73, 79, 83
]
check = [
    -56, -50, -118, -105, -98, -101, -117, -105, -96, -42, -80, 89, 78, 70,
    177, 86, 126, 80, 80, 96, 177, 109, 28
]
result = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

dic = {'eax': 0, 'ebx': 0, 'ecx': 0, 'zf': 0}
list1 = []
list2 = []
while input != ' ':  #循环需要修改为不等于,原题不该直接跳过循环无法调试了,同理所有的if判断也是一样修改

    if index <= 10:
        dic['eax'] = ~ord(input[index])
        dic['ebx'] = 0
        dic['ecx'] = index
        dic['zf'] = 0
        #debuginfo(dic, index)

        if input != ' ':
            dic['eax'] = dic['eax'] ^ arr[index]
            dic['ebx'] = arr[index]
            dic['ecx'] = index
            dic['zf'] = 1
            result[index] = dic['eax']
            #debuginfo(dic, index)
            '''
            关键算法在这里:
            check列表是最终结果,输入的flag需要和这个比较(在后面一个while中)。
            第一部分: flag的前11位

            分别取输入的字符串,逐个转换为10进制,然后按位取反运算(类似a=-x-1),结果在对应arr列表元素进行按位异或运算。
            
            '''
            reg1 = ((check[index] ^ arr[index]) + 1) * -1
            list1.append(chr(reg1))

    else:
        dic['eax'] = ord(input[index]) + arr[index]
        dic['ebx'] = arr[index]
        dic['ecx'] = index
        dic['zf'] = 1
        #debuginfo(dic, index)

        if input != ' ':
            dic['eax'] = dic['eax'] ^ 0xcc
            dic['ebx'] = 0xcc
            dic['ecx'] = index
            dic['zf'] = 1
            result[index] = dic['eax']
            #debuginfo(dic, index)
            '''
            第二部分: flag的后12位

            分别取输入的字符串,逐个转换为10进制,然后加上arr列表对应元素,结果再和0xcc进行按位异或运算。
            
            '''
            reg2 = ((check[index] ^ 0xcc) - arr[index])
            list2.append(chr(reg2))

    index = index + 1
    if index == 23 or index == lenth:
        break
print(list1 + list2)
print('flag为'+''.join(list1 + list2))
while input != ' ':
    dic['eax'] = result[idx]
    dic['ebx'] = check[idx]
    dic['ecx'] = idx
    if dic['eax'] != dic['ebx']:
        dic['zf'] = 1
        print("Wrong flag, try again!")
        #debuginfo(dic, idx)
        exit(0)
    else:
        dic['zf'] = 0
    #debuginfo(dic, idx)
    idx = idx + 1

    if idx == 23 or idx == lenth:
        if lenth == 23:
            print("Yes, you got it!")
            exit(0)
        else:
            print("Close to right!")
            exit(0)





运行,输入23位假码。即可出注册码   52pojie{H4PpY_New_Ye4R}



微信截图_20210227223927.png

免费评分

参与人数 3威望 +1 吾爱币 +24 热心值 +3 收起 理由
Ah0NoR + 1 + 1 谢谢@Thanks!
Hmily + 1 + 20 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
pwp + 3 + 1 膜拜大佬

查看全部评分

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

Hmily 发表于 2021-2-28 10:00
popdisk 发表于 2021-2-27 23:52
对头,不是很懂这题的意义在哪。一开始以为是pwn,后来给了提示就发现能爆破,所以是考察fuzz吗。。。
【2021春节】逆向高级题 -- 出题人出来挨打了
https://www.52pojie.cn/thread-1379363-1-1.html


作者的回复。
gunxsword 发表于 2021-2-28 10:41
终于搞清楚怎么回事了
原题并不是给的PY代码,不是这么玩的,是一个NC的远程服务器
可能你来的太晚,看到的是这样的题(我刚刚也下载了题目打包看了一下)
原题并不是这么解的,而且那个服务器,卡的很!
头像被屏蔽
冰棍好烫啊 发表于 2021-2-27 22:36
lphgor 发表于 2021-2-27 23:17
原题是远程调试,看不到源码的

这是原题:
[Bash shell] 纯文本查看 复制代码
nc 27.100.36.88 9999
popdisk 发表于 2021-2-27 23:52
lphgor 发表于 2021-2-27 23:17
原题是远程调试,看不到源码的

这是原题:

对头,不是很懂这题的意义在哪。一开始以为是pwn,后来给了提示就发现能爆破,所以是考察fuzz吗。。。

点评

作者的回复。  详情 回复 发表于 2021-2-28 10:00
花好s月圆 发表于 2021-2-28 07:25
我的天,难怪堆栈里跟踪不到。
头像被屏蔽
First丶云心 发表于 2021-2-28 09:43
提示: 作者被禁止或删除 内容自动屏蔽
gunxsword 发表于 2021-2-28 09:59
我表示没看懂...原题不是NC远程连接的吗?你是怎么得到他的PY代码的?
gunxsword 发表于 2021-2-28 10:22
正好最近也在学习python,就拿过来研究一下。
发现代码不多,稍微加几行代码就可以逆向计算出注册码了。


请问你是怎么拿到代码的?请问你是怎么拿到代码的?请问你是怎么拿到代码的?
gunxsword 发表于 2021-2-28 10:23

H大,我不是很懂,那个不是NC远程题吗,作者的回复中也说了,是要靠猜的
那这个发贴子的人,是怎么拿到PY代码的呢?

点评

活动结束,题目直接公布了,看活动帖子,代码发出来了。  详情 回复 发表于 2021-2-28 11:30
您需要登录后才可以回帖 登录 | 注册[Register]

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

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

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

GMT+8, 2024-4-20 06:47

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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