import re
import sys
import requests
def post_url(data):
"""
其实就是把「https://www.dcode.fr/cipher-identifier」网站的功能,改成接口形式
之所以改成接口,是因为网站加载有些慢,很多不必要加载很是浪费时间
:param data: 需要判断的密码字符串
:return: 网站的返回分析数据
"""
session = requests.session()
# 获取 Cookie
url = "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('(.*?)', key).group(1)] = cipher[key]
return new_dict
def 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))
没有什么好说明的,就是 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 : ▫