当我尝试使用简单程序来转换battoexe.exe
并运行它时,它并不像我直接从批处理文件运行那样运行.......bat
.exe
我的批处理脚本代码是这样的:
@echo off
:: BatchGotAdmin
:-------------------------------------
REM --> Check for permissions
>nul 2>&1 "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\config\system"
REM --> If error flag set, we do not have admin.
if '%errorlevel%' NEQ '0' (
goto UACPrompt
) else ( goto gotAdmin )
:UACPrompt
echo Set UAC = CreateObject^("Shell.Application"^) > "%temp%\getadmin.vbs"
set params = %*:"=""
echo UAC.ShellExecute "cmd.exe", "/c %~s0 %params%", "", "runas", 1 >> "%temp%\getadmin.vbs"
"%temp%\getadmin.vbs"
del "%temp%\getadmin.vbs"
exit /B
:gotAdmin
pushd "%CD%"
CD /D "%~dp0"
:--------------------------------------
net user administrator /active:yes
pause
如果我运行批处理文件,它实际上会启用管理员帐户,但是如果我将其作为文件运行.exe
,则此脚本中的任何代码都无法运行...
我该如何让它工作或者是否有一个好的程序可以做到这一点?
答案1
只需尝试使用此批处理文件,certutil
通过将文件拖放到该批处理文件中,使用命令实用程序用 base64 对您的文件进行编码:
@echo off
Title Encoding Batch Files With CERTUTIL Utility by Hackoo 2017
color 0A & Mode 80,5
If "%~1"=="" (
color 0C & Mode 80,3
echo(
echo You should drag and drop a file over this batch script to be encoded !
Timeout /T 5 /nobreak>nul & exit /b
)
@for /f %%i in ("certutil.exe") do if not exist "%%~$path:i" (
echo CertUtil.exe not found.
pause
exit /b
)
>"temp.~b64" echo(//4mY2xzDQo=
set "BOM_File=%~n1"
certutil.exe -f -decode "temp.~b64" "%BOM_File%"
del "temp.~b64"
@Copy "%BOM_File%" /b + "%~1" /b >nul 2>&1
set "TempFile=%Temp%\Temp_b64
set "OutputFile=%BOM_File%_encoded%~x0"
If exist "%OutputFile%" Del "%OutputFile%" >nul 2>&1
echo(
certutil.exe -f -encode "%BOM_File%" "%TempFile%"
(
echo @echo off
echo Title Execution of "%~nx1" by Hackoo 2017
echo CERTUTIL -f -decode "%%~f0" "%%Temp%%\%~nx1" ^>nul 2^>^&1
echo Start "" "%%Temp%%\%~nx1"
echo Exit
)> "%OutputFile%"
@Copy "%OutputFile%" /b + "%TempFile%" /b >nul 2>&1
If exist "%TempFile%" Del "%TempFile%" >nul 2>&1
If exist "%BOM_File%" Del "%BOM_File%" >nul 2>&1
Timeout /T 2 /NoBreak>nul