55 lines
1.5 KiB
JavaScript
55 lines
1.5 KiB
JavaScript
const fs = require('fs');
|
|
const crypto = require('crypto');
|
|
|
|
const passPath = 'HKEY_CURRENT_USER\\SOFTWARE\\HwaSmart';
|
|
const passValue = 'BDAuthorization';
|
|
|
|
function cryptMD5(GUID) {
|
|
let md5 = crypto.createHash('md5');
|
|
let ciphertext = md5.update(GUID).digest('hex')
|
|
return ciphertext.slice(0,8)+'-'+ciphertext.slice(8,12)+'-'+ciphertext.slice(12,16)+'-'+ciphertext.slice(16,20)+'-'+ciphertext.slice(20,32);
|
|
}
|
|
|
|
fs.readFile('./MachineGuid.txt', 'utf-8', (err, data) => {
|
|
if (err) {
|
|
if (err.code === 'ENOENT') {
|
|
console.error('file not exist');
|
|
return;
|
|
}
|
|
console.error(err, 'open');
|
|
return;
|
|
}
|
|
fs.readFile('./KeyWord.txt', 'utf-8', (error, key) => {
|
|
if (error) {
|
|
if (error.code === 'ENOENT') {
|
|
console.error('file not exist');
|
|
return;
|
|
}
|
|
console.error(error, 'open');
|
|
return;
|
|
}
|
|
console.log(key)
|
|
fs.writeFile('./BDAuthorization.bat',
|
|
`@echo off
|
|
|
|
If Not "%~1"=="H" (
|
|
mshta vbscript:"<script language=vbs>Set UAC=CreateObject(""Shell.Application""):UAC.ShellExecute ""%~s0"", ""H"", """", ""runas"", 1:window,close</script>"
|
|
)
|
|
|
|
reg add ${passPath} /v ${passValue} /t REG_SZ /d ${cryptMD5(data + key)} /f
|
|
|
|
exit`,
|
|
(e) => {
|
|
if(e){
|
|
console.log(`创建失败:${e}`);
|
|
}
|
|
console.log(`创建成功!`);
|
|
});
|
|
fs.writeFile('./MachineGuid.txt', '', (ero) => {
|
|
if(ero){
|
|
console.log(`创建失败:${ero}`);
|
|
}
|
|
console.log(`创建成功!`);
|
|
});
|
|
});
|
|
}); |