Познакомьтесь с пентестом веб-приложений на практике в нашем новом бесплатном курсе
set KEY_REGKEY=HKLM\SOFTWARE\Microsoft\Cryptography
set KEY_REGVAL=MachineGuid
REM Check for presence of key first.
reg query %KEY_REGKEY% /v %KEY_REGVAL% 2>nul || (echo No theme name present! & exit /b 1)
REM query the value. pipe it through findstr in order to find the matching line that has the value. only grab token 3 and the remainder of the line. %%b is what we are interested in here.
set KEY_NAME=
for /f "tokens=2,*" %%a in ('reg query %KEY_REGKEY% /v %KEY_REGVAL% ^| findstr %KEY_REGVAL%') do (
set KEY_NAME=%%b
)
echo %KEY_NAME%
Set objNet = CreateObject("WScript.Network")
strComputer = objNet.ComputerName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
("Select * From Win32_UserAccount Where Domain = '" & strComputer & "'")
For Each objAccount in colAccounts
If Left (objAccount.SID, 6) = "S-1-5-" and Right(objAccount.SID, 4) = "-500" Then
Wscript.Echo objAccount.Name
Wscript.Echo objAccount.SID
WScript.Echo "Computer's SID: " & Left(objAccount.SID, Len(objAccount.SID) - 4)
End If
Next
как это использовать?Код:strComputer = "youcomputername" Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") Set colAccounts = objWMIService.ExecQuery _ ("Select * From Win32_UserAccount Where Domain = '" & strComputer & "'") For Each objAccount in colAccounts If Left (objAccount.SID, 6) = "S-1-5-" and Right(objAccount.SID, 4) = "-500" Then Wscript.Echo objAccount.Name Wscript.Echo objAccount.SID WScript.Echo "Computer's SID: " & Left(objAccount.SID, Len(objAccount.SID) - 4) End If Next
можно както output в файлик записать?2 - vbs - сохраняем в файл с расширение vbs и запускаем
Dim fso
Set fso = WScript.CreateObject("Scripting.Filesystemobject")
Set f = fso.OpenTextFile("C:\Users\Administrator\Desktop\sid\output.txt", 2)
Set objNet = CreateObject("WScript.Network")
strComputer = objNet.ComputerName
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colAccounts = objWMIService.ExecQuery _
("Select * From Win32_UserAccount Where Domain = '" & strComputer & "'")
For Each objAccount in colAccounts
If Left (objAccount.SID, 6) = "S-1-5-" and Right(objAccount.SID, 4) = "-500" Then
f.WriteLine objAccount.Name
f.WriteLine objAccount.SID
f.WriteLine "Computer's SID: " & Left(objAccount.SID, Len(objAccount.SID) - 4)
End If
Next
f.Close
Administrator
S-1-5-21-538003744-2869898636-1843681998-500
Computer's SID: S-1-5-21-538003744-2869898636-1843681998
set KEY_REGKEY=HKLM\SOFTWARE\Microsoft\Cryptography
set KEY_REGVAL=MachineGuid
reg query %KEY_REGKEY% /v %KEY_REGVAL% 2>nul || (echo No theme name present! & exit /b 1)
set KEY_NAME=
for /f "tokens=2,*" %%a in ('reg query %KEY_REGKEY% /v %KEY_REGVAL% ^| findstr %KEY_REGVAL%') do (
set KEY_NAME=%%b
)
echo %KEY_NAME% >%USERPROFILE%\Desktop\sid.txt
ругается на VBSНа этот не должен ругаться
Код:set KEY_REGKEY=HKLM\SOFTWARE\Microsoft\Cryptography set KEY_REGVAL=MachineGuid reg query %KEY_REGKEY% /v %KEY_REGVAL% 2>nul || (echo No theme name present! & exit /b 1) set KEY_NAME= for /f "tokens=2,*" %%a in ('reg query %KEY_REGKEY% /v %KEY_REGVAL% ^| findstr %KEY_REGVAL%') do ( set KEY_NAME=%%b ) echo %KEY_NAME% >%USERPROFILE%\Desktop\sid.txt
S-1-5-21-538003744-2869898636-1843681998-500
Computer's SID: S-1-5-21-538003744-2869898636-1843681998
@echo off &setlocal
set "RegPath=HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList"
for /f "delims=" %%i in ('reg query "%RegPath%"^|findstr /ibc:"%RegPath%\S-"') do (
reg query "%%i" /v "ProfileImagePath"|findstr /iec:"%UserProfile%" >nul &&set "SID=%%~nxi"
)
echo %SID% >%USERPROFILE%\Desktop\sid.txt
@echo off
for /f "delims=" %%i in ('wmic useraccount where "name='%UserName%'" get sid /value') do (
for /f "delims=" %%j in ("%%i") do set "%%j"
)
echo %SID% >%USERPROFILE%\Desktop\sid.txt
Код:@echo off &setlocal set "RegPath=HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\ProfileList" for /f "delims=" %%i in ('reg query "%RegPath%"^|findstr /ibc:"%RegPath%\S-"') do ( reg query "%%i" /v "ProfileImagePath"|findstr /iec:"%UserProfile%" >nul &&set "SID=%%~nxi" ) echo %SID% >%USERPROFILE%\Desktop\sid.txt
Обучение наступательной кибербезопасности в игровой форме. Начать игру!