自学内容网 自学内容网

新160个crackme - 060-snake

运行分析

在这里插入图片描述

  • 需破解Name和Serial

PE分析

在这里插入图片描述

  • 32位,未知程序和壳
    在这里插入图片描述
  • 点击Scan/t按钮外部扫描,发现是C++程序

静态分析&动态调试

在这里插入图片描述

  • ida搜索关键字符串,双击进入

在这里插入图片描述

  • 发现无法反编译

在这里插入图片描述

  • 选中该函数(地址:401048 - 401172)
  • Edit -> Functions -> Delete function
  • 然后再选中该函数,按P键创建函数

在这里插入图片描述

  • 按F5,反编译成功
  • 分析主函数,注释如上图,还需要知道sub_401173、sub_40119B和sub_40120C函数功能

在这里插入图片描述

  • 分析sub_401173,发现其作用是初始化变量dword_401AF0

在这里插入图片描述

  • 动调sub_40119B函数,发现函数作用是根据Name决定0xCC和0xDD位置和个数
    在这里插入图片描述
  • 看一下结果,结合题目为snake,猜测为16*16的贪吃蛇地图

在这里插入图片描述

  • 动调sub_40120C函数,其作用是模拟贪吃蛇的轨迹,具体如下:
  • 1、贪吃蛇初始长度为1,蛇头位置为0x99
  • 2、提取Serial每一位进行&3计算,得到结果转化为蛇头上下左右行为
    0 -> 16 -> ↑
    1 -> -16 -> ↓
    2 -> -1 -> ←
    3 -> 1 -> →
  • 3、每吃到一个0xCC,蛇身+1,蛇头不能撞到蛇身,必须吃完0xCC,最后再吃0xDD,即可弹窗成功

算法分析

from ctypes import *


def sub_40119B():         # 根据Name决定0xCC和0xDD位置和个数
    global dword_401B00
    global dword_401700

    # Name每个字符相加得到v2
    v2 = c_uint8(0)
    for i in Name:
        v2.value = (v2.value + ord(i)) & 0xff

    # Name每个字符进行计算,改变dword_401B00的值
    n = 0
    v5 = c_uint8(0)
    for i in range(len(Name)):
        v5.value = (v2.value ^ ord(Name[i]))
        v2.value -= v5.value
        dword_401B00[v5.value] |= 0xCC

    # 对dword_401B00[v5]赋值0xDD
    i = c_uint8(0)
    i.value = v5.value ^ v2.value
    while 1:
        v5.value = v5.value - i.value
        if (dword_401B00[v5.value] != 0xCC):
          break
        i.value = i.value - 1
    dword_401B00[v5.value] = 0xDD

    v5.value = i.value
    while ( dword_401B00[v5.value] == 0xCC or dword_401B00[v5.value] == 0xDD):
        v5.value = v5.value - 1
    dword_401B00[v5.value] = 0x99

    # 对dword_401700赋值
    dword_401700 = v5.value


def sub_40120C():
    global maps
    global Serial

    # 对地图进行分块
    for i in range(0,16):
        maps.append(dword_401B00[16*i:16*(i+1)])

    # 获取0xCC坐标点
    addr_CC = []
    for y in range(0,16):
        for x in range(0,16):
            if maps[y][x] == 0xCC:
                addr_CC.append([x,y])

    # 获取0xDD坐标
    addr_DD = []
    for x in range(0,16):
        for y in range(0,16):
            if maps[y][x] == 0xDD:
                addr_DD.append([x,y])

    # 获取初始蛇头位置
    addr_99 = []
    for x in range(0,16):
        for y in range(0,16):
            if maps[y][x] == 0x99:
                addr_99.append([x,y])


    # 蛇头吃0xCC行动轨迹
    for i in range(len(addr_CC)-1,-1,-1):
        y =  addr_99[0][1] - addr_CC[i][1]
        x =  addr_99[0][0] - addr_CC[i][0]
        if y >= 0 :
            Serial += '1' * y
        else:
            Serial += '0' * (-y)
        if x >= 0:
            Serial += '2' * x
        else:
            Serial += '3' * (-x)
        addr_99[0] = addr_CC[i]

    # 蛇头吃0xDD行动轨迹
    y =  addr_99[0][1] - addr_DD[i][1]
    x =  addr_99[0][0] - addr_DD[i][0]
    if y >= 0 :
        Serial += '1' * y
    else:
        Serial += '0' * (-y)
    if x >= 0:
        Serial += '2' * x
    else:
        Serial += '3' * (-x)


if __name__ == '__main__':
    Name = 'c'# 假设Name长度为1
    Serial = ''
    dword_401B00 = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,0x00, 0x00]
    maps = []
    sub_40119B()
    sub_40120C()
    print(Name + '的Serial为:\n' + Serial)


在这里插入图片描述

在这里插入图片描述

  • 因为未限制Name个数,所以假设Name长度为1,这样比较简单
  • 验证成功

原文地址:https://blog.csdn.net/qq_41483767/article/details/142338679

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!