title:polybius
description: 2020 | bjdctf | crypto | polybius
做題平台:ctfhub
密文:ouauuuoooeeaaiaeauieuooeeiea hint:vghligxlbmd0acbvzib0aglzihbsywlud**4ddogmtq= flag:解出明文後,**上bjd{}
首先題目描述為「polybius」,最直接想到的應該是「波利比奧斯矩陣」或「波利比奧斯棋盤」即棋盤密碼。再對應給出的密文是「a,e,i,o,u」這五個字母的重複,那就肯定了這個應該是棋盤密碼。
話說給出的hint為base64編碼,解碼後為「the length of this plaintext: 14」,而密文長度剛好為14*2=28,更加確定了這是棋盤加密。
key=[['a','b','c','d','e'],\
['f','g','h','i/j','k'],\
['l','m','n','o','p'],\
['q','r','s','t','u'],\
['v','w','x','y','z']] #字母棋盤的生成
ordstr = ''
c = 'ouauuuoooeeaaiaeauieuooeeiea'
import itertools
num = ['a','e','i','o','u']
for num in itertools.permutations(num, 5): #python內建庫itertools中指定元素全排列函式的使用
order = list(num)
for i in c :
a = str(order.index(i))
ordstr = ordstr + a
ordstrlist = list(map(int,list(ordstr))) #將密文中的aeiou轉化為對應數字並存入列表
ordstr = ''
i = 0
mstr2 = ''
while (i!=28):
mstr1 = key[ordstrlist[i]][ordstrlist[i+1]] #兩兩一組獲取對應明文
mstr2 = mstr2 + mstr1
i = i+2
print(mstr2) #輸出解密結果
執行結果:
在結果中查詢「flag」:
bjd
1.編寫了棋盤密碼窮舉的指令碼
2.了解到了指定元素全排列函式itertools.permutations(list,int)
的用法
3.不能定式思維誰說的「aeiou」順序必須按照字母表來?
馬踏棋盤python 馬踏棋盤python實現
import collections import random class checkerboard object 初始化棋盤 def init self,len self.len len self.position has gone set def init checkerboard self ...
POJ 1321 棋盤問題(棋盤DFS)
棋盤問題 思路 分層查詢,逐行深搜。注意k n時的處理。1 include 2 include 3 include 4 include 5 include 6 include 7 include 8 include 9 include 10 define ll long long 11 define...
棋盤覆蓋問題
source code include include include using namespace std const int n 1024 int board n n count void cover int sx,int sy,int cx,int cy,int size,int cx1,i...