Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
87owo authored Jun 15, 2024
1 parent 4591600 commit 0173567
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
22 changes: 12 additions & 10 deletions Driver/Install_Driver.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ setlocal
:: Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"

if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto gotAdmin)
if %errorlevel% NEQ 0 goto NoAdmin
goto gotAdmin

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0""", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
:NoAdmin
echo You do not have administrator rights, please run this script as administrator.
pause
exit /B

:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"

set "script_dir=%~dp0"
set "script_dir=%script_dir:~0,-1%"

set script_dir=%~dp0
set script_dir=%script_dir:~0,-1%
bcdedit -debug on
bcdedit /deletevalue {current} safeboot
bcdedit /set testsigning on
bcdedit /deletevalue {current} safeboot

powershell.exe -ExecutionPolicy Bypass -Command ^
"$endDate = (Get-Date).AddYears(100); ^
$cert = New-SelfSignedCertificate -DnsName PYAS -CertStoreLocation cert:\LocalMachine\My -Type CodeSigning -NotAfter $endDate; ^
$pwd = ConvertTo-SecureString -String 'PYAS' -Force -AsPlainText; ^
Export-PfxCertificate -Cert $cert -FilePath '%script_dir%\PYAS.pfx' -Password $pwd;"
"%script_dir%\signtool.exe" sign /f "%script_dir%\PYAS.pfx" /p PYAS "%script_dir%\PYAS_Driver.sys"
sc create PYAS_Driver type= kernel start= demand binPath= "%script_dir%\PYAS_Driver.sys"
shutdown -r -t 0

shutdown -r -t 0
endlocal
15 changes: 8 additions & 7 deletions Driver/Uninstall_Driver.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,22 @@ setlocal
:: Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\icacls.exe" "%SYSTEMROOT%\system32\config\system"

if '%errorlevel%' NEQ '0' (goto UACPrompt) else (goto gotAdmin)
if %errorlevel% NEQ 0 goto NoAdmin
goto gotAdmin

:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
echo UAC.ShellExecute "cmd.exe", "/c ""%~s0""", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
:NoAdmin
echo You do not have administrator rights, please run this script as administrator.
pause
exit /B

:gotAdmin
if exist "%temp%\getadmin.vbs" ( del "%temp%\getadmin.vbs" )
if exist "%temp%\getadmin.vbs" del "%temp%\getadmin.vbs"

sc stop PYAS_Driver
sc delete PYAS_Driver

bcdedit /set testsigning off
bcdedit -debug off
shutdown -r -t 0

shutdown -r -t 0
endlocal

0 comments on commit 0173567

Please sign in to comment.