Introduction: How to Setup a Windows Kernel Debugger Over Your Network
A couple things to take note of:
- This instruction set is designed for advanced computer users and the author has assumed that with these instructions.
- For privacy sake some information has been obscured.
First thing we will go over are the items you'll need to setup your debugger.
Step 1: What You'll Need
- 2 Windows Computers
- The Host computer which you’ll use for debugging. This computer must have Windows XP or newer installed
- The Target computer which you’ll be debugging. This computer must have Windows 8 or newer installed. It must also have one of the network adapters found in the list here. http://msdn.microsoft.com/en-us/library/windows/h...
Next we will go over what you'll need to do to set your computers up.
Step 2: Preparing Your Computers
- For the computer you'll be debugging on you'll need to install Debugging Tools for Windows which can be found here...
- http://msdn.microsoft.com/en-US/windows/desktop/bg...
- Connect the computer to your Switch/Router
- Make sure you are using Windows 8 or newer
- Make sure you are using a network adapter from this list http://msdn.microsoft.com/en-us/library/windows/hardware/dn337009(v=vs.85).aspx
- Connect the computer to your Switch/Router
Now that we have the computers setup we'll need to connect them, starting with the target computer.
Step 3: Setting Up the Target Computer
You need a couple things to get your target computer ready. You need the IP address of your Host computer. You can obtain this by using the ping tool. Here is how to do this...
- Open a command prompt
- Type "ping -4 HostComputerName." You'll get something like the following...
ping HostComputerName
Pinging HostComputerName [192.166.0.123] with 32 bytes of data:
Reply from 192.166.0.123: bytes=32 time=2268ms TTL=128
Reply from 192.166.0.123: bytes=32 time=10ms TTL=128
Reply from 192.166.0.123: bytes=32 time=19ms TTL=128
Reply from 192.166.0.123: bytes=32 time=1ms TTL=128
Ping statistics for 192.166.0.123:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 2268ms, Average = 574ms
*Keep this windows open. You'll need it later.
Next you need to make some changes to the boot configuration. The changes to your boot configuration file will tell your target computer how to connect to the host computer. In order to do this you'll need to open a command prompt with administrator (elevated) permissions. Here is how you do that.
- Right click on the command prompt on the taskbar
- Right click on command prompt again
- Click "Run As Administrator" (User Account Control will ask if you would like to allow this program to make changes on your computer, click Yes)
Now you need to set the boot configuration settings for network debugging. You will do this by using the bcdedit tool. This tool is built into the OS and can be run from any elevated command prompt. The following steps show how you make these setting changes
- In this new command window run the following...
- bcdedit /dbgsettings net hostip=192.166.0.123 port=XXXXX key=z.z.z.z
- where the hostip equals the IP address you obtained when you ran the ping command, XXXXX equals any number between 50000 and 50099, and z is any alphanumeric combination. Here is an example ...
bcdedit /dbgsettings net hostip=192.166.0.123 port:50002 key=a1b.2c3.d4e.5f6
Remember the key that you created. You'll need this when you set up your host computer.
Now you need to turn the debugger on. You can use the same elevated command prompt that you were using before or open a new one. To turn debugging on run the following bcdedit command
- bcdedit /debug on
- restart the computer
Please reference the picture above which shows examples of all of the commands in this step.
Now that we have the target computer set up we can prepare the host computer to look for our target computer on the network.
Step 4: Setting Up the Host Computer
To use the debugger from the command prompt.
- Open an elevated command prompt window
- Browse to the Debuggers directory where you installed the debugger. The default location looks like this. C:\Program Files (x86)\Windows Kits\8.0\Debuggers\
- If your host computer is running a 64 bit operating system, change directory to the x64 directory. If you are running a 32bit operating system on your host computer, change directory to the x86 directory.
- Type in the following command. kd - k net:port=XXXXX,key=z.z.z.z (Where XXXXX is the port you set on the target computer and z.z.z.z is the key you set on the target computer)
- Hit Enter
To run the debugger using windbg.
- run windbg from the directory you installed the debugger from. The default location looks like this. C:\Program Files (x86)\Windows Kits\8.0\Debuggers\.
- If your host computer is running a 64 bit operating system, change directory to the x64 directory. If you are running a 32bit operating system on your host computer, change directory to the x86 directory.
- Double click on windbg.exe
- Click on File
- Click Kernel Debug
- Select the Net tab
- Enter the port number you set on the target computer
- Enter the key you set on the target computer.
- Hit Okay
Please reference the pictures above which shows examples of all of the commands in this step.
Now that we have the host and target computers set up we can connect the two.
Step 5: Connecting to the Debugger
If everything is set up correctly this part is really easy. In fact after you set up the host computer you may have noticed a lot of text appear in the window. If so, you are done. If not, all you need to do is restart the target computer. As the target computer boots you'll start to see a stream of text in your debugging window (kd or windbg depending on which you use) on the host computer. It will looks something like the pictures above.
Step 6: In Conclusion
Now that you have successfully connected your computers with a debugger you can begin to help solve all the worlds computer problems. This is only the first step in a long road to getting to the root cause of any computer issue. Look for more articles in the future where I tackle how to begin investigating the many different problems that you may encounter.
3 Comments
5 years ago
Hi byoung82,
Thanks for a great guide :)
Unfortunately I'm couldn't make the Host collect data from Target machine.
Target : I've performed all of your steps above
Host : (it's pending for something)
C:\Program Files\Windows Kits\10\Debuggers\x64>kd -k net:port=(number),key=(s.o.m.e.key)
Microsoft (R) Windows Debugger Version 10.0.16299.15 AMD64
Copyright (c) Microsoft Corporation. All rights reserved.
Using NET for debugging
Opened WinSock 2.0
Kernel Debug Target Status: [no_debuggee]; Retries: [0] times in last [7] seconds.
Waiting to reconnect...
What details you need to understand what may be the problem ?
BR,
Andrey
5 years ago
Thanks Michael. You are right. I've updated the instructions
Tip 5 years ago on Step 3
Nowadays, (i.e. Win10) you need to enter "ping -4 ..." to get the ipv4 address. Otherwise you'll get the ipv6 address.