Code Monkey home page Code Monkey logo

posh's People

Contributors

winadm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

posh'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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.