在阅读之前,请确认是否处于这个地址,这是对本菜鸟辛勤码字最大的鼓励啦,感激不尽~


拿到题目,记事本打开,发现是一首诗后面跟着密文,所以想到是PoemCode。关于PoemCode更详细的加解密原理介绍可以参阅我的这篇博客,本文只粗略讲步骤。

The life that I have
Is all that I have
And the life that I have
Is yours.The love that I have
Of the life that I have
Is yours and yours and yours.A sleep I shall have
A rest I shall have
Yet death will be but a pause.For the peace of my years
In the long green grass
Will be yours and yours and yours.decrypted message: emzcf sebt yuwi ytrr ortl rbon aluo konf ihye cyog rowh prhj feom ihos perp twnb tpak heoc yaui usoa irtd tnlu ntke onds goym hmpq

简要分析:

  1. 找关键词
    密文第一块是“emzcf”,意味着:
    e:第一个关键词是诗歌的第(26k+5)个词,可能是[‘have’, ‘yours’, ‘my’],
    m:第二个关键词是诗歌的第(26k+13)个词,可能是 [‘life’, ‘shall’, ‘be’],
    z:第三个关键词是诗歌的第(26k+26)个词,可能是[‘life’, ‘pause’],
    c:第四个关键词是诗歌的第(26k+3)个词,可能是[‘that’, ‘have’, ‘peace’],
    f:第五个关键词是诗歌的第(26k+6)个词,可能是[‘is’, ‘and’, ‘years’]
    这意味着,可能的关键词组合有3*3*2*3*3=162种,每种关键词对应一个解密结果。

  2. 筛掉不可能的关键词组合
    密文sebt yuwi ytrr ortl rbon aluo konf ihye cyog rowh prhj feom ihos perp twnb tpak heoc yaui usoa irtd tnlu ntke onds goym hmpq有100个字母,关键词的字母个数应该可以被100整除。
    所以像my be life that is这个组合,有14个字母,不能被100整除,就可以直接不用试了,不可能是正确组合。
    其它组合以此类推。

  3. 手动解法的话,接下来就是关键词字母标号,密文依次填进去,重新排列,获取明文内容。具体操作还是参考文章开头给的博文。

  4. 直接脚本解密,看下面的步骤。

1.把诗歌和密文分成两个文本,诗歌去掉特殊字符,记得要保留单词间的空格,否则解密会出错。

poem.txt

The life that I have
Is all that I have
And the life that I have
Is yoursThe love that I have
Of the life that I have
Is yours and yours and yoursA sleep I shall have
A rest I shall have
Yet death will be but a pauseFor the peace of my years
In the long green grass
Will be yours and yours and yours

cip.txt

emzcf sebt yuwi ytrr ortl rbon aluo konf ihye cyog rowh prhj feom ihos perp twnb tpak heoc yaui usoa irtd tnlu ntke onds goym hmpq

2.解密脚本PoemCode.py

# modified by Clover on 2022.05.13
import sys
import itertools
import re
from os import listdir
from os.path import isfile, joinabc='abcdefghijklmnopqrstuvwxyz'def loadlist(infile):tlist = []for line in open(infile,'r'):for w in line.split(): tlist.append(w.lower())return tlistdef decrypt(poem, cip):# Load all words of the poem into a temporary listtwords = loadlist(poem)# Load all cipher chunks of the ciphertext into a listcwords = loadlist(cip)# Get the code rom the first chunk and remove it from the ciphertext listcode = []for i in cwords.pop(0): #get keywords tipscode.append(abc.index(i))# Select only those words specified in the code in a new multi-arrayed listxwords = [[] for x in range(len(code))]for xcount, c in enumerate(code):tlen = cwhile(c<len(twords)):xwords[xcount].append(twords[c].lower())c+=26# Get all possible combinationsCN=len(cwords)*len(cwords[0])for comb in itertools.product(*xwords):pwords = ''for c in comb: pwords+=cKN = len(pwords)if CN%KN!=0 : continue#re-devide the cyber text by CN/KNc_text=''for i in range(0,len(cwords)):c_text+=cwords[i]c_text_list = re.findall(r'\w{'+str(CN/KN)+'}', c_text)# Rearrange the chunks according to the keypcode = [None] * KN#len of pcode is equal to the numbers in keywords groupcount = 0while(count<KN):for al in abc:for pc, pl in enumerate(pwords):if al!=pl: continuepcode[count]=c_text_list[pc]#put cyber-text blocks in the right positioncount+=1# Decrypt the ciphertextmsg = ''for c in range(0, CN/KN):for word in pcode:msg+=word[c]print msg# first argument = poem
# second argument = ciphertxt or msg
if len(sys.argv) != 3: sys.exit(2)decrypt(sys.argv[1], sys.argv[2])

3.运行python2 PoemCode.py poem.txt cip.txt。运行结果如下,可以看到,虽然经过了关键词组合的筛选,还是有29种可能的关键词组合,需要挑一个长得像答案的。但是如果不筛选的话,就要从162个答案里面挑,工作量更大。
认真看一下,倒数第十行是很有可能的,所以尝试提交一下这一行的数据,耶~ 破解啦~

┌──(kali㉿kali)-[~/AttackAndDefence/CRYPTO进阶/11 PoemCOde]
└─$ python2 PoemCode.py poem.txt cip.txt
uutamlgpetyosoeapdtrwikihrrtonesenolrspriuermbowclcpbfmuhgaoysotpownyuyetiiojokrtondqnhbanoryhhkfyht
ueatmlgtysuoadppetorwoikhrrpeeinlsrtonsrimremboacbufughwclpoyitopowkytsioojnyuerthdnqnhhoyohkyfbanrt
ueutmlgttyseoadpporawoikhrrpneeonlsrtsriimuemboalcbcfughwporyisopowkuytyioojnertthonqnhhnoyahkyfbrtd
ueatlgtutysodapepmorwoinrrpikeenslrothsrimrlboauecbfguhcwmpoyituowksoytioojynperthdnnhhonoyhykfabqrt
uyatmltpsouogpedaetrweikhrptenisrroslonricrembawbfupohmgucloyytopokntisewjiooyurtodnqnhbyhorhfhykant
uyutmlttpsoeogpedaraweikhrpntenosrroslriicuembalwbfcpohmguoryysopokuntiyewjioorttoonqnhnbyharhfhyktd
uyatltutpsoodgpeeamrweinrpiktenssrroolhricrlbauewbfpgohmcumoyytuoksontieowjiyoprtodnnhonbyhryhfhakqt
uyotlesoadgpeatmutprwesnroenisrrolphiktricplbcbfrgohmuamuewoyyeuoytitowjiokpsonrtornnayhdyhfhkhqonbt
uyoaletsoudgpeatmprtwesirokenisrrolphtrnicprbcebfugohmuamwolyyetoyotisowjiokpnrutordnanyhoyhfhkhqbtn
uttaeloeputpsgyodmrawpklornotinreresshriiaeucbfmwulhbocpgmorykooyoiinsujtwyeoprtthnkanhhbonfyhoryqtd
ugetalootstydempuprawroklrnsnepesohtirriioceubfplbacgmmwuhorywyoooieutkyoipnsjrtthanknhrnyhoyhqboftd
ugttalooutspydempreawrpklrnsinetesohrroiioaeubfpulbwcgmmhocrywkoooiesutnyoipjrytthhnknhronyboyhqftad
atmptgpuyooedulaetrsikhrprtiesnoswrlonreremhaowucpfmgibuclobtopjkwnsyeiioyooyurtdnqfhhboorhhytnkanty
utmpttgpeyooedularasikhrpnrtoesnoswrlrieuemhalowccpfmgibuorbsopjkuwnyyeiioyoorttonqfhnhbaorhhytnktdy
atptutgpyodoeuelamrsinrpikrtessnoworlhrerlhaueowcpgfmicbumobtujksownyeoiiyyooprtdnfhonhboryhhtankqty
otpegaydouelatmutrpssnroriesnworlphikrteplhcorcgfimbuamueowbeujywtyoiyiookpsorntrnfahdoyhthnkhqontby
oapetguydouelatmrptssirokriesnworlphrtneprhceoucgfimbuamowlbetjyowsyoiyiookprnutrdfanhooyhthnkhqtbny
gtetyapdpeoulaomutrsrnopeitsroswrlnhikreolcacrwghmpibufmueobwuykytnojieyooipsorthnahodbyfhrtnkhqonty
gaettyupdpeoulaomrtsriokpeitsroswrlnhrneorceacuwghmpibufmolbwtyokysnojieyooipruthdanhoobyfhrtnkhqtny
ifyouthinkcryptographyistheanswertoyourproblemthenyoudonotknowwhatyourproblemisabcdefghijklmnopqrstu
etoyotetpguldampursaoknesnoprrwrslhtireicefcplmahoibgumwuobryoiyeuikjwyooopnsrttanhornhhfhtnykqbotyd
ttoyouteppguldamresapknesinotrrwrslhroeiaefcpulmwhoibgumocbrkoiyesuinjwyoooprytthnhoronhbfhtnykqtayd
putoamypetdugtlaoresriknihetonswrprlsroehuefrmcwclgioabupombjsoitpynyuoywkooeritfonhdqobanythhnkrthy
tteoeputaplgrysodmuapkonotinlrrrreesshwiaecfmwuluhboocbpgmirkoyiinsuojowryteopythnahhbonkfnhtoyryqtd
getootatlrsydempupuaroknsnlprreesohtirwiocefpluabobcgmmwuhirwyoieuokortyoipnsjythanhrnkhntyoyhqboftd
gttooutaplrsydempeuarpknsinltrreesohrowioaefpuluwbobcgmmhcirwkoiesuonortyoipjyythhnhronkbntyoyhqfatd
aetoteltpoygsdrmpuualoksnorprneresrhtiwiuceplmbahfcobgomwuiroyoeuiokjiywtorpnsytkanrnhnhfhohyytqbotd
attoutelppoygsdrmeualpksinortrneresrhowiuaepulmbwhfcobgomcirokoesuionjiywtorpyytkhnronhnbfhohyytqatd
aputampetloysdgtroeulrikihtonrneesrprsowuhuermwclbfcbgoaopmiojsotpnyuoiytowkreiykfondqbannhoyyhhtrht

writeup 攻防世界 Decrypt-the-Message相关推荐

  1. forgot [XCTF-PWN][高手进阶区]CTF writeup攻防世界题解系列13

    题目地址:forgot 本题是高手进阶区的第二题,恭喜大家已经进入高手行列!好假好假,哈哈哈! 废话不说,看看题目先 这个题目有很长的描述,但是都是废话,不去管他了. 照例下载附件,做下安全检查 ro ...

  2. 攻防世界 Reverse高手进阶区 3分题 crackme

    前言 继续ctf的旅程 攻防世界Reverse高手进阶区的3分题 本篇是crackme的writeup 攻防世界的题目分数是动态的 就仅以做题时的分数为准了 解题过程 查壳,显示nsPack壳 找了个 ...

  3. 攻防世界writeup

    攻防世界writeup 前言 web 新手练习 view_source get_post robots backup cookie disabled_button simple_js xff_refe ...

  4. 攻防世界reverse进阶easyre-153 writeup(#gdb调试父子进程、#ida版本差异)

    文章目录 学习目标: 引言 第一步.查脱壳 1.查壳 2.脱壳 3.查看文件格式 第二步.IDA静态分析 1.IDA版本的小坑 2.分析main函数 3.分析lol函数 第三步.gdb动态分析 1.m ...

  5. file upload 攻防世界_菜鸡 CTF 之旅 Writeup (攻防世界)

    前言 我是个菜鸡,菜鸡就要先走新手练习区. 这次 CTF Writeup 的指定训练站点为 攻防世界 新手练习区 Web 区 view_source 题目描述:X老师让小宁同学查看一个网页的源代码,但 ...

  6. XCTF攻防世界Web之WriteUp

    XCTF攻防世界Web之WriteUp 0x00 准备 [内容] 在xctf官网注册账号,即可食用. [目录] 目录 0x01 view-source2 0x02 get post3 0x03 rob ...

  7. 攻防世界 MISC 新手练习区 writeup 001-006

    攻防世界 MISC 新手练习区 题目解答 文章目录 001 this_is_flag 002 pdf 003 如来十三掌 004 give_you_flag 005 stegano 006 坚持60s ...

  8. 攻防世界web高手进阶区ics-05(XCTF 4th-CyberEarth)WriteUp

    文章目录 解题部分 总结: 解题部分 题目来源 攻防世界web高手进阶区ics-05(XCTF 4th-CyberEarth) 1.拿到题目以后,发现是一个index.php的页面,并且设备-没有显示 ...

  9. 攻防世界web新手区easyphp题解writeup

    写在前面 最近在学习CTF web相关知识,顺带学习php,在攻防世界平台上做做题.遇到了一道名为easyphp的题目,对我这个新手一点也不easy,于是决定把过程记录下来. 参考了官网上shuita ...

最新文章

  1. struct ifconf和struct ifreq,获取网线插入状态
  2. python读取连接数据库文件_python 读取配置文件 pandas连接数据库
  3. 【Hibernate】hibernate实体关系映射——单边的多对多关系
  4. uml类图例子_转:(中文命名)UML类图新手入门级介绍
  5. 【无标题】物联网安全挑战:为什么企业现在必须评估它们
  6. 2.1 ListView 源码
  7. element下拉框回显问题
  8. 瑜伽扭身祈祷式动作教程
  9. JS流程控制语句 重复重复(for循环)语句结构: for(初始化变量;循环条件;循环迭代) { 循环语句 }...
  10. 【弃】Selenium官方文档中文版
  11. 叔叔阿姨,我真的不会修电脑
  12. 用HTML5绘制的一个星空特效图
  13. java 减法基础_Java 基础入门
  14. 如何在JPG照片尺寸不变的情况下压缩大小?
  15. C#版 - 小红书后台开发面试题: 二维数组中的查找
  16. 《月亮与六便士》书摘
  17. python数据分析基础试题_Python数据分析基础知识
  18. 当BERT遇上搜索引擎
  19. 牛客练习赛43 c Tachibana Kanade Loves Review
  20. python程序设计第三版课后答案第六章_python程序设计 第六章答案

热门文章

  1. C# 读取txt文件生成Word文档
  2. android lunch 报错
  3. ImageMagick将多张图片拼接成一张图片_介绍一款全功能的图片查看编辑软件
  4. HTTP_REFERER的用法及伪造及去掉REFERER方法
  5. http://www.ithao123.cn/content-1432166.html
  6. An Auto-tuning Framework for Autonomous Vehicles
  7. 清理Ubuntu虚拟机磁盘空间
  8. struct sysinfo 用法
  9. 深入理解Seq2seq模型(Sequence2sequence)
  10. 图解unicode、utf8和utf8mb4