Decrypt-the-Message

题目信息:

解密这段信息!

附件:
  1. The life that I have
  2. Is all that I have
  3. And the life that I have
  4. Is yours.
  5. The love that I have
  6. Of the life that I have
  7. Is yours and yours and yours.
  8. A sleep I shall have
  9. A rest I shall have
  10. Yet death will be but a pause.
  11. For the peace of my years
  12. In the long green grass
  13. Will be yours and yours and yours.
  14. 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

涉及知识点:

peom codes(诗歌加密)

诗歌密码在第二次世界大战中被广泛使用,它的工作方式如下:

首先,你需要先记住一首诗歌,它不需要太长,也不需要完整。比如下面这句截取自尤利西斯诗歌的片段就可以。

for my purpose holds to sail beyond the sunset, and the baths of all the western stars until I die.

然后,从中选择五个词作为关键字:比如“ for”,“ sail”,“ all”,“ stars”,“ die”。

接着,将它们串在一起,然后给字母编号,以“ a”开头为1,第二个“ a”开头为2,依此类推;如果没有第二个“ a”,则“ b”的编号为2;或者 如果没有“ b”,则“ c”被标记为2,依此类推,直到我们为所有字母编号。结果:

现在,假设我们要对下面这个消息进行加密:We have run out of cigars, situation desperate.

由于我们在诗歌中选中了18个字母,因此我们以18个字母为一组写出该消息,并用无用的字母填充结尾,如下所示:

注意,在第一个表格(关键字表格)中,第一个字母“f”,它的下面是6;第二个字母是“o”,下面是12。

相对应地,在第二个表格(我们填充的分组的消息)中,第六列字母是“eud”,而第12列是“tdk”。

我们一般按照五个字母为一组发送加密消息,这样可以减少(但当然不能消除)传输错误。

因此,我们信息的第一部分将是eudtd koekc pmwrt

尝试手动加密整个消息!您会发现这很容易做到,您还将看到错误在何处以及如何产生。

当然,我们还必须告诉接收方,我们选择了哪五个词作为关键字,分别是第1个,第6个,第14个,第17个和第20个。最简单的方法是替换字母,因此:“afnqt”将被附加到加密的消息上。然后,接收者可以(大致)遵循相反的步骤来解密消息。

当然,在以上的简短讨论中我们忽略了所有的细微差别。但要知道,用诗歌密码加密的短消息是很难破解的,尤其是当诗歌很少被用于加密或仅用其加密一次。如果这首诗是经常使用的,或者是众所周知的,那么破解用它加密的消息就不难了。另外,诗歌密码具有易用性和易记性的优点,并且不需要任何计算设备。

link: http://wmbriggs.com/post/1001/?doing_wp_cron=1626104322.6441810131072998046875

解题思路:

1.观察附件,发现有一段诗歌以及密文,考虑诗歌加密。
2.由于诗歌加密解密较为复杂,使用现成脚本poemcode.py
3.将诗歌复制到名为peom的文件,将密文复制到cip的文件,删除标点符号
4.运行脚本,从输出中寻找一个最自然的句子,即为flag

附件:

  1. #poemcode.py
  2. #参考:https://github.com/abpolym/crypto-tools/tree/master/poemcode
  3. import sys
  4. import itertools
  5. from os import listdir
  6. from os.path import isfile, join
  7. abc = 'abcdefghijklmnopqrstuvwxyz'
  8. def loadlist(infile):
  9. tlist = []
  10. for line in open(infile, 'r'):
  11. for w in line.split():
  12. tlist.append(w.lower())
  13. return tlist
  14. def decrypt(poem, cip):
  15. # Load all words of the poem into a temporary list
  16. twords = loadlist(poem)
  17. # Load all cipher chunks of the ciphertext into a list
  18. cwords = loadlist(cip)
  19. # Get the code rom the first chunk and remove it from the ciphertext list
  20. code = []
  21. for i in cwords.pop(0):
  22. code.append(abc.index(i))
  23. # Select only those words specified in the code in a new multi-arrayed list
  24. xwords = [[] for x in range(len(code))]
  25. for xcount, c in enumerate(code):
  26. tlen = c
  27. while(c < len(twords)):
  28. xwords[xcount].append(twords[c].lower())
  29. c += 26
  30. # Get all possible combinations
  31. for comb in itertools.product(*xwords):
  32. pwords = ''
  33. for c in comb:
  34. pwords += c
  35. plen = len(pwords)
  36. # Rearrange the chunks according to the key
  37. pcode = [None] * plen
  38. count = 0
  39. while(count < plen):
  40. for al in abc:
  41. for pc, pl in enumerate(pwords):
  42. if al != pl:
  43. continue
  44. pcode[count] = cwords[pc]
  45. count += 1
  46. # Decrypt the ciphertext
  47. msg = ''
  48. wlen = len(pcode[0])
  49. for c in range(0, wlen):
  50. for word in pcode:
  51. msg += word[c]
  52. print(msg)
  53. decrypt("poem", "cip")

FLAG

ifyouthinkcryptographyistheanswertoyourproblemthenyoudonotknowwhatyourproblemisabcdefghijklmnopqrstu

参考:

https://www.cnblogs.com/zhengna/p/14763913.html

作者:damedane-qiuqiu

CTF-Decrypt-the-Message-writeup的更多相关文章

  1. 【CTF】WDCTF-2017 3-1 writeup

    题目来源:WDCTF-2017 题目链接:https://adworld.xctf.org.cn/task/answer?type=misc&number=1&grade=1& ...

  2. 【CTF】WDCTF-finals-2017 3-11 writeup

    题目来源:WDCTF-finals-2017 题目链接:https://adworld.xctf.org.cn/task/answer?type=misc&number=1&grade ...

  3. H4CK1T CTF 2016 Mexico-Remote pentest writeup

    进去网站之后发现连接都是包含类型的,就能想到文件包含漏洞(话说刚总结过就能遇到这题,也算是复习啦) 这里用php://filter/read=convert.base64-encode/resourc ...

  4. hdu 4119 Isabella's Message

    Isabella's Message Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...

  5. hdu 4119 Isabella's Message 模拟题

    Isabella's Message Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.p ...

  6. ctf百度杯十二月场what_the_fuck(一口盐汽水提供的答案)

    目录 漏洞利用原理 具体利用步骤 漏洞利用原理 read(, &s, 0x20uLL); if ( strstr(&s, "%p") || strstr(& ...

  7. C# 加密(Encrypt) 解密(Decrypt) 操作类 java与 C# 可以相互加密解密

    public sealed class EncryptUtils { #region Base64加密解密 /// <summary> /// Base64加密 /// </summ ...

  8. picoCTF2018记录

    近期准备参加CTF 一头雾水 开始练练手 https://2018game.picoctf.com/  这个网站挺适合新手的(据说面向高中生?? 惭愧惭愧) 前面几个比较简单 就从 Resources ...

  9. android md5加密与rsa加解密实现代码

    import java.io.UnsupportedEncodingException;import java.security.MessageDigest;import java.security. ...

  10. What is SSL and what are Certificates?

    Refer to http://www.tldp.org/HOWTO/SSL-Certificates-HOWTO/x64.html The content 1.2. What is SSL and ...

随机推荐

  1. JVM学习心得—JVM内存模型(个人整理,请勿转载)

    一.运行时数据区域 线程私有的:程序计数器+虚拟机栈+本地方法栈 线程共享的:堆+方法区(运行时常量池)+直接内存(非运行时数据区的一部分) *JDK1.8后将方法区废除,新增元空间. 1.1 程序计 ...

  2. 关于Numba的线程实现的说明

    关于Numba的线程实现的说明 由Numbaparallel目标执行的工作由Numba线程层执行.实际上,"线程层"是Numba内置库,可以执行所需的并发执行.在撰写本文时,有三个 ...

  3. TinyML-TVM是如何驯服Tiny的(上)

    TinyML-TVM是如何驯服Tiny的(上) 低成本.人工智能驱动的消费类设备的激增,导致了ML研究人员和从业者对"裸智能"(低功耗,通常没有操作系统)设备的广泛兴趣.虽然专家已 ...

  4. Nsight Compute Profilier 分析

    profiler报告包含每次内核启动分析期间收集的所有信息.在用户界面中,它包含一个包含常规信息的标题,以及用于在报告页面或单个收集的启动之间切换的控件.默认情况下,报告以选定的详细信息页面开始. 页 ...

  5. 英特尔Intel® Arria® 10 FPGA加速器设计

    英特尔Intel Arria 10 FPGA加速器设计 Introducing the Intel Vision Accelerator Design with Intel Arria 10 FPGA ...

  6. .NET平台系列21:云原生时代 .NET5 雄霸天下

    系列目录     [已更新最新开发文章,点击查看详细] 随着互联网持续高歌猛进,相关技术名词也是层出不穷.微服务.容器化.DevOps.ServerLess.FaaS,这两年最火的当属云原生Cloud ...

  7. fiddler抓取手机APP包相关的设置

    一.设置手机的代理服务器 1.前提:手机与电脑用的是同一个网络 2.fiddler设置允许远程连接,并设置好端口 3.查询电脑所在网络的ip地址(windows下,命令行窗口使用:ipconfig进行 ...

  8. Spring MVC 到 Spring BOOT 的简化之路

    背景 Spring vs Spring MVC vs Spring Boot Spring FrameWork Spring 还能解决什么问题 Spring MVC 为什么需要Spring Boot ...

  9. Java @FunctionalInterface注解-6

    在学习 Lambda 表达式时,我们提到如果接口中只有一个抽象方法(可以包含多个默认方法或多个 static 方法),那么该接口就是函数式接口.@FunctionalInterface 就是用来指定某 ...

  10. 让Github畅通无阻,FastGithub1.0.0发布

    前言 我近半年来被github的抽风虐得没脾气了,虽然我有代理的方式来上网,但代理速度并不理想,而且有时代理服务一起跟着抽风.这时候,我会搜索"github访问不了"相关题材,其中 ...