1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| 'use strict'; var exec = require('child_process').exec; var path = require("path") ; var fs = require("fs") ; var filePath = path.resolve("C:/Windows/System32/Macromed/Flash/Flash.ocx");
fs.open(filePath, 'r', function (error, fd) { var i = 0, j = 0; if (error) { console.log("\u001b[31m打开文件错误!没有找到文件或者没有权限,可能已经安装了移除Flash的系统更新\u001b[0m"); process.exit(); } let size = fs.statSync(filePath).size; let buf = Buffer.alloc(size); fs.read(fd, buf, 0, size, 0, function (error, data, buffer) { console.log("\u001b[37m文件路径:" + filePath + "\u001b[0m"); console.log("\u001b[37m文件长度:" + buffer.length + "\u001b[0m") ;
var sourceBytes = [0x00, 0x00, 0x40, 0x46, 0x3E, 0x6F, 0x77, 0x42]; var isFound = false; try { for (i = 0; i < buffer.length - 8 && !isFound; i++) { for (j = 0; j < sourceBytes.length; j++) { if (buffer[i+j] != sourceBytes[j]) break; if (buffer[i+j] == sourceBytes[j] && j == sourceBytes.length - 1) isFound = true; } } } catch (err) { console.log("越界!位置:" + (i+j)); throw(err); }
if (i == size - 8) { console.error("\u001b[31m文件找到了,但是没找到定时自毁的代码!或者已经修改过!\u001b[0m"); } else { console.log("\u001b[37m已找到定时自毁的代码:" + (--i) + "\u001b[0m"); buffer[i+7] = 0x72; fs.close(fd, function () { fs.writeFile(filePath, buffer, {encoding: "ascii"}, function (err) { if (err) { console.log("\u001b[31m写入失败!错误信息:" + err + "\u001b[0m"); } else { console.log("\u001b[32m" + "写入成功!已去除自毁定时器,现在可以使用AX版Flash了。" + "\u001b[0m"); } }); }); } }); });
|