mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-11 20:21:03 +00:00
Update security.js
This commit is contained in:
parent
2cd457dc22
commit
47f5b9857a
|
@ -1,50 +1,51 @@
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// Security API
|
||||
// Security Policy API
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
var SYS = require("lib/system");
|
||||
var FILE = require("lib/file");
|
||||
var REG = require("lib/registry");
|
||||
var WSH = CreateObject("WScript.Shell");
|
||||
|
||||
exports.VERSIONINFO = "Security Lib (security.js) version 0.1";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
var DISABLED = 0x00000001;
|
||||
var ENABLED = 0x00000000;
|
||||
|
||||
exports.DISABLED = 0x00000001;
|
||||
exports.ENABLED = 0x00000000;
|
||||
function __BOOL_TO_DWORD__(x) {
|
||||
return x ? DISABLED : ENABLED;
|
||||
}
|
||||
|
||||
// check 'run as administrator'
|
||||
exports.isElevated = function() {
|
||||
// Check 'Run as administrator'
|
||||
function isElevated = function() {
|
||||
try {
|
||||
WSH.RegRead("HKEY_USERS\\s-1-5-19\\");
|
||||
CreateObject("WScript.Shell").RegRead("HKEY_USERS\\s-1-5-19\\");
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// turn on/off Windows Defender
|
||||
exports.setAntiSpyware = function(buffer) {
|
||||
// Turn on/off Windows Defender
|
||||
function setDisableAntiSpyware(x) {
|
||||
var path = "SOFTWARE\\Policies\\Microsoft\\Windows Defender";
|
||||
var key = "DisableAntiSpyware";
|
||||
REG.write(REG.HKLM, path, key, buffer, REG.DWORD);
|
||||
REG.write(REG.HKLM, path, key, __BOOL_TO_DWORD__(x), REG.DWORD);
|
||||
};
|
||||
|
||||
// trun on/off Registry Editor (regedit)
|
||||
exports.setRegedit = function(buffer) {
|
||||
// Trun on/off Registry Editor (regedit)
|
||||
function setDisableRegistryTools(x) {
|
||||
var path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
|
||||
var key = "DisableRegistryTools";
|
||||
REG.write(REG.HKLM, path, key, buffer, REG.DWORD);
|
||||
};
|
||||
REG.write(REG.HKLM, path, key, __BOOL_TO_DWORD__(x), REG.DWORD);
|
||||
}
|
||||
|
||||
// turn on/off Task Manager (taskmgr)
|
||||
exports.setTaskmgr = function(buffer) {
|
||||
// Turn on/off Task Manager (taskmgr)
|
||||
function setDisableTaskMgr(x) {
|
||||
var path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System";
|
||||
var key = "DisableTaskMgr";
|
||||
REG.write(REG.HKLM, path, key, buffer, REG.DWORD);
|
||||
};
|
||||
REG.write(REG.HKLM, path, key, __BOOL_TO_DWORD__(x), REG.DWORD);
|
||||
}
|
||||
|
||||
// detect antivirus from security center
|
||||
exports.detectAntivirus = function() {
|
||||
// Get antivirus products list from the security center
|
||||
function getAntiVirusProducts() {
|
||||
var displayNames = [];
|
||||
|
||||
var objWMIService = GetObject("winmgmts:\\.\root\SecurityCenter2");
|
||||
|
@ -56,4 +57,27 @@ exports.detectAntivirus = function() {
|
|||
}
|
||||
|
||||
return displayNames;
|
||||
};
|
||||
}
|
||||
|
||||
// Open the threat setting window on Windows Defender
|
||||
function OpenThreatSettings() {
|
||||
var FN_MSASCui = SYS.getEnvString("%ProgramFiles%") + "\\Windows Defender\\MSASCui.exe";
|
||||
if (!FILE.fileExists(FN_MSASCui)) {
|
||||
SHELL.runAs(FN_MSASCui); // old Windows Defender
|
||||
} else {
|
||||
SHELL.runAs("windowsdefender://Threatsettings");
|
||||
}
|
||||
}
|
||||
|
||||
exports.DISABLED = DISABLED;
|
||||
exports.ENABLED = ENABLED;
|
||||
exports.setDisableAntiSpyware = setDisableAntiSpyware;
|
||||
exports.setDisableRegistryTools = setDisableRegistryTools;
|
||||
exports.setDisableTaskMgr = setDisableTaskMgr;
|
||||
exports.getAntiVirusProducts = getAntiVirusProducts;
|
||||
exports.OpenThreatSettings = OpenThreatSettings;
|
||||
|
||||
exports.VERSIONINFO = "Security Policy Module (security.js) version 0.2";
|
||||
exports.AUTHOR = "catswords@protonmail.com";
|
||||
exports.global = global;
|
||||
exports.require = global.require;
|
||||
|
|
Loading…
Reference in New Issue
Block a user