C:Users用户名AppDataRoamingMicrosoftInputMethodChs
%USERPROFILE%AppDataRoamingMicrosoftInputMethodChs
是 Windows 系统中用于存储微软拼音输入法相关数据的文件夹
两个是ChsPinyinIH.dat和ChsPinyinUDL.dat
ChsPinyinIH.dat
该文件通常存储微软拼音输入法的
输入历史记录
它记录了用户输入过的词汇、短语等信息,以便输入法能够根据用户习惯提供更准确的联想和预测
ChsPinyinUDL.dat
该文件通常存储微软拼音输入法的
用户自定义词典
这两个是用户下的两个dat,这里面会记录用户长期输入的文字,需要通过代码编写进行解码,尝试使用 GBK 或 UTF-16 解码
因为要显示中文,所以这是我们需要的
通过读取后,我们得到这里面的常用词汇,成果如下
还有更多,甚至你长期敲的字都在这里面,需要把ChsPinyinUDL.dat给解密出来,这里解密的肯定不多,只有几个汉字
所以还要配合着ChsPinyinIH.dat来配合查看
我们找了一位长期使用微软输入法的人进行测试(常见的在windows server上都是默认微软输入法)
发现解密出9.4k大小的东西
像他常用的云服务器厂商观星云
玩偶姐姐?
还有一些人名地名事件等等
解密代码如下:
import sys
import os
import platform
import pypinyin
defstr2sysstr(strout):
sysstr = platform.system()
if (sysstr == "Windows"):
return strout.encode("gbk")
else:
return strout.encode("utf-8")
if __name__ == '__main__':
iflen(sys.argv) == 2:
user_word_file = sys.argv[1]
else:
user_word_file = os.environ['USERPROFILE'] + "AppDataRoamingMicrosoftInputMethodChsChsPinyinUDL.dat"
ifnot os.path.exists(user_word_file):
print("file:", user_word_file, "not existnn")
print("use example")
print("user_word_exporter.exe")
print(" : paser %USERPROFILE%AppDataRoamingMicrosoftInputMethodChsChsPinyinUDL.dat")
print("user_word_exporter.exe dat_file_name")
print(" : paser dat_file_name")
sys.exit(1)
fp = open(user_word_file, "rb")
userword = open("user_word_microsoft_pinyin.txt", "at")
data = fp.read()
cnt = int.from_bytes(data[12:16], byteorder='little', signed=False)
user_word_base = 0x2400
for i inrange(cnt):
cur_idx = user_word_base + i * 60
word_len = int.from_bytes(data[cur_idx + 10:cur_idx + 11], byteorder='little', signed=False)
word = data[cur_idx + 12: cur_idx + 12 + word_len * 2].decode("utf-16")
pinyin_str = 't'
pinyin_list = pypinyin.pinyin(word, style=pypinyin.NORMAL)
for i, py inenumerate(pinyin_list):
pinyin_str += py[0]
if i + 1 != word_len:
pinyin_str += ' '
one_line = word + pinyin_str + 't1'
print(word + pinyin_str + 't1')
userword.write(one_line + "n")
fp.close()
userword.close()
原文始发于微信公众号(秋风的安全之路):微软输入法自学习取证
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论