《CTF特训营》学习笔记-Crypto

19章 编码

19.1 hex

PyCrypto库处理hex

from Crypto.Util.number import long_to_bytes,bytes_to_long
flag="flag{123}".encode()
a=bytes_to_long(flag)
print (a)
print (long_to_bytes(a).decode())

19.2 urlencode

特征:用于浏览器和网站之间的数据交换,主要解决一些特殊字符在传输过程中造成的问题。
运算法则:在特殊字符hex的基础上,每个字符前加%。%xx三个字符对应一个明文字符。
urllib库
quote对字符串进行url编码,urlencode对字典模式的键值对进行url编码

from urllib.parse import quote,urlencode
flag="flag{url_encode_1234_!@#$}"
print (quote(flag))
d={'name':'bibi@flappypig.club','flag':flag}
print (urlencode(d))

19.3 morsecode

在线解码工具:

  1. https://www.atool99.com/morse.php
  2. 待补 共4个
    音频编辑工具:
  3. Cool Edit

19.4 jsfuck

特征:()+[]!六个字符写JavaScript
在线解码:

  1. https://jsfuck.com/
  2. https://utf-8.jp/public/jsfuck.html

19.5 uuencode

二进制文件转化为可见字符文本文件,转换后的文件可通过纯文本的email传输。
特征:可见字符取值[32,95],无小写字母
运算法则:将连续的3字节扩展成4字节。编码效率高于hex。
在线解码:https://www.qqxiuzi.cn/bianma/uuencode.php

19.6 base

将特殊字符和不可见字符转换为常见字符,用于网络传输
特征:编码最后有补位=,或者编码中字母属于base相应字符集

编码方式 字符集 备注
base64 a-z,A-Z,0-9,+,,= 有小写字母
base32 A-Z,2-7,= 无小写字母和01
base16 0-9,A-F,= 字母只含A-F
import base64
def b64e(s):
    return base64.b64encode(s.encode()).decode()
def b64d(s):
    return base64.b64decode(s).decode()

base64原理示例:

20章 古典密码

TBC

posted @ 2023-06-07 23:35  better?  阅读(143)  评论(0)    收藏  举报