本文最后更新于 539 天前,其中的信息可能已经有所发展或是发生改变。
A misc in CatCTF
https://en.wikipedia.org/wiki/ANSI_escape_code?spm=wolai.workspace.0.0.1a8f6d3abrlcab
FILE = open("flag", 'wb')
def writeThings(b):
FILE.write(b)
def MoveLeft(n=1):
writeThings(b'\x1b[C' * n)
def MoveRight(n=1):
writeThings(b'\x1b[D' * n)
FLAG = b' CatCTF{!2023_Will_Be_Special,2022_Was_Not!} '
# flag彩蛋:https://thwiki.cc/%E6%98%8E%E6%97%A5%E4%B9%8B%E7%9B%9B%EF%BC%8C%E6%98%A8%E6%97%A5%E4%B9%8B%E4%BF%97
import random
COUNT = 2022234
randpos = [random.randint(0, len(FLAG) - 1) for _ in range(COUNT)]
randchar = [random.randint(0x20, 0x7e) for _ in range(COUNT)]
# adjust char
for i in range(len(FLAG)):
pos = COUNT
for j in range(COUNT - 1, 0, -1):
if (randpos[j] == i):
pos = j
break
randchar[pos] = FLAG[i]
writeThings(b'\n')
POS = 0
for i in range(COUNT):
if (randpos[i] > POS):
MoveLeft(randpos[i] - POS)
elif (randpos[i] < POS):
MoveRight(POS - randpos[i])
writeThings(bytearray([randchar[i]]))
POS = randpos[i] + 1
writeThings(b'\n')