0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

modの逆数

Last updated at Posted at 2023-11-15

[picoCTF][Cryptography][basic-mod2]

Writeup

  • またしても解法が書いてあるので、翻訳ソフトで翻訳。
    DeepLって分かりやすい日本語に変換してくれます。
    screenshot 6.png
    screenshot 7.png

  • またしてもプログラムをBingChatに作ってもらった。
    ただBingChatのプログラムは、そのままだと回答にならなかった。
python
# 数値と文字セットを定義
numbers = [432, 331, 192, 108, 180, 50, 231, 188, 105, 51, 364, 168, 344, 195, 297, 342, 292, 198, 448, 62, 236, 342, 63]
charset = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_'

# モジュラ逆数を計算する関数
def mod_inverse(a, m):
    for x in range(1, m):
        if ((a % m) * (x % m)) % m == 1:
            return x
    return -1

# 各数値のモジュロと逆元を計算
mod_numbers = [num % 41 for num in numbers]
inv_numbers = [mod_inverse(num, 41) for num in mod_numbers]

# 文字にマッピング
message = ''.join([charset[num-1] for num in inv_numbers])

print('picoCTF{'+message+'}')
  • 修正部分を探す力が必要でした。
    screenshot 5.png

  • 以上です。
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?