正常的图片软件无法开,加密方式为异或加密,但是加密值每个人都不同,需要计算。
可以通过在线解码百度搜索【源代码设计笔记】直接查看dat文件。
至此,微信dat文件还原成为图片也就结束了。
//修改图片
//修改图片
let fs = require('fs');
let path = require('path');
let async = require('async');
//值是多少自己算。
let base = 0xFF;
let next = 0xD8;
let gifA = 0x47;
let gifB = 0x49;
let pngA = 0x89;
let pngB = 0x50;
let scanDir = 'd:/ttt/load/';
let imgDir = 'd:/ttt/load1/';
let files = fs.readdirSync(scanDir);
var arr = [];
files.forEach(function(item){
if(path.extname(item) == '.dat'){
arr.push(item);
}
})
async.mapLimit(arr,50,function(item,cb){
convert(item,cb);
},function(){
process.exit(0);
})
//convert
function convert(item,cb){
let absPath =path.join(scanDir,item);
let imgPath = path.join(imgDir,item+'.jpg');
fs.readFile(absPath,(err,content)=>{
if(err){
console.log(err);
cb(err);
}
let firstV = content[0],
nextV = content[1],
jT = firstV ^ base,
jB = nextV ^ next,
gT = firstV ^ gifA,
gB = nextV ^ gifB,
pT = firstV ^ pngA,
pB = nextV ^ pngB;
var v = firstV ^ base;
if(jT == jB){
v = jT;
}else if(gT == gB){
v = gT;
}else if(pT == pB){
v = pT;
}
let bb = content.map(br=>{
return br ^ v
})
fs.writeFileSync(imgPath,bb)
cb(null);
})
}
转载请注明出处: http://sdxlp.cn/article/dat.html