bit4woo / gui_burp_extender_para_encrypter Goto Github PK
View Code? Open in Web Editor NEWBurp_Extender_para_encrypter
Burp_Extender_para_encrypter
AES加解密的程序写的有个问题,没有自动对16位对齐,下面是16位对齐,支持中英文版的python程序:
`#coding:utf-8
'''
pthon3 aes1.py
AES Key String: 0102030405060708
AES IV String: 0102030405060708
AES Mode: AES/CBC/PKCS7PADDING
'''
import base64
from binascii import b2a_hex,a2b_hex
from Crypto.Cipher import AES #注:python3 安装 Crypto 是 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple pycryptodome
def pkcs7padding(text):
"""
明文使用PKCS7填充
最终调用AES加密方法时,传入的是一个byte数组,要求是16的整数倍,因此需要对明文进行处理
:param text: 待加密内容(明文)
:return:
"""
bs = AES.block_size # 16
length = len(text)
bytes_length = len(bytes(text,encoding='utf-8'))
# tips:utf-8编码时,英文占1个byte,而中文占3个byte
padding_size = length if(bytes_length == length) else bytes_length
padding = bs - padding_size % bs
# tips:chr(padding)看与其它语言的约定,有的会使用'\0'
padding_text = chr(padding) * padding
return text + padding_text
def pkcs7unpadding(text):
"""
处理使用PKCS7填充过的数据
:param text: 解密后的字符串
:return:
"""
try:
length = len(text)
unpadding = ord(text[length-1])
return text[0:length-unpadding]
except Exception as e:
pass
def aes_encode(key,iv,content):
"""
AES加密
key,iv使用同一个
模式cbc
填充pkcs7
:param key: 密钥
:param content: 加密内容
:return:
"""
key_bytes = bytes(key,encoding='utf-8')
iv_bytes = bytes(iv,encoding='utf-8')
iv = iv_bytes
cipher = AES.new(key_bytes,AES.MODE_CBC,iv)
# 处理明文
content_padding = pkcs7padding(content)
# 加密
aes_encode_bytes = cipher.encrypt(bytes(content_padding,encoding='utf-8'))
# 重新编码
result = str(base64.b64encode(aes_encode_bytes),encoding='utf-8')
#result=str(bytes.hex(aes_encode_bytes))
return result
def aes_decode(key,iv,content):
"""
AES解密
key,iv使用同一个
模式cbc
去填充pkcs7
:param key:
:param content:
:return:
"""
try:
key_bytes = bytes(key,encoding='utf-8')
#iv_bytes = bytes(iv,encoding='utf-8')
#iv = iv_bytes
cipher = AES.new(key_bytes,AES.MODE_CBC,iv)
# base64解码
aes_encode_bytes = base64.b64decode(content)
#aes_encode_bytes=a2b_hex(content)
# 解密
aes_decode_bytes = cipher.decrypt(aes_encode_bytes)
# 重新编码
result = str(aes_decode_bytes,encoding='utf-8')
# 去除填充内容
result = pkcs7unpadding(result)
return result
except Exception as e:
print(e)
pass
key = '{g;$9~l[de]}wSZ9'
key_iv = '$Sz>&*lZFsZ?:P#9'
data = 'test'
mi="PKVhuJXjpYaanmqbOZIUGw=="
#mi = aes_encode(key,key_iv,data)
#imi=mi.upper()
print("[*]加密结果:\n"+mi)
print("[*]解密结果:\n"+aes_decode(key,key_iv,mi))
`
AES/CBC/PKCS5Padding
4oMdph+WhlHALjvZ4BBuTQ==
key = This is the super secret key 123
iv=0
解密此数据提示 java.security.InvalidKeyException: Illegal key size
另外可以考虑支持RC4 DES 的解密 以及加密后的十六进制显示的问题
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.