LoginSignup
0
0

ksnctf #2 Easy Clipher

Last updated at Posted at 2024-02-11

ksnctf #2 Easy Clipher

problem.txt
EBG KVVV vf n fvzcyr yrggre fhofgvghgvba pvcure gung ercynprf n yrggre jvgu gur yrggre KVVV yrggref nsgre vg va gur nycunorg. EBG KVVV vf na rknzcyr bs gur Pnrfne pvcure, qrirybcrq va napvrag Ebzr. Synt vf SYNTFjmtkOWFNZdjkkNH. Vafreg na haqrefpber vzzrqvngryl nsgre SYNT.

アルファベットや空白があることからこれはシーザー暗号と推測できます。
https://dencode.com/ja/cipher
このサイトで解読すると、13(A<-N)で意味の分かる文字列になります。

ans.txt
ROT XIII is a simple letter substitution cipher that replaces a letter with the letter XIII letters after it in the alphabet. ROT XIII is an example of the Caesar cipher, developed in ancient Rome. Flag is FLAGSwzgxBJSAMqwxxAU. Insert an underscore immediately after FLAG.

よって答えは"FLAGSwzgxBJSAMqwxxAU"とわかります。

ほかにも、python でシーザー暗号を解読することができる。

caesar.py
text = "EBG KVVV vf n fvzcyr yrggre fhofgvghgvba pvcure gung ercynprf n yrggre jvgu gur yrggre KVVV yrggref nsgre vg va gur nycunorg. EBG KVVV vf na rknzcyr bs gur Pnrfne pvcure, qrirybcrq va napvrag Ebzr. Synt vf SYNTFjmtkOWFNZdjkkNH. Vafreg na haqrefpber vzzrqvngryl nsgre SYNT."

for i in range(1, 26):
    ans = ""
    for char in text:
        if char.isalpha():
            ascii_offset = ord('a') if char.islower() else ord('A')
            ans += chr((ord(char) - ascii_offset - i) % 26 + ascii_offset)
        else:
            ans += char
    print(f"Shift {i}: {ans}")

これはGithubでも公開しています。
https://github.com/furiirakun/onigiri/blob/main/caesar.py
スクリーンショット 2024-02-11 002941.png

ここでも同じく13シフトで意味のわかる文になる。

参考文献

isalpha()->https://qiita.com/furiirakun/items/c763d4655ae7d7665896
ord()->https://qiita.com/furiirakun/items/5b7397766c0fca04b4fd
islower()->https://qiita.com/furiirakun/items/071c9b07214302c18300

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0