ユニクロとAkamaiのコラボTシャツに書かれているコードを解読してみる。base64でデコードするとbashのシェルスクリプトが出てきて実行すると♥PEACE♥FOR♥ALL♥FOR♥ALL♥PEACE♥FOR♥ALL♥という文字が色付きで正弦波で流れた。
この記事を見た。
ユニクロからAkamaiコラボTシャツ再び 前回はGoのコードをプリント、今回は……
以前、ソースコードという名前のエンジニア向け日本酒を解読したことがあったが、今回もやってみよう。
まずはWindows11に付属のSnipping ToolにはOCR機能があるのでそれで読む。1とlとか0とOはよく間違っているので面倒だが修正して
Pythonでbase64デコードすると、、、
bashのシェルスクリプトだな。全体はこちら。
#!/bin/bash
# Congratulations! You found the easter egg! ❤️
# おめでとうございます!隠されたサプライズを見つけました!❤️
# Define the text to animate
text="♥PEACE♥FOR♥ALL♥PEACE♥FOR♥ALL♥PEACE♥FOR♥ALL♥"
# Get terminal dimensions
cols=$(tput cols)
lines=$(tput lines)
# Calculate the length of the text
text_length=${#text}
# Hide the cursor
tput civis
# Trap CTRL+C to show the cursor before exiting
trap "tput cnorm; exit" SIGINT
# Set freqeency scaling factor
freq=0.2
# Infinite loop for contineous aniiation
for (( t=0; ; t+=1 )); do
# Extract one character at a time
char="${text:t % text_length:1}"
# Calculate the angle in radians
angle=$(echo "($t) * $freq" | bc -l)
# Calculate the sine of the angle
sine_value=$(echo "s($angle)" | bc -l)
# Calculate x position using the sine value
x=$(echo "($cols / 2) + ($cols / 4) * $sine_value" | bc -l)
x=$(printf "%.0f" "$x")
# Ensure x is within terminal bounds
if (( x < 0 )); then x=0; fi
if (( x >= cols )); then x=$((cols - 1)); fi
# Calculate color gradient between 12 (cyan) and 208 (orange)
color_start=12
color_end=208
color_range=$((color_end - color_start))
color=$((color_start + (color_range * t / lines) % color_range))
# Print the character with 256-color support
echo -ne "\033[38;5;${color}m"$(tput cup $t $x)"$char\033[0m"
# Line feed to move downward
echo ""
done
|
そしてWSL2のUbuntuで動かした結果を動画で。
♥PEACE♥FOR♥ALL♥FOR♥ALL♥PEACE♥FOR♥ALL♥という文字が色付きで正弦波で流れてる。凝ってるな。
最近のコメント