Skip to content

Instantly share code, notes, and snippets.

@ceres-c
Last active June 27, 2025 15:15
Show Gist options
  • Select an option

  • Save ceres-c/653a357a12e4c45fec44ee953056ea9a to your computer and use it in GitHub Desktop.

Select an option

Save ceres-c/653a357a12e4c45fec44ee953056ea9a to your computer and use it in GitHub Desktop.

Revisions

  1. ceres-c revised this gist Feb 18, 2021. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions WPAD_kill.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    # Disabling WPAD
    WPAD is the Windows Proxy Auto Discovery service, used since Windows 95, IIRC, to automatically discover network configurations. Since Windows 10 Microsoft decided for some reason that users shall NOT be allowed to disable this (mostly) useless and problematic service.

    ![Can't disable WPAD service](cant_disable_wpad.jpg)
    ![Can't disable WPAD service](https://user-images.githubusercontent.com/24912818/108377205-13a5ca00-7204-11eb-809c-557c69366bde.jpg)

    Problem is: on my laptop this _feature_ used up to 20% of the CPU while doing nothing at all due to some bug I don't want to dig into. The best part is that it often triggered **after** disconnection from a wireless network. Discovering proxies makes lot of sense once you are NOT connected to any network, huh? Also, there were multiple vulnerabilities related to this service and cute tools such as [Responder](https://github.com/SpiderLabs/Responder) leverage on it.

    @@ -29,18 +29,18 @@ Stop-Transcript

    ### The scheduled task
    * Create a new task, configure the General tab as follows
    ![General tab config](task_general.jpg)
    ![General tab config](https://user-images.githubusercontent.com/24912818/108377300-2fa96b80-7204-11eb-8add-9562010538ae.jpg)
    > **NOTE**: I configured the script to be run as SYSTEM. This is terribly UNSAFE because a world writable script will be executed with the maximum privileges. I don't care, but you might
    * In the Triggers tab add a new trigger on logon
    ![Trigger on logon](task_trigger_logon.jpg)
    ![Trigger on logon](https://user-images.githubusercontent.com/24912818/108377333-37691000-7204-11eb-925b-157fb55e05a9.jpg)
    * Add a new action with the following config
    - Action: Start a program
    - Program/script: `%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe`
    - Add argument `-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File "<POWERSHELL_SCRIPT_PATH_HERE>"`
    * Set the following Conditions
    ![Task conditions](task_conditions.jpg)
    ![Task conditions](https://user-images.githubusercontent.com/24912818/108377359-3df78780-7204-11eb-8dce-ee5276c0a6a0.jpg)
    * Configure the Settings
    ![Task settings](task_settings.jpg)
    ![Task settings](https://user-images.githubusercontent.com/24912818/108377393-464fc280-7204-11eb-8e82-1a52a5098417.jpg)

    Done.

  2. ceres-c created this gist Feb 18, 2021.
    47 changes: 47 additions & 0 deletions WPAD_kill.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,47 @@
    # Disabling WPAD
    WPAD is the Windows Proxy Auto Discovery service, used since Windows 95, IIRC, to automatically discover network configurations. Since Windows 10 Microsoft decided for some reason that users shall NOT be allowed to disable this (mostly) useless and problematic service.

    ![Can't disable WPAD service](cant_disable_wpad.jpg)

    Problem is: on my laptop this _feature_ used up to 20% of the CPU while doing nothing at all due to some bug I don't want to dig into. The best part is that it often triggered **after** disconnection from a wireless network. Discovering proxies makes lot of sense once you are NOT connected to any network, huh? Also, there were multiple vulnerabilities related to this service and cute tools such as [Responder](https://github.com/SpiderLabs/Responder) leverage on it.

    ## Killing WPAD
    The service can still be disabled writing in the registry, but it will be randomly re-enabled by windows after updates/who-knows-what, so the best way to prevent this is a scheduled task running on every boot which runs a powershell script to kill the service and disable it.

    ### The script
    I saved it as `wapd_kill.ps1` in my Documents folder
    ```
    $WPADName = "WinHttpAutoProxySvc"
    Start-Transcript -Path Join-Path -Path $pwd -ChildPath "wapd_kill.log"
    Set-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\WinHttpAutoProxySvc -Name Start -Value 0x00000004
    Write-Host "Wrote registry to disable WPAD"
    $WPADServ = Get-Service -Name $WPADName
    if ($WPADServ.Status -eq "Running") {
    Write-Host "WPAD is running: Stopping it"
    $ServicePID = (get-wmiobject win32_service | where { $_.name -eq $WPADName}).processID
    Stop-Process $ServicePID -Force
    } else {
    Write-Host "WPAD not found running"
    }
    Stop-Transcript
    ```

    ### The scheduled task
    * Create a new task, configure the General tab as follows
    ![General tab config](task_general.jpg)
    > **NOTE**: I configured the script to be run as SYSTEM. This is terribly UNSAFE because a world writable script will be executed with the maximum privileges. I don't care, but you might
    * In the Triggers tab add a new trigger on logon
    ![Trigger on logon](task_trigger_logon.jpg)
    * Add a new action with the following config
    - Action: Start a program
    - Program/script: `%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe`
    - Add argument `-NoProfile -NoLogo -NonInteractive -ExecutionPolicy Bypass -File "<POWERSHELL_SCRIPT_PATH_HERE>"`
    * Set the following Conditions
    ![Task conditions](task_conditions.jpg)
    * Configure the Settings
    ![Task settings](task_settings.jpg)

    Done.

    Please read the above **NOTE** about security concers. This is mostly a reminder for myself, I don't advise you to follow this script, but if you're fed up with WPAD as well, this works.