[XDCTF-2017] base64

Posted on 2017, Oct6, Friday 02:12:44 • Tagged with xdctf-2017, ctf-crypto, base64

分析

题目中给出了一个txt,其内容为

bWFpbigpe2ludCBpLG5bXT17KCgoMSA8PDEpPDwgKDE8PDEpPDwoMTw8Cm==
ICAgICAgIDEpPDwoMTw8KDE+PjEpKSkrKCgxPDwxKTw8KDE8PDEpKSksKCgoMQp=
ICAgICAgIDw8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAxKQq=
ICAgICAgIDw8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAoMQp=
ICAgICAgIDw8MSk8PCgxPDwxKTw8ICAgICAgICAgKDE8PDEpKS0oKDE8PDEpPDwoCr==
ICAgIAkxPDwxKTw8KDE8PDEpKSsgICAgICAgICgoMTw8MSk8PCgxPDwoMT4+Ch==
ICAgICAgIDEpKSkrKDE8PCgxPj4xKSkpICAgICAgICAgICAgICAgICAgICAgICAgLAq=
ICAgICAgICgoKDE8PDEpPDwoMTw8MSkgICAgICAgICAgICAgICAgICAgICAgICA8PAo=
ICAgICAgICgxPDwxKTw8KDE8PDEpKS0oKDEgPDwxKTw8KDE8PDEpIDw8KDE8PCgxCl==
ICAgICAgID4+MSkpKS0oKDE8PDEpPDwoMTw8KDE+PjEpKSkpLCgoKDE8PDEpCp==
ICAgICAgIDw8KCAgICAxPDwgICAgICAgICAgICAgICAgICAgICAgICAgIDEpCt==
ICAgICAgIDw8KCAgICAxPDwgICAgICAgICAgICAgICAgICAgICAgICAgIDEpCu==
ICAgICAgIDw8KCAxPDwxKSktKCgxIDw8MSk8PCAoMSA8PDEpPDwoMSA8PAr=
ICAgICAgICgxPj4xKSkpLSgoMTw8MSk8PCgxPDwoMT4+MSkpKSksKCgoMTw8MSk8PAo=
ICAgICAgICgxPDwxKTw8KDE8PDEpPDwoMTw8MSkpLSgoMTw8MSk8PCgxPDwxKTw8KAr=
ICAgICAgIDE8PCgxPj4xKSkpLSgxPDwoMT4+ICAgICAgICAgIDEpKSksKCgoMTw8MSk8PAq=
ICAgICAgICgxPDwxKTw8KDE8PDEpKSsgICAgKCgxPDwxKSAgICA8PCgxPDwxKTw8Ch==
ICAgICAgICgxPDwoMT4+MSkpKS0oKCAgICAgMTw8MSk8PCggICAgICAxPDwoMT4+Co==
ICAgICAgIDEpKSkpLCgoMTw8MSk8PCAgICAgICgxPDwxKSAgICAgICAgPDwoMTw8MSkpCl …

Continue reading

base64详解

Posted on 2017, Oct5, Thursday 20:47:02 • Tagged with base64

原理

众所周知,任何数据在内存中都是以Byte为单位进行存储的,每个Byte包含了8个二进制位,因此本文不区分二进制数据与文本,而是将其作为一个整体进行讨论。

编码

base64编码包括以下几个步骤

  1. 将每个BYTE转为8位二进制
  2. 若二进制位不是6的倍数则在其后面补0直到其变为6的倍数
  3. 将每6个二进制位作为整体转换为10进制
  4. 通过查表将十进制转为字符
  5. 若转出的长度不为4的倍数,则在其后补’=’

注: 转换表见附录

若是以编码 CNSS 为例,则整个过程为

解码

base64解码包括以下几个步骤

  1. 将除了 = 以外的别的字符通过查表转为十进制数字
  2. 将十进制数字转为6位二进制
  3. 删去等号个数*2位二进制
  4. 将二进制转为BYTE

黑魔法:base64隐写 …


Continue reading