0x00 简介
培根密码,培根所用的密码是一种本质上用二进制数设计的,没有用通常的0和1来表示,而是采用a和b
培根密码加密有两种方式:
A aaaaa B aaaab C aaaba D aaabb E aabaa F aabab G aabba H aabbb I abaaa J abaab K ababa L ababb M abbaa N abbab O abbba P abbbb Q baaaa R baaab S baaba T baabb U babaa V babab W babba X babbb Y bbaaa Z bbaab
方式二:
a AAAAA g AABBA n ABBAA t BAABA
b AAAAB h AABBB o ABBAB u-v BAABB
c AAABA i-j ABAAA p ABBBA w BABAA
d AAABB k ABAAB q ABBBB x BABAB
e AABAA l ABABA r BAAAA y BABBA
f AABAB m ABABB s BAAAB z BABBB
通常加密者只需要两种不同的字体或使用大小写来代替ab即可,例如明文为bling,加密为:aaaab ababb abaaa abbab aabba,此时再随意找句句子,使用大小写来代替ab。密文如下:good GoOd STuDy day DAy Up hAHa
0x01 解密代码
#! python3
# -*- coding: utf-8 -*-
# @Time : 2017/8/26 上午12:07
# @Author : BlingBling
# @File : Baconian.py
# @Software: PyCharm Community Edition
import re
class Baconian():
alphabet = ['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']
first_cipher = ["aaaaa", "aaaab", "aaaba", "aaabb", "aabaa", "aabab", "aabba", "aabbb", "abaaa", "abaab", "ababa",
"ababb", "abbaa", "abbab", "abbba", "abbbb", "baaaa", "baaab", "baaba", "baabb", "babaa", "babab",
"babba", "babbb", "bbaaa", "bbaab"]
second_cipher = ["aaaaa", "aaaab", "aaaba", "aaabb", "aabaa", "aabab", "aabba", "aabbb", "abaaa", "abaaa", "abaab",
"ababa", "ababb", "abbaa", "abbab", "abbba", "abbbb", "baaaa", "baaab", "baaba", "baabb", "baabb",
"babaa", "babab", "babba", "babbb"]
def __init__(self, str):
self.str = str
def decode(self):
str = self.str.lower()
str_array = re.findall(".{5}", str)
decode_str1 = ""
decode_str2 = ""
for key in str_array:
for i in range(0,26):
if key == Baconian.first_cipher[i]:
decode_str1 += Baconian.alphabet[i]
if key == Baconian.second_cipher[i]:
decode_str2 += Baconian.alphabet[i]
print(decode_str1)
print(decode_str2)
if __name__ == '__main__':
str = input("please input string to decode:\n")
bacon = Baconian(str)
bacon.decode()
总结:
培根密码:base64解码后直接培根解密http://ctf.ssleye.com/baconian.html
Crypto2:RSA小明文攻击,得出输出也就是C后,使用https://xz.aliyun.com/t/6459#toc-34里面的脚本。
MISC2:16进制编辑器打开,逆序答案在内。
Re1 ida 打开搜索字符串 flag,一堆 flag 中间只有一个有引用的,就是正确的。
来源:oschina
链接:https://my.oschina.net/u/4389636/blog/4685520