{"id":255910,"date":"2024-05-17T11:50:32","date_gmt":"2024-05-17T11:50:32","guid":{"rendered":"https:\/\/www.ninjaone.com\/?post_type=script_hub&#038;p=255910"},"modified":"2024-05-17T11:50:32","modified_gmt":"2024-05-17T11:50:32","slug":"configurar-la-autenticacion-ntlm","status":"publish","type":"script_hub","link":"https:\/\/www.ninjaone.com\/es\/script-hub\/configurar-la-autenticacion-ntlm\/","title":{"rendered":"C\u00f3mo configurar la autenticaci\u00f3n NTLM en Windows mediante PowerShell"},"content":{"rendered":"<p>En un panorama de ciberseguridad en constante evoluci\u00f3n, es primordial proteger las comunicaciones y el intercambio de datos. Uno de estos protocolos que ha sido objeto de debate es la autenticaci\u00f3n NTLM (NT LAN Manager), que se utiliza para autenticar usuarios en entornos Microsoft. Con los recientes avances y la preocupaci\u00f3n por la seguridad, se ha producido un cambio de las antiguas versiones de NTLM a la m\u00e1s segura NTLMv2. Hoy profundizaremos en un script de PowerShell que ayuda a gestionar las respuestas de <strong>autenticaci\u00f3n NTLM<\/strong> mediante la configuraci\u00f3n de LmCompatibilityLevel en el <a href=\"https:\/\/www.ninjaone.com\/blog\/what-is-windows-registry\/\" target=\"_blank\" rel=\"noopener\">registro de Windows<\/a>.<\/p>\n<h2>Antecedentes<\/h2>\n<p>Desarrollado originalmente como protocolo de autenticaci\u00f3n por Microsoft, la autenticaci\u00f3n NTLM ha sido objeto de varias actualizaciones para hacer frente a diversas vulnerabilidades de seguridad. Sin embargo, a medida que surgieron mecanismos de autenticaci\u00f3n m\u00e1s seguros, especialmente NTLMv2, se hizo evidente la necesidad de restringir o desactivar las versiones anteriores. Este script ayuda a los profesionales de TI y a los <a href=\"https:\/\/www.ninjaone.com\/es\/que-es-un-msp\">proveedores de servicios gestionados (MSP)<\/a> a realizar esta transici\u00f3n sin problemas, sin tener que navegar manualmente por complejas configuraciones del registro.<\/p>\n<h2>El script para configurar la autenticaci\u00f3n NTLM en Windows<\/h2>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"powershell\">#Requires -Version 5.1\r\n\r\n&lt;#\r\n.SYNOPSIS\r\n    Set the LM and NTLMv1 authentication responses via LmCompatibilityLevel in the registry\r\n.DESCRIPTION\r\n    Set the LM and NTLMv1 authentication responses via LmCompatibilityLevel in the registry\r\n.EXAMPLE\r\n    No parameters needed.\r\n    Sets LAN Manager auth level to 5, \"Send NTLMv2 response only. Refuse LM &amp; NTLM.\"\r\n.EXAMPLE\r\n     -LmCompatibilityLevel 5\r\n    Sets LAN Manager auth level to 5, \"Send NTLMv2 response only. Refuse LM &amp; NTLM.\"\r\n.EXAMPLE\r\n     -LmCompatibilityLevel 3\r\n    Sets LAN Manager auth level to 3, \"Send NTLMv2 response only.\"\r\n    This is the default from Windows 7 and up.\r\n.EXAMPLE\r\n    PS C:&gt; Disable-LmNtlmV1.ps1 -LmCompatibilityLevel 5\r\n    Sets LAN Manager auth level to 5, \"Send NTLMv2 response only. Refuse LM &amp; NTLM.\"\r\n.OUTPUTS\r\n    None\r\n.NOTES\r\n    Minimum OS Architecture Supported: Windows 10, Windows Server 2016\r\n    Reference chart: https:\/\/ss64.com\/nt\/syntax-ntlm.html\r\n    Release Notes:\r\n    Initial Release\r\nBy using this script, you indicate your acceptance of the following legal terms as well as our Terms of Use at https:\/\/www.ninjaone.com\/terms-of-use.\r\n    Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms. \r\n    Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party. \r\n    Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library or website belonging to or under the control of any other software provider. \r\n    Warranty Disclaimer: The script is provided \u201cas is\u201d and \u201cas available\u201d, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations. \r\n    Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks. \r\n    Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script. \r\n    EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).\r\n.COMPONENT\r\n    ProtocolSecurity\r\n#&gt;\r\n\r\n[CmdletBinding()]\r\nparam (\r\n    [Parameter()]\r\n    [ValidateRange(0, 5)]\r\n    [int]\r\n    $LmCompatibilityLevel = 5\r\n)\r\n\r\nbegin {\r\n    function Test-IsElevated {\r\n        $id = [System.Security.Principal.WindowsIdentity]::GetCurrent()\r\n        $p = New-Object System.Security.Principal.WindowsPrincipal($id)\r\n        if ($p.IsInRole([System.Security.Principal.WindowsBuiltInRole]::Administrator))\r\n        { Write-Output $true }\r\n        else\r\n        { Write-Output $false }\r\n    }\r\n    function Set-ItemProp {\r\n        param (\r\n            $Path,\r\n            $Name,\r\n            $Value,\r\n            [ValidateSet(\"DWord\", \"QWord\", \"String\", \"ExpandedString\", \"Binary\", \"MultiString\", \"Unknown\")]\r\n            $PropertyType = \"DWord\"\r\n        )\r\n        New-Item -Path $Path -Force -ErrorAction SilentlyContinue | Out-Null\r\n        if ((Get-ItemProperty -Path $Path -Name $Name -ErrorAction SilentlyContinue)) {\r\n            Set-ItemProperty -Path $Path -Name $Name -Value $Value -Force -Confirm:$false | Out-Null\r\n        }\r\n        else {\r\n            New-ItemProperty -Path $Path -Name $Name -Value $Value -PropertyType $PropertyType -Force -Confirm:$false | Out-Null\r\n        }\r\n    }\r\n}\r\nprocess {\r\n    if (-not (Test-IsElevated)) {\r\n        Write-Error -Message \"Access Denied. Please run with Administrator privileges.\"\r\n        exit 1\r\n    }\r\n    $Path = @(\r\n        \"HKLM:SYSTEMCurrentControlSetServicesLsa\"\r\n        \"HKLM:SYSTEMCurrentControlSetControlLSA\"\r\n    )\r\n    $Name = \"LmCompatibilityLevel\"\r\n    # $Value = $LmCompatibilityLevel\r\n    # Sets LmCompatibilityLevel to $LmCompatibilityLevel\r\n    try {\r\n        $Path | ForEach-Object {\r\n            Set-ItemProp -Path $_ -Name $Name -Value $LmCompatibilityLevel\r\n        }\r\n        \r\n    }\r\n    catch {\r\n        Write-Error $_\r\n        exit 1\r\n    }\r\n    $Path | ForEach-Object {\r\n        $Value = Get-ItemPropertyValue -Path $_ -Name $Name -ErrorAction SilentlyContinue\r\n        if ($null -eq $Value) {\r\n            Write-Host \"$_$Name set to: OS's default value(3).\"\r\n        }\r\n        else {\r\n            Write-Host \"$_$Name set to: $Value\"\r\n        }\r\n    }\r\n}\r\nend {}<\/pre>\n<p>&nbsp;<\/p>\n\n<div class=\"in-context-cta\"><p style=\"text-align: center;\">Accede a m\u00e1s de 300 scripts en el Dojo de NinjaOne<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.ninjaone.com\/es\/prueba-gratuita-formulario\/\">Obt\u00e9n acceso<\/a><\/p>\n<\/div>\n<h2>An\u00e1lisis detallado<\/h2>\n<p>El script se divide esencialmente en tres fases: <em>inicio<\/em>, <em>proceso<\/em> y <em>final<\/em>.<\/p>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>Fase de inicio<\/strong>: el script comienza con la definici\u00f3n de dos funciones:<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>Test-IsElevated<\/strong>: comprueba si el script se ejecuta con privilegios de administrador.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>Set-ItemProp<\/strong>: crea o establece una propiedad de clave de registro.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"4\" data-aria-level=\"1\"><strong>Fase del proceso<\/strong>: verifica que el usuario tiene derechos elevados. En caso contrario, se indica un error. De otra manear, pasa a modificar el <strong>LmCompatibilityLevel<\/strong> en dos posibles rutas del registro. Tras la modificaci\u00f3n, el script confirma la configuraci\u00f3n aplicada.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"5\" data-aria-level=\"1\"><strong>Fase final<\/strong>: no se utiliza expl\u00edcitamente, pero es un marcador de posici\u00f3n para posibles futuras actualizaciones o ampliaciones del script.<\/li>\n<\/ul>\n<h2>Posibles casos de uso<\/h2>\n<p><em>Estudio de caso<\/em>: Imagina a Marta, administradora de TI en una empresa mediana. Recientemente se han sometido a una auditor\u00eda de seguridad que ha revelado que algunos sistemas siguen utilizando versiones de NTLM obsoletas. Con cientos de m\u00e1quinas que gestionar, no es factible actualizar manualmente cada una de ellas. Usando este script, Marta actualiza sin problemas todos los sistemas, asegur\u00e1ndose de que s\u00f3lo aceptan respuestas NTLMv2.<\/p>\n<h2>Comparaciones<\/h2>\n<p>Aunque la directiva de grupo tambi\u00e9n se puede utilizar para gestionar la configuraci\u00f3n de NTLM en una organizaci\u00f3n, scripts de PowerShell, como el que tratamos en este post, ofrecen m\u00e1s granularidad y automatizaci\u00f3n. Pueden integrarse en herramientas de automatizaci\u00f3n o flujos de trabajo m\u00e1s amplios, agilizando el proceso y haci\u00e9ndolo menos propenso a errores manuales.<\/p>\n<h2>FAQ<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\"><strong>\u00bfC\u00f3mo comprueba el script si se tienen privilegios de administrador?<br \/>\n<\/strong> El script utiliza la funci\u00f3n <strong>Test-IsElevated<\/strong> para determinar si se est\u00e1 ejecutando con derechos de administrador.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\"><strong>\u00bfQu\u00e9 ocurre si quiero establecer un valor de LmCompatibilityLevel diferente?<\/strong><br \/>\nPuedes hacerlo proporcionando el par\u00e1metro <strong>-LmCompatibilityLevel<\/strong> al ejecutar el script, por ejemplo, <strong>Disable-LmNtlmV1.ps1 -LmCompatibilityLevel 3<\/strong>.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"3\" data-aria-level=\"1\"><strong>\u00bfEs compatible con versiones anteriores de Windows?<\/strong><br \/>\nEl script es compatible con Windows 10 y Windows Server 2016 en adelante.<\/li>\n<\/ul>\n<h2>Implicaciones<\/h2>\n<p>Al establecer el LmCompatibilityLevel, los profesionales de TI dictan c\u00f3mo los sistemas manejan la autenticaci\u00f3n NTLM. La restricci\u00f3n a NTLMv2 mejora la seguridad, reduciendo los riesgos asociados a versiones m\u00e1s antiguas y menos seguras. Sin embargo, es crucial garantizar la compatibilidad, ya que los sistemas o aplicaciones m\u00e1s antiguos pueden tener problemas de conectividad tras los cambios.<\/p>\n<h2>Recomendaciones<\/h2>\n<ul>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"1\" data-aria-level=\"1\">Haz siempre una copia de seguridad del estado actual del registro antes de realizar cambios.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Primero, prueba el script en un entorno controlado para comprender su impacto.<\/li>\n<li data-leveltext=\"\uf0b7\" data-font=\"Symbol\" data-listid=\"1\" data-list-defn-props=\"{&quot;335552541&quot;:1,&quot;335559684&quot;:-2,&quot;335559685&quot;:720,&quot;335559991&quot;:360,&quot;469769226&quot;:&quot;Symbol&quot;,&quot;469769242&quot;:[8226],&quot;469777803&quot;:&quot;left&quot;,&quot;469777804&quot;:&quot;\uf0b7&quot;,&quot;469777815&quot;:&quot;hybridMultilevel&quot;}\" data-aria-posinset=\"2\" data-aria-level=\"1\">Mantente al d\u00eda sobre las mejores pr\u00e1cticas de seguridad e int\u00e9gralas en tus auditor\u00edas rutinarias.<\/li>\n<\/ul>\n<h2>Reflexiones finales<\/h2>\n<p>Mientras que los scripts PowerShell como estos permiten a los profesionales de TI mejorar la seguridad, las <a href=\"https:\/\/www.ninjaone.com\/es\/rmm\/\">herramientas de supervisi\u00f3n y gesti\u00f3n como NinjaOne<\/a> elevan a\u00fan m\u00e1s estas capacidades. Con <a href=\"https:\/\/www.ninjaone.com\/es\/rmm\/automatizacion-de-ti\">supervisi\u00f3n, automatizaci\u00f3n e informes integrados,<\/a> plataformas como NinjaOne garantizan que tu infraestructura de TI siga siendo s\u00f3lida, segura y eficiente, complementando los scripts y las intervenciones manuales.<\/p>\n<p>Recuerda que, en el \u00e1mbito de las TI, las medidas proactivas, combinadas con las herramientas adecuadas, allanan el camino hacia una <a href=\"https:\/\/www.ninjaone.com\/es\/enterprise-it-management\/seguridad\/\">mayor seguridad y una gesti\u00f3n eficaz del sistema<\/a>.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"author":35,"featured_media":144864,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_acf_changed":false,"_relevanssi_hide_post":"","_relevanssi_hide_content":"","_relevanssi_pin_for_all":"","_relevanssi_pin_keywords":"","_relevanssi_unpin_keywords":"","_relevanssi_related_keywords":"","_relevanssi_related_include_ids":"","_relevanssi_related_exclude_ids":"","_relevanssi_related_no_append":"","_relevanssi_related_not_related":"","_relevanssi_related_posts":"","_relevanssi_noindex_reason":"","_lmt_disableupdate":"no","_lmt_disable":""},"operating_system":[4212],"use_cases":[4259],"class_list":["post-255910","script_hub","type-script_hub","status-publish","has-post-thumbnail","hentry","script_hub_category-windows"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub\/255910","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/script_hub"}],"about":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/types\/script_hub"}],"author":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/users\/35"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/comments?post=255910"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media\/144864"}],"wp:attachment":[{"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/media?parent=255910"}],"wp:term":[{"taxonomy":"script_hub_category","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/operating_system?post=255910"},{"taxonomy":"use_cases","embeddable":true,"href":"https:\/\/www.ninjaone.com\/es\/wp-json\/wp\/v2\/use_cases?post=255910"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}