@echo off net session >nul 2>&1 if NOT "%errorlevel%"=="0" ( echo THIS SCRIPT IS NOT ADMINISTRATIVE ping -n 2 127.0.0.1 >nul 2>&1 exit ) echo THIS SCRIPT IS ADMINISTRATIVE ping -n 2 127.0.0.1 >nul 2>&1
Showing posts with label admin. Show all posts
Showing posts with label admin. Show all posts
Batch script: check for admin rights
After some extensive research and testing, I have found the most accurate way to check for administrative privileges in batch script is:
Download Google Chrome installer without using a browser
Download and execute Google Chrome installer without a browser:
There are few things more painful than using Internet Explorer on a fresh Windows Server Install. As such, I have created this batch script to install Google Chrome without using Internet Explorer. Enjoy:
To use, simply paste the above into a command prompt and hit enter.
After a few moments while the Google Chrome installer is downloaded, the installation window will pop up and guide you through the rest of the process.
About:
This script is a Batch wrapper for a VBS script which uses the XMLHTTP object to download the Chrome installer from the Internet, the ADODB object to write it to disk, and Shell object to execute it.
For the sake of readability and completeness, here's a plain VBS script that does the same thing (without the Batch script wrapper):
There are few things more painful than using Internet Explorer on a fresh Windows Server Install. As such, I have created this batch script to install Google Chrome without using Internet Explorer. Enjoy:
echo Set o=CreateObject^("MSXML2.XMLHTTP"^):Set a=CreateObject^("ADODB.Stream"^):Set f=Createobject^("Scripting.FileSystemObject"^):o.open "GET", "https://dl.google.com/chrome/install/chrome_installer.exe", 0:o.send^(^):If o.Status=200 Then >"%temp%\d.vbs" &echo a.Open:a.Type=1:a.Write o.ResponseBody:a.Position=0:If f.Fileexists^("%temp%\s.exe"^) Then f.DeleteFile "%temp%\s.exe" >>"%temp%\d.vbs" &echo a.SaveToFile "%temp%\s.exe" >>"%temp%\d.vbs" &echo End if >>"%temp%\d.vbs" &cscript //B "%temp%\d.vbs" &del /F /Q "%temp%\d.vbs" &start "" "%temp%\s.exe"
To use, simply paste the above into a command prompt and hit enter.
After a few moments while the Google Chrome installer is downloaded, the installation window will pop up and guide you through the rest of the process.
![]() |
| Right-click -> Paste, hit enter |
![]() |
| A few seconds later, Google Chrome downloader. |
About:
This script is a Batch wrapper for a VBS script which uses the XMLHTTP object to download the Chrome installer from the Internet, the ADODB object to write it to disk, and Shell object to execute it.
For the sake of readability and completeness, here's a plain VBS script that does the same thing (without the Batch script wrapper):
Set xmlHttp=CreateObject("MSXML2.XMLHTTP")
Set adoStream=CreateObject("ADODB.Stream")
Set fileSys=Createobject("Scripting.FileSystemObject")
Set wsShell=WScript.CreateObject("WScript.Shell")
tmpFile = wsShell.ExpandEnvironmentStrings("%TEMP%\") & Rnd & ".exe"
xmlHttp.open "GET", "https://dl.google.com/chrome/install/chrome_installer.exe", 0
xmlHttp.send()
If xmlHttp.Status=200 Then
adoStream.Open
adoStream.Type=1
adoStream.Write xmlHttp.ResponseBody
adoStream.Position=0
If fileSys.Fileexists(tmpFile) Then
fileSys.DeleteFile tmpFile
End If
adoStream.SaveToFile tmpFile
wsShell.Run tmpFile
End if
To use this one you need to save it as a .vbs file and run it obviously. Which is slightly less convenient than the first one.
Disable Windows Firewall with VBS/Batch script
This is a simple VBS script to disable the specified computers' windows firewall using WMI, requires administrator access.
And if you can do it in VBS, you can do it in batch script!
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name = 'SharedAccess'")
For Each objService in colServiceList
If objService.State = "Running" Then
objService.StopService()
Wscript.Sleep 5000
End If
errReturnCode = objService.ChangeStartMode("Disabled")
Next
And if you can do it in VBS, you can do it in batch script!
Administrator to System privilege escallation
Windows XP. There comes a time in every Windows users life when he wants more. Administrator access isn't enough. He wants to have the same level of access that the System has.
Maybe it's to kill a stubborn process which looks like a virus but actually turns out to be a critical System process, or maybe it's just so they can laugh maniacally.
Whatever the reason, I have created a script to give Administrator users SYSTEM level access to their Windows XP computers:
This script uses the old at.exe trick to escalate your privs but it fills in the parameters automatically, so all you need to do is say what command you want to execute with your system privs.
PS: You DO need administrator access to run this script, so it's useless to most baddies. This is only useful if you want to increase from administrator to system.
Maybe it's to kill a stubborn process which looks like a virus but actually turns out to be a critical System process, or maybe it's just so they can laugh maniacally.
Whatever the reason, I have created a script to give Administrator users SYSTEM level access to their Windows XP computers:
@echo off
echo.
at>nul
if "%errorlevel%"=="1" (
echo You do not have sufficient priviliges to execute this command.
echo You MUST be running as an administrator ^(with access to "at.exe"^).
goto end
)
echo WARNING: This command will be executed with SYSTEM priviliges!
echo.
set /P cmd=Enter command to run (eg,"cmd", "taskmgr"):
set rnd=r%random%n%random%d
echo.|time>%rnd%
set /P time=<%rnd%
del /F /Q %rnd%
for /F "usebackq tokens=5,6,7 delims=:. " %%i in ('%time%') do (
set our=%%i
set min=%%j
set sec=%%k
)
set /A tot=%min%+1
set /A dif=60-%sec%
at %our%:%tot% /interactive %cmd% >nul
if "%errorlevel%"=="0" (
echo The command will be executed in %dif% seconds.
) else (
echo An unknown error has occured.
)
:end
echo Press any key to exit.
pause>nul
Save the code as a .bat file, and run!This script uses the old at.exe trick to escalate your privs but it fills in the parameters automatically, so all you need to do is say what command you want to execute with your system privs.
PS: You DO need administrator access to run this script, so it's useless to most baddies. This is only useful if you want to increase from administrator to system.
Subscribe to:
Posts (Atom)

