USTC Hackergame 2023 Writeup

Last updated on November 4, 2023 pm

前言

  1. 第一天压根就没打算打,因为期中了挺忙的 而且之前做 CCBC13 做出心理阴影了,到后来看到一群人截图一堆 MyGO 梗才觉得不打那岂不是完全辜负了自己前几天补的 MyGO(结果来说没做出几道 MyGO 题(
  2. 实际上总共也就打了两天,周一和周二。之后的就没有打了。
  3. 往年照例,奇技淫巧流,一旦深入立马就不会了;
  4. 最后成绩:1750,总排名:467 / 2386;AI:0 , binary:200 , general:1100 , math:0 , web:450 ;
  5. 无论是官方题解还是我看到的几个第三方题解都有那么几道题是完全不打算考虑最简单情况。可能是 CTF 打多了和我这样的思路不太一样?
  6. 看了看官方题解的 MyGO 浓度,明年这样我还来打(

Writeup

写完了的

Hackergame,启动!

随便录音后提交,观察 URL 发现带了查询参数 ?similarity=XX.XXX,改为大于 99.9 的数字即可拿到 flag。
Hackergame,启动!

猫咪小测

年年小测拉着大家熟悉中科大

  1. 所提到的书的校内 OPAC,馆藏位置在西区外文书库;查图书馆馆藏分布,西区外文书库在 12 楼;
  2. 直接搜索关键词“The density upperbound of chicken in observable universe”,找到对应论文 ;数据很多,没有天体物理学基础也不要紧;注意到单位是每立方秒差距($pc^{-3}$),在 Abstract 中搜索即得为 $10^{23} pc^{-3}$;
  3. Google 对于如何配置 GCE 上支持 TCP BBR 的 Linux Kernel 的文章;结尾 Further Reading 部分提到了两个参数,第一个 CONFIG_TCP_CONG_BBR支持,第二个是默认启用;
  4. 按照提示搜索 mypy infinite loop halting problem +paper,然后就耐心的直到翻到这篇论文吧;所在的会议是 ECOOP 2023;

更深更暗

打开提供的网页看源代码。
什么嘛,沉底了嘛。

音频、ISS、图片,直接上 SSTV。慢扫描电视,启动!

flag{SSssTV_y0u_W4NNa_HaV3_4_trY}

JSON $\subset$ YAML?

这种技术问题一定会有人出来骂。简单搜索 JSON subset YAML,就能找到这篇文章和这条评论

  1. YAML 允许在不转义的情况下使用字符串 yesno 直接表达布尔值,JSON 的字符串严格不转义;
  2. JSON 会将科学计数法(例如 1e6)转义为数字,YAML 会按字符串转义;
  3. JSON 的 RFC 标准要求 Object Key“应当”是独特的,而 YAML 1.2 的 Spec 要求“必须”独特;
    1. 说实话,这个本身在 JSON 里面也不能算“合法”。属于没活硬整。
  4. YAML 1.2 有 Object Key 的长度硬限制(1024 字符),JSON 没有,所以撑爆就好;
    1. 出题组拒绝了考虑这一条作为可选题解。Fine。
    2. (赛后)好好好:

      这个 flag 实际上有一个额外的要求,就是输入必须能正常被 YAML 1.1 解析成功。这是故意的,因为能让 YAML 1.1 与 YAML 1.2 同时报错的输入太多了,非常容易找到,例如超长的 key(1024 字符)

Git? Git!

Git 的底层系统会以 object 和 refs 的形式保留任何进入 Git 监测的文件的任何更改,甚至包括硬回退。使用 git reflog 可以看到这些记录的更改,使用 git reset --hard <SHA> 可以强制回退到某一更改的时刻。

HTTP 集邮册

五种状态码

正常请求:200
请求不存在的:404
使用错误方法请求:405
大量塞入 URI 路径:414
改 HTTP 版本为 2.0 或者 3.0 啥的:505
解题。

没有状态……哈?

根据 Bug,Nginx 会处理 Header 带有恶意 CRLF 的 Request,不作转义。在请求首行的 URI 路径部分构造一个恶意的 CRLF 就能拿到。
(赛后)原来是 HTTP 0.9,学到多。

高频率星球

asciinema cat file.rec 可以将所有输出内容导出到 stdout。需要注意的是因为 less pager 扰乱了一部分,需要隔一段清理一下控制字符。选择适当的范围,搜索删除即可。

低带宽星球

小试牛刀

压缩工具 ;OxiPNG+Efford 拉满+Reduce Palette 就能完美压进1kb。

为什么要打开 /Flag

LD_PRELOAD, Love!

题目用 LD_PRELOAD 代理拦截了 open 系统调用,任何读取带 flag 路径的请求都会被 redirect 到 /fakeflag,直接偷系统的原装库从里面把需要的函数拆出来用就可以。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
#include <dlfcn.h>
#include <fcntl.h>

int main() {
const char* flagPath = "/flag";

// Dynamically load the system's C library
void* libcHandle = dlopen("libc.so.6", RTLD_LAZY);
if (!libcHandle) {
std::cout << "Failed to load C library." << std::endl;
return 1;
}

// Get the function pointers for the necessary functions
typedef int (*OpenFunc)(const char*, int, ...);
OpenFunc openFunc = reinterpret_cast<OpenFunc>(dlsym(libcHandle, "open"));
if (!openFunc) {
std::cout << "Failed to get the 'open' function." << std::endl;
dlclose(libcHandle);
return 1;
}

typedef ssize_t (*ReadFunc)(int, void*, size_t);
ReadFunc readFunc = reinterpret_cast<ReadFunc>(dlsym(libcHandle, "read"));
if (!readFunc) {
std::cout << "Failed to get the 'read' function." << std::endl;
dlclose(libcHandle);
return 1;
}

typedef int (*CloseFunc)(int);
CloseFunc closeFunc = reinterpret_cast<CloseFunc>(dlsym(libcHandle, "close"));
if (!closeFunc) {
std::cout << "Failed to get the 'close' function." << std::endl;
dlclose(libcHandle);
return 1;
}

// Open the file using the 'open' function from the C library
int fd = openFunc(flagPath, O_RDONLY);
if (fd == -1) {
std::cout << "Failed to open the file." << std::endl;
dlclose(libcHandle);
return 1;
}

char buffer[1024];
ssize_t bytesRead;

// Read data from the file using the 'read' function from the C library
while ((bytesRead = readFunc(fd, buffer, sizeof(buffer))) > 0) {
// Print the contents of the file
std::cout.write(buffer, bytesRead);
}

// Close the file using the 'close' function from the C library
closeFunc(fd);

// Unload the dynamically loaded C library
dlclose(libcHandle);

return 0;
}

flag{nande_ld_preload_yattano_9a3946a493}

没写完的

旅行照片 3.0

早上

奖牌是诺贝尔奖,奖牌上的铭字 M.KOSHIBA MMII 应当指的是 2002 年获得诺贝尔物理学奖的物理学家小柴昌俊(Masatoshi Koshiba)教授。老人家退休前是东京大学教授,退休后是东海大学名誉教授。通过对中午和晚上的内容过滤,锁定“上野站”这一地点,与学校为步行距离。过滤得学校应当为东京大学。

中午

搜图易得喷泉是上野公园大喷泉。


USTC Hackergame 2023 Writeup
http://elfile4138.moe/2023/11/USTC-Hackergame-2023-Writeup/
Author
Matrew File
Posted on
November 4, 2023
Updated on
November 4, 2023
Licensed under