net user saferun_user Passw0rd /add
PS C:\> Get-ApplockerFileInformation -Directory 'C:\Program Files (x86)\Adobe\' -Recurse -FileType Exe | New-ApplockerPolicy -RuleType Publisher -User SafeRun_user -RuleNamePrefix Adobe -Optimize -Xml > Adoby.xml
PS C:\> Set-AppLockerPolicy –XmlPolicy Adoby.xml
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Parental Controls\Users\UID\App Restrictions
net localgroup users saferun_user /delete
icacls %USERPROFILE% /deny saferun_user:(OI)(IO)(WDAC,WO,X)
C:\Users\Golovanov>runas /user: saferun_user cmd.exe
Enter the password for saferun_user:
Attempting to start cmd.exe as user “saferun_user" ...
C:\Windows\system32> cd %temp%
C:\Users\saferun_user\AppData\Local\Temp>%windir%notepad.exe
C:\Users\saferun_user\AppData\Local\Temp>copy c:\windows\notepad.exe .
1 file(s) copied.
C:\Users\saferun_user\AppData\Local\Temp>.\notepad.exe
Access is denied.
xcopy /E /I /C /Y /Q /H /R %APPDATA%\Mozilla\* C:\Users\saferun_user\AppData\Roaming\Mozilla\
Option explicit
Dim oShell
set oShell= Wscript.CreateObject("WScript.Shell")
oShell.Run "RunAs /noprofile /user:saferun_user Firefox.exe"
WScript.Sleep 1000
oShell.Sendkeys "Passw0rd"
oShell.Sendkeys "{ENTER}"
Wscript.Quit
Set oWS = WScript.CreateObject("WScript.Shell")
sLinkFile = "C:\firefox_saferun.LNK"
Set oLink = oWS.CreateShortcut(sLinkFile)
oLink.TargetPath = "C:\Program Files (x86)\Mozilla Firefox\firefox.vbs"
oLink.IconLocation = "C:\Program Files (x86)\Mozilla Firefox\firefox.exe,0"
oLink.WorkingDirectory = "C:\Program Files (x86)\Mozilla Firefox\"
oLink.Save
::Writed by: Sergey.Golovanov at kaspersky.com for habrahabr.ru @echo on @Echo This batch file will create a new user for browsers with no rights to run downloaded from Internet files. Pause ::Setup new user:: set safeusername=saferun_user_%random% set safepassword=%random%Ai%random% echo Login: %safeusername% echo Password: %safepassword% net user %safeusername% /delete del Browserlist4saferun.txt net user %safeusername% %safepassword% /add ::init new user profile:: echo Option explicit > init_new_user_profile.vbs echo Dim oShell >> init_new_user_profile.vbs echo set oShell= Wscript.CreateObject("WScript.Shell") >> init_new_user_profile.vbs echo oShell.Run "RunAs /profile /user:%safeusername% ping" >> init_new_user_profile.vbs echo WScript.Sleep 1000 >> init_new_user_profile.vbs echo oShell.Sendkeys "%safepassword%" >> init_new_user_profile.vbs echo oShell.Sendkeys "{ENTER}" >> init_new_user_profile.vbs echo Wscript.Quit >> init_new_user_profile.vbs call cscript init_new_user_profile.vbs ping -n 10 localhost >> nul del init_new_user_profile.vbs ::Setup privileges for new user:: net localgroup users %safeusername% /delete icacls c:\users\%safeusername%\ /deny %safeusername%:(OI)(IO)(WDAC,WO,X) ::Setup browsers:: :FindOpera if exist %APPDATA%\Opera\ xcopy /E /I /C /Y /Q /H /R %APPDATA%\Opera\* C:\Users\%safeusername%\AppData\Roaming\Opera\ if exist "%Programfiles%\Opera\Opera.exe" goto run4opera if exist "%Programfiles(x86)%\Opera\Opera.exe" goto run4operax86 Goto FindFireFox :run4opera echo Opera^|%Programfiles%\Opera>> Browserlist4saferun.txt Goto FindFireFox :run4operax86 Set Browsername=Opera echo Opera^|%Programfiles(x86)%\Opera>> Browserlist4saferun.txt Goto FindFireFox :FindFireFox if exist %APPDATA%\Mozilla\ xcopy /E /I /C /Y /Q /H /R %APPDATA%\Mozilla\* C:\Users\%safeusername%\AppData\Roaming\Mozilla\ if exist "%Programfiles%\Mozilla Firefox\Firefox.exe" goto run4Firefox if exist "%Programfiles(x86)%\Mozilla Firefox\Firefox.exe" goto run4Firefoxx86 Goto FindChrome :run4Firefox echo Firefox^|%Programfiles%\Mozilla Firefox>> Browserlist4saferun.txt Goto FindChrome :run4Firefoxx86 echo Firefox^|%Programfiles(x86)%\Mozilla Firefox>> Browserlist4saferun.txt Goto FindChrome :FindChrome If exist %LOCALAPPDATA%\Google\Chrome\Application\chrome.exe goto run4chrome Goto FindIE :run4chrome ::// Can work for some versions of Chrome by not stable. Dissabled for performance. ::xcopy /E /I /C /Y /Q /H /R %LOCALAPPDATA%\Google\Chrome\* C:\Users\%safeusername%\AppData\Local\Google\Chrome\ ::for /r C:\Users\%safeusername%\AppData\Local\Google\Chrome\ %%C in (*.exe) do icacls %%C /grant %safeusername%:(X) ::for /r C:\Users\%safeusername%\AppData\Local\Google\Chrome\ %%C in (*.dll) do icacls %%C /grant %safeusername%:(X) ::echo Chrome^|C:\Users\%safeusername%\AppData\Local\Google\Chrome\Application\>> Browserlist4saferun.txt Goto FindIE :FindIE ::// TODO A lot of XCOPYs if exist "%LOCALAPPDATA%\Microsoft\Internet Explorer" ( xcopy /E /I /C /Y /Q /H /R "%USERPROFILE%\Favorites\*" "C:\Users\%safeusername%\Favorites\" xcopy /E /I /C /Y /Q /H /R "%LOCALAPPDATA%\Microsoft\Internet Explorer\*" "C:\Users\%safeusername%\AppData\Local\Microsoft\Internet Explorer\" xcopy /E /I /C /Y /Q /H /R "%LOCALAPPDATA%\Microsoft\Windows\History\*" "C:\Users\%safeusername%\AppData\Local\Windows\History\" xcopy /E /I /C /Y /Q /H /R "%APPDATA%\Roaming\Microsoft\Windows\Cookies\*" "C:\Users\%safeusername%\AppData\Roaming\Microsoft\Windows\Cookies\" ) if exist "%Programfiles(x86)%\Internet Explorer\iexplore.exe" goto run4iex86 if exist "%Programfiles%\Internet Explorer\iexplore.exe" goto run4ie :run4iex86 echo IExplore^|%Programfiles(x86)%\Internet Explorer>> Browserlist4saferun.txt goto MakeLinks :run4ie echo IExplore^|%Programfiles%\Internet Explorer>> Browserlist4saferun.txt ::Make links:: :MakeLinks rd /s /q %USERPROFILE%\Downloads\Browser rd /s /q %USERPROFILE%\Desktop\SafeLinks mklink /d %USERPROFILE%\Downloads\Browser C:\Users\%safeusername%\Downloads mkdir %USERPROFILE%\Desktop\SafeLinks echo on For /f "tokens=1,2 delims=|" %%A in (Browserlist4saferun.txt) do ( echo Option explicit > "%%B\%%A.vbs" echo Dim oShell >> "%%B\%%A.vbs" echo set oShell= Wscript.CreateObject^("WScript.Shell"^) >> "%%B\%%A.vbs" echo oShell.Run "RunAs /user:%safeusername% %%A.exe" >> "%%B\%%A.vbs" echo WScript.Sleep 1000 >> "%%B\%%A.vbs" echo oShell.Sendkeys "%safepassword%" >> "%%B\%%A.vbs" echo oShell.Sendkeys "{ENTER}" >> "%%B\%%A.vbs" echo Wscript.Quit >> "%%B\%%A.vbs" echo Set oWS = WScript.CreateObject^("WScript.Shell"^) > "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" echo sLinkFile = "%USERPROFILE%\Desktop\SafeLinks\%%A_saferun.LNK" >> "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" echo Set oLink = oWS.CreateShortcut^(sLinkFile^) >> "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" echo oLink.TargetPath = "%%B\%%A.vbs" >> "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" echo oLink.IconLocation = "%%B\%%A.exe,0" >> "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" echo oLink.WorkingDirectory = "%%B\" >> "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" echo oLink.Save >> "%USERPROFILE%\Desktop\SafeLinks\%%A.lnk.vbs" ) for /r %USERPROFILE%\Desktop\SafeLinks\ %%p in (*.vbs) do cscript %%p for /r %USERPROFILE%\Desktop\SafeLinks\ %%v in (*.vbs) do del %%v :: Open Explorer with links:: explorer %USERPROFILE%\Desktop\SafeLinks\ :: Create Uninstall:: echo @echo off > uninstall_%~n0.bat echo net user %safeusername% /del >> uninstall_%~n0.bat echo rd /s /q %USERPROFILE%\Downloads\Browser >> uninstall_%~n0.bat echo rd /s /q %USERPROFILE%\Desktop\SafeLinks >> uninstall_%~n0.bat echo rd /s /q C:\Users\%safeusername%\ >> uninstall_%~n0.bat echo For /f "tokens=1,2 delims=|" %%%%A in (Browserlist4saferun.txt) do del "%%%%B\%%%%A.vbs" >> uninstall_%~n0.bat echo del Browserlist4saferun.txt >> uninstall_%~n0.bat echo del %%0 >> uninstall_%~n0.bat :Exit
C:\Users\saferun_user_31714\AppData\Local\Temp>d:\md5.exe ____991.ex ____991.ex : 04DA16B5447D8F2B4BD23AFD469FB153
Source: https://habr.com/ru/post/137304/
All Articles