avatar

我可是会飞的啊

找对象ing

  • 首页
  • ctfs
  • 关于
  • 文件库
  • 留言板
  • 标签
  • 归档
  • 【网课推荐】(红队&二进制)
首页 [Google CTF 2023]rev-zermatt

[Google CTF 2023]rev-zermatt

Posted 2023年 10月 31日 Updated 2023年 11月 1日
[Google CTF 2023]rev-zermatt
By selph
8~11 min read

image​

‍

分析

这里给了个超长的lua脚本,格式化之后,首先看到的就是一个解密函数:

    local v0 = string.char;
    local v1 = string.byte;
    local v2 = string.sub;
    local v3 = bit32 or bit;
    local v4 = v3.bxor;
    local v5 = table.concat;
    local v6 = table.insert;
    local function v7(v24, v25)
        local v26 = 0;
        local v27;
        while true do
            if (v26 == 1) then
                print(v5(v27));	-- 加一行,打印结果
                return v5(v27);
            end
            if (v26 == 0) then
                v27 = {};
                for v44 = 1, #v24 do
                    v6(v27, v0(
                        v4(v1(v2(v24, v44, v44 + 1)), v1(v2(v25, 1 + ((v44 - 1) % #v25), 1 + ((v44 - 1) % #v25) + 1))) %
                            256));
                end
                v26 = 1;
            end
        end
    end

为了知道解密结果,在返回的时候打印解密结果

运行脚本:

PS D:\Misc\CTF\ctf-bin\2023-Google-CTF\re-zermatt> luajit.exe .\zermatt.lua
tonumber
string
byte
string
char
string
sub
string
gsub
string
rep
table
concat
table
insert
math
ldexp
getfenv
setmetatable
pcall
select
unpack
tonumber
123
..
__index
__newindex
 _____             _     ___ _____ ____
|   __|___ ___ ___| |___|   |_   _|  __|
|  |  | . | . | . | | -_| -<  | | |  __|
|_____|___|___|_  |_|___|___| |_| |_|
              |___|       ZerMatt - misc
>

看到这里有一堆字符串,其中引起好奇的是unpack

接下来的代码是:一系列解密

    local v8 = _G[v7("\79\15\131\30\40\13\20\203", "\59\96\237\107\69\111\113\185")];
    local v9 = _G[v7("\55\2\190\232\63\247", "\68\118\204\129\81\144\122")][v7("\12\180\100\225",
        "\110\205\16\132\107\85\33\139")];
    local v10 = _G[v7("\243\205\101\215\89\95", "\128\185\23\190\55\56\100")][v7("\240\94\174\46",
        "\147\54\207\92\126\115\131")];
    local v11 = _G[v7("\109\25\35\60\115\10", "\30\109\81\85\29\109")][v7("\239\234\115", "\156\159\17\52\214\86\190")];
    local v12 = _G[v7("\175\186\253\180\178\169", "\220\206\143\221")][v7("\213\149\104\47",
        "\178\230\29\77\119\184\172")];
    local v13 = _G[v7("\235\225\172\3\21\112", "\152\149\222\106\123\23")][v7("\167\216\54", "\213\189\70\150\35")];
    local v14 = _G[v7("\28\78\87\120\13", "\104\47\53\20")][v7("\12\172\66\130\29\168", "\111\195\44\225\124\220")];
    local v15 = _G[v7("\191\217\68\12\118", "\203\184\38\96\19\203")][v7("\199\55\96\124\83\218", "\174\89\19\25\33")];
    local v16 = _G[v7("\6\46\6\90", "\107\79\114\50\46\151\231")][v7("\204\61\163\173\57",
        "\160\89\198\213\73\234\89\215")];
    local v17 = _G[v7("\194\77\101\178\251\203\94", "\165\40\17\212\158")] or function()
        return _ENV;
    end;
    local v18 = _G[v7("\53\224\205\5\54\50\228\205\9\49\42\224", "\70\133\185\104\83")];
    local v19 = _G[v7("\217\7\68\72\38", "\169\100\37\36\74")];
    local v20 = _G[v7("\67\5\139\167\83\20", "\48\96\231\194")];
    local v21 = _G[v7("\150\198\74\15\46\18", "\227\168\58\110\77\121\184\207")] or
                    _G[v7("\177\122\62\179\69", "\197\27\92\223\32\209\187\17")][v7("\238\13\79\194\248\8",
            "\155\99\63\163")];
    local v22 = _G[v7("\144\141\223\180\128\187\129\144", "\228\226\177\193\237\217")];
    print("123");	-- 自己加的,用来分隔

发现对应unpack字符串解密的是v21变量

v21可能是个函数,搜索v21(​搜到8个结果

image​

寻找作为返回值的v21调用,调用的时候,使用print打印其结果

image​

在运行的时候,发现flag出现:

image​

CTF{At_least_it_was_not_a_bytecode_base_sandbox_escape}

‍

逆向调试
CTF
This post is licensed under CC BY 4.0 by the author.
Share

Further Reading

Nov 30, 2023

[技能兴鲁2023 决赛 职工组]re-ezalgorithm

附件给了个exe,是pyinstaller打包的结果,没操作过这种程序,赛场上也没做出来,现在再来做一做(输在了没准备工具上) 环境准备 解包需要两个工具 pyinstxtractor.py:exe -> pyc github地址:extremecoders-re/pyinstxtractor: P

Nov 7, 2023

[Pico CTF 2022]pwn-basic-file-exploit

题目分析 只给了个源码.c文件:应该只是逻辑问题 #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #include <string.h> #include <stdint.h> #include <ctype.h> #inclu

Nov 7, 2023

[Pico CTF 2021]pwn-Unsubscriptions Are Free

题目分析 给出了程序和源码 ➜ pwn-Unsubscriptions Are Free pwn checksec vuln [*] '/home/selph/Downloads/PicoCTF/pwn-Unsubscriptions Are Free/vuln' Arch: i3

OLDER

[Google CTF 2023]pwn-write-flag-where3

NEWER

[Pico CTF 2021]pwn-Stonks

Recently Updated

  • 【置顶】本博客的使用指南&更新计划(2023.3更新)
  • [技能兴鲁2023 决赛 职工组]re-ezalgorithm
  • [Pico CTF 2022]pwn-basic-file-exploit
  • [Pico CTF 2021]pwn-Unsubscriptions Are Free
  • [Pico CTF 2021]pwn-Here's a Libc

Trending Tags

pwn 符号执行 HEVD学习 .NET逆向 病毒分析 CTF 软件安全 《Windows内核编程》 dll注入 树莓派

Contents

©2023 我可是会飞的啊. Some rights reserved.

Using the Halo theme Chirpy