Decrypt-the-Message

题目信息:

解密这段信息!

附件:
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

涉及知识点:

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

附件:

#poemcode.py
#参考:https://github.com/abpolym/crypto-tools/tree/master/poemcode
import sys
import itertools
from os import listdir
from os.path import isfile, join abc = 'abcdefghijklmnopqrstuvwxyz' def loadlist(infile):
tlist = []
for line in open(infile, 'r'):
for w in line.split():
tlist.append(w.lower())
return tlist def decrypt(poem, cip):
# Load all words of the poem into a temporary list
twords = loadlist(poem) # Load all cipher chunks of the ciphertext into a list
cwords = loadlist(cip) # Get the code rom the first chunk and remove it from the ciphertext list
code = []
for i in cwords.pop(0):
code.append(abc.index(i)) # Select only those words specified in the code in a new multi-arrayed list
xwords = [[] for x in range(len(code))]
for xcount, c in enumerate(code):
tlen = c
while(c < len(twords)):
xwords[xcount].append(twords[c].lower())
c += 26 # Get all possible combinations
for comb in itertools.product(*xwords):
pwords = ''
for c in comb:
pwords += c
plen = len(pwords) # Rearrange the chunks according to the key
pcode = [None] * plen
count = 0
while(count < plen):
for al in abc:
for pc, pl in enumerate(pwords):
if al != pl:
continue
pcode[count] = cwords[pc]
count += 1 # Decrypt the ciphertext
msg = ''
wlen = len(pcode[0])
for c in range(0, wlen):
for word in pcode:
msg += word[c]
print(msg) 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. Python+Selenium学习笔记14 - python官网的tutorial - just() fill() format()

    repr(x).rjust(n)  左侧空格填充,右侧列对齐,str()和repr()是一种输出,也可不用,直接x.rjust() repr(x).ljust(n)  右侧空格填充,左侧列对齐 rep ...

  2. Unity3d_2018_2019_2020安装包

    网上各种注册,官网登陆这么麻烦,留着自用 链接:https://pan.baidu.com/s/1LBtMetnr9xkOa18xYiFoDA 提取码:o01t 链接:https://pan.baid ...

  3. 在NVIDIA A100 GPU中使用DALI和新的硬件JPEG解码器快速加载数据

    在NVIDIA A100 GPU中使用DALI和新的硬件JPEG解码器快速加载数据 如今,最流行的拍照设备智能手机可以捕获高达4K UHD的图像(3840×2160图像),原始数据超过25 MB.即使 ...

  4. 用华为MindSpore进行分布式训练

    技术背景 分布式和并行计算,在计算机领域是非常重要的概念.对于一些行外人来说,总觉得这是一些很简单的工作,但是如果我们纵观计算机的硬件发展史,从CPU到GPU,再到TPU和华为的昇腾(NPU),乃至当 ...

  5. 重新整理 .net core 实践篇—————日志系统之结构化[十八]

    前言 什么是结构化呢? 结构化,就是将原本没有规律的东西进行有规律话. 就比如我们学习数据结构,需要学习排序然后又要学习查询,说白了这就是一套,没有排序,谈如何查询是没有意义的,因为查询算法就是根据某 ...

  6. oracle表ddl审计

    ============= 表ddl 审计============== 1.table信息 SQL> select * from test; ID CUST_CREDIT_LIMIT TIME ...

  7. 工作流中容器化的依赖注入!Activiti集成CDI实现工作流的可配置型和可扩展型

    Activiti工作流集成CDI简介 activiti-cdi模块提供activiti的可配置型和cdi扩展 activiti-cdi的特性: 支持 @BusinessProcessScoped be ...

  8. 给小米路由R1D增加WebDAV服务

    我的R1D是14年买的,原装的硬盘已经不能用了,换了一块从笔记本上退役下来的500G硬盘后继续愉快的使用了-- 当初买这款路由器的原因之一是看中了它的内置硬盘,可以用来备份手机相册.存储智能摄像机录像 ...

  9. DG duplicate报错:RMAN-05001:auxiliary file name /u01/app/oracle/oradata/fratbs01.dbf conflicts with a file used by the target database

    问题:rman duplicate时报错: RMAN-05001:auxiliary file name /u01/app/oracle/oradata/fratbs01.dbf conflicts ...

  10. Jenkins 构建自动化 .NET Core 发布镜像

    Jenkins 构建自动化 .NET Core 发布镜像 导读 在本章中,将介绍如何在 Linux 下使用 Docker 部署.启动 Jenkins,编写脚本,自动化构建 .NET Core 应用,最 ...