posh's People
Forkers
andrewcred ckfn4czc platon47 artempetrochenko zebraroma alexquaken pelengattor frew777 pavel-matskevich devil96-96 qweskm meinkkaif ne01011 yellowapps mku-krsk-dev chvi-dev berethor hamsterr angelform kot624 123new bolgovsky andreibyuarov fom4578 smirvanya turbokach zyuzginov karakuraizer kragen89 kartavenkov-nikita const885 dimm-g s1gne maxxaa adkham sqweeezi scrik youtweakit chernikovkn sergeyha cronv logros sfedyaev odoron sheverdukis alexx72 asm8bit bazaev acenotass mrshade666 olelukoye karendaposh's Issues
порядок операций в скрипте для терминального сервера.
#=====
#запуск скрипта из командного файла cmd, необходимы права администратора.
#PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "& 'D:\Install\Programs\RDP\Patch\RDP_patch.ps1'"
#=====
# поиск шаблона в файле termsrv.dll
Write-Output 'Checking for version'
$dll_as_bytes = Get-Content c:\windows\system32\termsrv.dll -Raw -Encoding byte
$dll_as_text = $dll_as_bytes.forEach('ToString', 'X2') -join ' '
$patternregex = ([regex]'39 81 3C 06 00 00(\s\S\S){6}')
$patch = 'B8 00 01 00 00 89 81 38 06 00 00 90'
$checkPattern=Select-String -Pattern $patternregex -InputObject $dll_as_text
If ($checkPattern -ne $null)
{
Write-Output 'Patching...'
# Остановить службы
Stop-Service UmRdpService -Force
Stop-Service TermService -Force
# сделать копию файла и разрешений
Copy-Item c:\windows\system32\termsrv.dll c:\windows\system32\termsrv.dll.copy
$termsrv_dll_acl = Get-Acl c:\windows\system32\termsrv.dll
# изменить разрешения
takeown /f c:\windows\system32\termsrv.dll
$new_termsrv_dll_owner = (Get-Acl c:\windows\system32\termsrv.dll).owner
cmd /c "icacls c:\windows\system32\termsrv.dll /Grant $($new_termsrv_dll_owner):F /C"
# модификация файла termsrv.dll
$dll_as_text_replaced = $dll_as_text -replace $patternregex, $patch
[byte[]] $dll_as_bytes_replaced = -split $dll_as_text_replaced -replace '^', '0x'
Set-Content c:\windows\system32\termsrv.dll.patched -Encoding Byte -Value $dll_as_bytes_replaced
# Сравним два файла
fc.exe /b c:\windows\system32\termsrv.dll.patched c:\windows\system32\termsrv.dll
# замена оригинального файла
Copy-Item c:\windows\system32\termsrv.dll.patched c:\windows\system32\termsrv.dll -Force
# установка оригинальных разрешений
Set-Acl c:\windows\system32\termsrv.dll $termsrv_dll_acl
# Запустить службы
Start-Service UmRdpService
Start-Service TermService
Write-Output 'The termsrv.dll file succefully patched'
}
Elseif (Select-String -Pattern $patch -InputObject $dll_as_text)
{
Write-Output 'The termsrv.dll file is already patched'
}
else
{
Write-Output "Version not supported "
}
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.