rapid7/meterpreter — pull request #40 by OJ (2013-10-29 00:28:54+00:00)
Title: Fix ipconfig command to show IPv6

The code to make this work with IPv6 had already been written, but there was a check in place that wasn't required any more thanks to work that had already been done. This check forced every single operating system, regardless of version, to go through the code path that falls back to the old MIB approach which doesn't pull out IPv6 stuff. Removal of this check allowed the correct code path to execute which pulls out a lot more detail. However, there was also an issue with the usage of the API, in that it was assumed that the `Length` parameter of the [IP_ADAPTER_UNICAST_ADDRESS structure][1] is always `48`, even if running on versions of Windows prior to Vista. This means that checking this `Length` member not a valid way to determine if the `OnLinkPrefixLength` value was present. Instead, the Windows version is now being queried to determine if we're on an appropriate OS prior to using this member.

**Note:** I added `config.h` to the project, which is why you can see the `vcxproj` file updated.

Here's sample test output from various environments.

### Windows 2000 x86

```
meterpreter > ipconfig

Interface 1
============
Name : MS TCP Loopback interface
Hardware MAC : 00:00:00:00:00:00
MTU : 32768
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0

Interface 16777219
============
Name : AMD PCNET Family Ethernet Adapter
Hardware MAC : 00:0c:29:90:33:8a
MTU : 1500
IPv4 Address : 192.168.24.200
IPv4 Netmask : 255.255.255.0

Interface 16777220
============
Name : AMD PCNET Family Ethernet Adapter
Hardware MAC : 00:0c:29:90:33:80
MTU : 1500
IPv4 Address : XX.XX.XX.54
IPv4 Netmask : 255.255.248.0
```

### Windows XP Home SP0 x86

```
meterpreter > ipconfig

Interface 1
============
Name : MS TCP Loopback interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1520
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0

Interface 2
============
Name : AMD PCNET Family PCI Ethernet Adapter - Packet Scheduler Miniport
Hardware MAC : 00:0c:29:71:48:d8
MTU : 1500
IPv4 Address : XX.XX.XX.38
IPv4 Netmask : 255.255.248.0
```

### Windows XP Pro SP2 x86

```
meterpreter > ipconfig

Interface 1
============
Name : MS TCP Loopback interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1520
IPv4 Address : 127.0.0.1

Interface 2
============
Name : Intel(R) PRO/Wireless 2200BG Network Connection - Packet Scheduler Miniport
Hardware MAC : 00:0e:35:21:6a:a4
MTU : 1500
IPv4 Address : XX.XX.XX.41
IPv4 Netmask : 255.255.248.0

Interface 3
============
Name : Broadcom 440x 10/100 Integrated Controller - Packet Scheduler Miniport
Hardware MAC : 00:0f:1f:15:77:53
MTU : 1500
IPv4 Address : 192.168.2.101
IPv4 Netmask : 255.255.255.0
```

### Windows XP Pro SP3 x86

```
meterpreter > ipconfig

Interface 1
============
Name : MS TCP Loopback interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1520
IPv4 Address : 127.0.0.1

Interface 2
============
Name : AMD PCNET Family PCI Ethernet Adapter - Packet Scheduler Miniport
Hardware MAC : 00:0c:29:d8:97:11
MTU : 1500
IPv4 Address : XX.XX.XX.39
IPv4 Netmask : 255.255.248.0

Interface 3
============
Name : VMware Accelerated AMD PCNet Adapter - Packet Scheduler Miniport
Hardware MAC : 00:0c:29:d8:97:1b
MTU : 1500
IPv4 Address : 172.16.240.128
IPv4 Netmask : 255.255.255.0
```

### Windows Vista SP2 x86

```
meterpreter > ipconfig

Interface 1
============
Name : Software Loopback Interface 1
Hardware MAC : 00:00:00:00:00:00
MTU : 4294967295
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 10
============
Name : Intel(R) PRO/1000 MT Network Connection
Hardware MAC : 00:0c:29:49:ae:13
MTU : 1480
IPv4 Address : XX.XX.XX.52
IPv4 Netmask : 255.255.248.0
IPv6 Address : YYYY:YYYY:YYYY:0:5495:4239:4f53:7361
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : YYYY:YYYY:YYYY:0:5d5f:b4b3:22ed:8311
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:7361
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 11
============
Name : Teredo Tunneling Pseudo-Interface
Hardware MAC : 02:00:54:55:4e:01
MTU : 1280
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ
IPv6 Netmask : ffff:ffff:ffff:ffff::
```

### Windows 7 x86

```
meterpreter > ipconfig

Interface 1
============
Name : Software Loopback Interface 1
Hardware MAC : 00:00:00:00:00:00
MTU : 4294967295
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 11
============
Name : Intel(R) PRO/1000 MT Network Connection
Hardware MAC : 00:0c:29:e7:2b:0b
MTU : 1500
IPv4 Address : 172.16.240.129
IPv4 Netmask : 255.255.255.0
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:6aea
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 12
============
Name : Microsoft ISATAP Adapter
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 13
============
Name : Teredo Tunneling Pseudo-Interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : 2001:0:5ef5:79fb:30ca:3469:53ef:f7e
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:f7e
IPv6 Netmask : ffff:ffff:ffff:ffff::
```

### Windows 7 x64

```
meterpreter > ipconfig

Interface 1
============
Name : Software Loopback Interface 1
Hardware MAC : 00:00:00:00:00:00
MTU : 4294967295
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 11
============
Name : Intel(R) PRO/1000 MT Network Connection
Hardware MAC : 00:0c:29:c3:68:84
MTU : 1480
IPv4 Address : XX.XX.XX.34
IPv4 Netmask : 255.255.248.0
IPv6 Address : YYYY:YYYY:YYYY:0:38c7:675e:54ae:ac5d
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : YYYY:YYYY:YYYY:0:e10c:4d79:d0ef:d27a
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:ac5d
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 12
============
Name : Microsoft ISATAP Adapter
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 13
============
Name : Teredo Tunneling Pseudo-Interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : 2001:0:9d38:90d7:897:2d8e:f5fa:e5dd
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:e5dd
IPv6 Netmask : ffff:ffff:ffff:ffff::
```

### Windows 8 x64

```
meterpreter > ipconfig

Interface 1
============
Name : Software Loopback Interface 1
Hardware MAC : 00:00:00:00:00:00
MTU : 4294967295
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 12
============
Name : Broadcom NetXtreme 57xx Gigabit Controller
Hardware MAC : 00:1d:09:51:11:ee
MTU : 1500
IPv4 Address : 192.168.2.100
IPv4 Netmask : 255.255.255.0
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:66db
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 13
============
Name : Intel(R) Wireless WiFi Link 4965AGN
Hardware MAC : 00:1f:3b:7b:1b:65
MTU : 1480
IPv4 Address : XX.XX.XX.47
IPv4 Netmask : 255.255.248.0
IPv6 Address : YYYY:YYYY:YYYY:0:4413:316a:9e17:15c7
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : YYYY:YYYY:YYYY:0:d0bc:f276:33fb:1997
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:15c7
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 14
============
Name : Microsoft ISATAP Adapter
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 15
============
Name : Teredo Tunneling Pseudo-Interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : 2001:0:9d38:6abd:1087:97f:3f57:fd9b
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:fd9b
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 16
============
Name : Microsoft ISATAP Adapter #2
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
```

### Windows 2012 x64

```
meterpreter > ipconfig

Interface 1
============
Name : Software Loopback Interface 1
Hardware MAC : 00:00:00:00:00:00
MTU : 4294967295
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 12
============
Name : Intel(R) 82574L Gigabit Network Connection
Hardware MAC : 00:0c:29:1a:8c:32
MTU : 1480
IPv4 Address : XX.XX.XX.55
IPv4 Netmask : 255.255.248.0
IPv6 Address : YYYY:YYYY:YYYY:0:ddeb:b646:e52a:9efb
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:9efb
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 13
============
Name : Microsoft ISATAP Adapter
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 14
============
Name : Teredo Tunneling Pseudo-Interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : 2001:0:9d38:6abd:c36:3a61:f5fa:e5c8
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:e5c8
IPv6 Netmask : ffff:ffff:ffff:ffff::
```

### Windows 8.1 x86

```
meterpreter > ipconfig

Interface 1
============
Name : Software Loopback Interface 1
Hardware MAC : 00:00:00:00:00:00
MTU : 4294967295
IPv4 Address : 127.0.0.1
IPv4 Netmask : 255.0.0.0
IPv6 Address : ::1
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 3
============
Name : Intel(R) Wireless WiFi Link 4965AGN
Hardware MAC : 00:1d:e0:72:86:0f
MTU : 1480
IPv4 Address : XX.XX.XX.32
IPv4 Netmask : 255.255.248.0
IPv6 Address : YYYY:YYYY:YYYY:0:f5fd:a72a:d7f7:8ab4
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : YYYY:YYYY:YYYY:0:1520:bc5d:27ae:f194
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : YYYY:YYYY:YYYY:0:5401:af10:b354:15d4
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : YYYY:YYYY:YYYY:0:6815:a838:dc36:f046
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : YYYY:YYYY:YYYY:0:818c:c018:7dae:ea6a
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : YYYY:YYYY:YYYY:0:bdd5:dd84:ed90:2a6c
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : YYYY:YYYY:YYYY:0:dd8d:d3f5:7760:a24e
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : YYYY:YYYY:YYYY:0:e04a:66ab:a089:8858
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:8ab4
IPv6 Netmask : ffff:ffff:ffff:ffff::

Interface 5
============
Name : Microsoft ISATAP Adapter
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ
IPv6 Netmask : ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff

Interface 6
============
Name : Teredo Tunneling Pseudo-Interface
Hardware MAC : 00:00:00:00:00:00
MTU : 1280
IPv6 Address : 2001:0:9d38:6abd:10ae:1052:f5fa:e5df
IPv6 Netmask : ffff:ffff:ffff:ffff::
IPv6 Address : ZZZZ::ZZZZ:ZZZZ:ZZZZ:e5df
IPv6 Netmask : ffff:ffff:ffff:ffff::
```

[1]: http://msdn.microsoft.com/en-us/library/windows/desktop/aa366066(v=vs.85).aspx

[FixRM #6455]