tis-disable-netbios icon

Disable NetBIOS

Silent install package for Disable NetBIOS

14
System and network
System and network

tis-disable-netbios

Objective

Disable NetBIOS on network interfaces.

Some VPN solutions still require NetBIOS or may be impacted by its deactivation. For this reason, a specific VPN adapter can be excluded from the process by modifying the VPN_NAME = "NAME_VPN_ADAPTER" section.

"""
Custom name of VPN adapter
Enter the name of the network adapter concerned:
ex: Get-NetAdapter | Select-Object InterfaceDescription
"""
VPN_NAME = "NAME_VPN_ADAPTER"

How it works

The script targets network interfaces with an active IP configuration (IPEnabled=True) using WMI and disables NetBIOS on them.

Usage

It is possible to define an exception by specifying the name of the network interface to ignore.
(If VPN_NAME matches part of the interface name, that interface will be skipped by the script.)

  • package: tis-disable-netbios
  • name: Disable NetBIOS
  • version: 14
  • categories: System and network
  • maintainer: WAPT Team,Tranquil IT
  • locale: all
  • target_os: windows
  • architecture: all
  • signature_date:
  • size: 8.73 Ko

package           : tis-disable-netbios
version           : 14
architecture      : all
section           : base
priority          : optional
name              : Disable NetBIOS
categories        : System and network
maintainer        : WAPT Team,Tranquil IT
description       : Disable netbios on all interfaces
depends           : 
conflicts         : 
maturity          : PROD
locale            : all
target_os         : windows
min_wapt_version  : 
sources           : 
installed_size    : 
impacted_process  : 
description_fr    : Désactiver netbios sur toutes les interfaces
description_pl    : Wyłączenie netbios na wszystkich interfejsach
description_de    : Netbios auf allen Schnittstellen deaktivieren
description_es    : Desactivar netbios en todas las interfaces
description_pt    : Desactivar netbios em todas as interfaces
description_it    : Disabilitare netbios su tutte le interfacce
description_nl    : Schakel netbios uit op alle interfaces
description_ru    : Отключить netbios на всех интерфейсах
audit_schedule    : 
editor            : 
keywords          : 
licence           : 
homepage          : 
package_uuid      : 87966917-160d-4149-be86-889ba6e0c241
valid_from        : 
valid_until       : 
forced_install_on : 
changelog         : 
min_os_version    : 10
max_os_version    : 
icon_sha256sum    : 04c349c5b94ca20ba22d88f25510da7f820cc9d5f1a876e9a3960d0c0cabc353
signer            : Tranquil IT
signer_fingerprint: 8c5127a75392be9cc9afd0dbae1222a673072c308c14d88ab246e23832e8c6bb
signature_date    : 2026-03-17T15:23:42.000000
signed_attributes : package,version,architecture,section,priority,name,categories,maintainer,description,depends,conflicts,maturity,locale,target_os,min_wapt_version,sources,installed_size,impacted_process,description_fr,description_pl,description_de,description_es,description_pt,description_it,description_nl,description_ru,audit_schedule,editor,keywords,licence,homepage,package_uuid,valid_from,valid_until,forced_install_on,changelog,min_os_version,max_os_version,icon_sha256sum,signer,signer_fingerprint,signature_date,signed_attributes
signature         : YJt6mhlXy/ja/1LDyv2+ZK/wEns55uRG6Og/vjG8NEgjZwezcY39nYtPEcAfe/ZgJHJeGutXBVtZmR3xZ6kLpMerTmTRpNPGvOAn/59cOdStWGZX8/UjOerO7R38VkjnqaEPm9cQNkcwDPxb1ETDCS2XY4H5JBmvp9nEdV25DtgVZhDRHzdC87grrpFGsBk/j8cij7LKCbQLrkSn375Ey3Y8q3YSCiVoM41KlhnOWJIREDUALdEJhEse1g3CD9mm2/oky1E2d6wuC4xvZrzvjoLMAVyolw+aWfukOf9FWcDySpH/qThkYzb8cyngdp9EleKVUbbaARruONCvfXRdSw==

from setuphelpers import *

uninstallkey = []

VPN_NAME = "NAME_VPN_ADAPTER"


def ps_list(cmd):
    result = run_powershell(cmd)
    if not result:
        return []
    if isinstance(result, dict):
        return [result]
    return result


def field(obj, name, default=None):
    if isinstance(obj, dict):
        return obj.get(name, default)
    return getattr(obj, name, default)


def get_enabled_adapters():
    return ps_list(
        'Get-CimInstance -ClassName "Win32_NetworkAdapterConfiguration" | '
        'Where-Object { $_.IPEnabled -eq $true } | '
        'Select-Object Description, TcpipNetbiosOptions, SettingID'
    )


def set_netbios(setting_id, value):
    safe_setting_id = setting_id.replace('"', '`"')
    return ps_list(
        'Get-CimInstance -ClassName "Win32_NetworkAdapterConfiguration" | '
        'Where-Object { $_.SettingID -eq "%s" } | '
        'Invoke-CimMethod -MethodName "SetTcpipNetbios" '
        '-Arguments @{ TcpipNetbiosOptions = %s } | '
        'Select-Object ReturnValue'
        % (safe_setting_id, int(value))
    )


def install():
    for connection in get_enabled_adapters():
        adapter_name = field(connection, 'Description', '') or ''
        setting_id = field(connection, 'SettingID')
        netbios_opt = field(connection, 'TcpipNetbiosOptions')

        if VPN_NAME.lower() in adapter_name.lower():
            print(u"Skipping NetBIOS disable for VPN adapter: %s" % adapter_name)
            continue

        if netbios_opt != 2:
            print(u"Disabling NetBIOS on %s" % adapter_name)
            print(set_netbios(setting_id, 2))

    print("Fix Denis's last experiment on NetBios things...")

    with disable_file_system_redirection():
        run('reg import "%s"' % makepath(persistent_dir, 'fix.reg'))


def uninstall():
    for connection in get_enabled_adapters():
        adapter_name = field(connection, 'Description', '') or ''
        setting_id = field(connection, 'SettingID')
        netbios_opt = field(connection, 'TcpipNetbiosOptions')

        if VPN_NAME.lower() in adapter_name.lower():
            print(u"Skipping NetBIOS enable for VPN adapter: %s" % adapter_name)
            continue

        if netbios_opt == 2:
            print(u'Enabling NetBIOS on %s' % adapter_name)
            print(set_netbios(setting_id, 0))


def audit():
    result = check_netbios()
    if result == "ERROR":
        print('Auto remediation')
        install()
        result = check_netbios()
        if result == "ERROR":
            print('Fail Fix netbios')
            return "ERROR"
    return "OK"


def check_netbios():
    has_netbios = []

    for connection in get_enabled_adapters():
        adapter_name = field(connection, 'Description', '') or ''
        netbios_opt = field(connection, 'TcpipNetbiosOptions')

        if VPN_NAME.lower() in adapter_name.lower():
            print(u'OK: VPN detected, check skipped for: %s' % adapter_name)
            continue

        if netbios_opt == 2:
            print(u'OK: NetBIOS disabled on: %s' % adapter_name)
        else:
            print(u'ERROR: NetBIOS enabled on: %s' % adapter_name)
            has_netbios.append(adapter_name)

    if has_netbios:
        print(u'\nNetBIOS must be disabled on:\n%s' % u'\n'.join(has_netbios))
        return 'ERROR'

    return 'OK'

4b5897d8f06b6e17618938d72a0508ce20adbc84cf332ee4a872d75cec999675 : WAPT/README.md
df5115979f4fdfc5f4a111d961680e3aaeb5e8d84523288960d00a5941ac82bd : WAPT/README_fr.md
38d056ab130f7bf7c481c12636a4e9959de36561d3dfcbe54c6e3571bc0c1dc3 : WAPT/certificate.crt
335123f8eac756f1fe94fef9094e4a9aa696a670623e2296e02d8835e4a9cdb4 : WAPT/control
04c349c5b94ca20ba22d88f25510da7f820cc9d5f1a876e9a3960d0c0cabc353 : WAPT/icon.png
df9e7a57d9d44a24a5339aa627880b6d5f61c7bed55c8d30932c54517cbc2915 : WAPT/persistent/fix.reg
73630a4c7b5f8fd235c17f175e96b7817cae340a09e5ad2ee1d84b8978ae793e : luti.json
d002ab88f50d51a1ab42a7e561d73211e614a41dd565219eff1162a9087a4046 : setup.py