本文主要是介绍【密文特征分析】加密类型判断,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、代码
import re
import sysimport requestsdef post_url(data):"""其实就是把「https://www.dcode.fr/cipher-identifier」网站的功能,改成接口形式之所以改成接口,是因为网站加载有些慢,很多不必要加载很是浪费时间:param data: 需要判断的密码字符串:return: 网站的返回分析数据"""session = requests.session()# 获取 Cookieurl = "https://www.dcode.fr/cipher-identifier"response = session.get(url)cookie = response.headers['Set-Cookie'].split(";")[0]# 带 Cookie 请求 api 接口url = "https://www.dcode.fr/api/"payload = f"tool=cipher-identifier&ciphertext={data}&clues="headers = {'Cookie': cookie,'Sec-Ch-Ua': '"Microsoft Edge";v="119", "Chromium";v="119", "Not?A_Brand";v="24"','Accept': 'application/json, text/javascript, */*; q=0.01','Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8','X-Requested-With': 'XMLHttpRequest','Sec-Ch-Ua-Mobile': '?0','User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0','Sec-Ch-Ua-Platform': '"macOS"','Origin': 'https://www.dcode.fr','Sec-Fetch-Site': 'same-origin','Sec-Fetch-Mode': 'cors','Sec-Fetch-Dest': 'empty','Referer': 'https://www.dcode.fr/cipher-identifier','Accept-Encoding': 'gzip, deflate','Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6'}response = session.post(url, headers=headers, data=payload).json()return response["results"]def clear_dict(cipher):""" 清理掉HTML标签 """new_dict = {}for key in cipher:new_dict[re.search('<a href=".*?">(.*?)</a>', key).group(1)] = cipher[key]return new_dictdef format_dict(dictionary):""" 字典输出格式化 """max_key_len = max(len(key) for key in dictionary.keys())max_value_len = max(len(value) for value in dictionary.values())for key, value in dictionary.items():key_spaces = ' ' * (max_key_len - len(key))value_spaces = ' ' * (max_value_len - len(value))print(key + key_spaces + ' : ' + value + value_spaces)if __name__ == '__main__':if len(sys.argv) == 2:cipher_dict = post_url(sys.argv[1])else:print("使用说明 : python3 cipher_identifier.py {密文}")exit(1)format_dict(clear_dict(cipher_dict))
2、使用说明
没有什么好说明的,就是 https://www.dcode.fr/cipher-identifier 网站接口,网站加载太慢了,所以我就把接口做成了Python脚本,方便使用,节省时间。
┌──(root㉿kali)-[~] (๑•̀ㅂ•́)و✧
└─# python3 cipher_identifier.py
Usage : python3 cipher_identifier.py {密文}
┌──(root㉿kali)-[~] (๑•̀ㅂ•́)و✧
└─# python3 cipher_identifier.py cf4c2232354952690368f1b3dfdfb24d
MD5 : ■▪
Hexadecimal Data : ■
MD4 : ■
Hexadecimal (Base 16) : ▪
ASCII Code : ▪
Base62 Encoding : ▫
Base64 Coding : ▫
XOR Cipher : ▫
UUID : ▫
Huffman Coding : ▫
LZW Compression : ▫
Circular Bit Shift : ▫
EBCDIC Encoding : ▫
RC4 Cipher : ▫
Substitution Cipher : ▫
Shift Cipher : ▫
Homophonic Cipher : ▫
Turning Grille : ▫
这篇关于【密文特征分析】加密类型判断的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!