Windows CCM Cache eats diskspace

Don’t delete the content of „c:\windows\ccmcache\“ manually with the File-Explorer:

  • it is managed by „Windows System Center Configuration Manager (SCCM)“.

You need „local Administrator“ access to your computer.

Let SCCM to cleanup it’s cache for you:

1) open the „Control Panel“

Control Panel – Configuration Manager

2) select „Configuration Manager“

3) go to „Cache“-Tab

4) click „Delete Files“

Configuration Manager – Delete Cache

Wait a second and the CCM-Cache is empty.

c:\Windows\ccmcache>dir
 Volume in drive C is Windows
 Volume Serial Number is 5Q4C-0K08

 Directory of c:\Windows\ccmcache

23.09.2021  19:10    <DIR>          .
23.09.2021  19:10    <DIR>          ..
               0 File(s)              0 bytes
               2 Dir(s)  11.164.721.152 bytes free

Compile PuTTY on your own

The beginning: Source Code

Find the original source archive at https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html or get the Windows-Archive directly here: https://the.earth.li/~sgtatham/putty/latest/putty-src.zip

Modify the Source Code

For example: Tweak the modal „Fatal Connection Error“ Dialog: Relax PuTTY: Suppress „Fatal Error“ Dialog

Next step: GCC-Compiler

I’d chose MinGW to compile native Windows Applications: MinGW as build-environment for native Windows Applications

Compile it

Using MinGw:

run MinGw

In PuTTY it’s all prepared for us – go to the „windows“ subdirectory:

  • mingw32-make -f Makefile.mgw
C:\Program Files\mingw-w64\x86_64-8.1.0-win32-seh-rt_v6-rev0>echo off
Microsoft Windows [Version 10.0.19042.1110]
(c) Microsoft Corporation. Alle Rechte vorbehalten.

C:\> cd C:\\Users\\user\\Downloads\\putty-src_0-76\

C:\Users\user\Downloads\putty-src_0-76> cd windows

C:\Users\user\Downloads\putty-src_0-76\windows> mingw32-make -f Makefile.mgw
gcc  -Wall -O2 -std=gnu99 -Wvla -D_WINDOWS -DWIN32S_COMPAT -D_NO_OLDNAMES -D__USE_MINGW_ANSI_STDIO=1 -I.././ -I../charset/ -I../windows/ -I../unix/ -D_WIN32_IE=0x0500 -DWINVER=0x0500 -D_WIN32_WINDOWS=0x0410 -D_WIN32_WINNT=0x0500  -c ../ssh2userauth.c
gcc -s -o plink.exe -Wl,-Map,plink.map agentf.o aqsync.o \
        be_all_s.o be_misc.o callback.o clicons.o cmdline.o conf.o \
        console.o cproxy.o ecc.o errsock.o ldisc.o logging.o \
        mainchan.o marshal.o memory.o misc.o miscucs.o mpint.o \
        noterm.o nullplug.o pgssapi.o pinger.o plink.res.o portfwd.o \
        proxy.o raw.o rlogin.o sessprep.o settings.o ssh.o ssh1bpp.o \
        ssh1censor.o ssh1connection.o ssh1connection-client.o \
        ssh1login.o ssh2bpp.o ssh2bpp-bare.o ssh2censor.o \
        ssh2connection.o ssh2connection-client.o ssh2kex-client.o \
        ssh2transhk.o ssh2transport.o ssh2userauth.o sshaes.o \
        ssharcf.o sshargon2.o sshauxcrypt.o sshblake2.o sshblowf.o \
        sshccp.o sshcommon.o sshcrc.o sshcrcda.o sshdes.o sshdh.o \
        sshdss.o sshecc.o sshgssc.o sshhmac.o sshmac.o sshmd5.o \
        sshprng.o sshpubk.o sshrand.o sshrsa.o sshsh256.o sshsh512.o \
        sshsha.o sshsha3.o sshshare.o sshutils.o sshverstring.o \
        sshzlib.o stripctrl.o supdup.o telnet.o timing.o tree234.o \
        utils.o version.o wcwidth.o wildcard.o wincapi.o \
        wincliloop.o wincons.o windefs.o wingss.o winhandl.o \
        winhsock.o winmisc.o winmiscs.o winnet.o winnohlp.o \
        winnoise.o winnojmp.o winnpc.o winnps.o winpgntc.o \
        winplink.o winproxy.o winsecur.o winselcli.o winser.o \
        winshare.o winstore.o wintime.o winucs.o winx11.o x11fwd.o \
        -ladvapi32 -lcomdlg32 -lgdi32 -limm32 -lole32 -lshell32 \
        -luser32
gcc -s -o pscp.exe -Wl,-Map,pscp.map agentf.o aqsync.o be_misc.o \
        be_ssh.o callback.o clicons.o cmdline.o conf.o console.o \
        cproxy.o ecc.o errsock.o logging.o mainchan.o marshal.o \
        memory.o misc.o miscucs.o mpint.o nullplug.o pgssapi.o \
        pinger.o portfwd.o proxy.o pscp.o pscp.res.o psftpcommon.o \
        settings.o sftp.o sftpcommon.o ssh.o ssh1bpp.o ssh1censor.o \
        ssh1connection.o ssh1connection-client.o ssh1login.o \
        ssh2bpp.o ssh2bpp-bare.o ssh2censor.o ssh2connection.o \
        ssh2connection-client.o ssh2kex-client.o ssh2transhk.o \
        ssh2transport.o ssh2userauth.o sshaes.o ssharcf.o \
        sshargon2.o sshauxcrypt.o sshblake2.o sshblowf.o sshccp.o \
        sshcommon.o sshcrc.o sshcrcda.o sshdes.o sshdh.o sshdss.o \
        sshecc.o sshgssc.o sshhmac.o sshmac.o sshmd5.o sshprng.o \
        sshpubk.o sshrand.o sshrsa.o sshsh256.o sshsh512.o sshsha.o \
        sshsha3.o sshshare.o sshutils.o sshverstring.o sshzlib.o \
        stripctrl.o timing.o tree234.o utils.o version.o wcwidth.o \
        wildcard.o wincapi.o wincliloop.o wincons.o windefs.o \
        wingss.o winhandl.o winhsock.o winmisc.o winmiscs.o winnet.o \
        winnohlp.o winnoise.o winnojmp.o winnpc.o winnps.o \
        winpgntc.o winproxy.o winsecur.o winselcli.o winsftp.o \
        winshare.o winstore.o wintime.o winucs.o x11fwd.o -ladvapi32 \
        -lcomdlg32 -lgdi32 -limm32 -lole32 -lshell32 -luser32
gcc -s -o psftp.exe -Wl,-Map,psftp.map agentf.o aqsync.o \
        be_misc.o be_ssh.o callback.o clicons.o cmdline.o conf.o \
        console.o cproxy.o ecc.o errsock.o logging.o mainchan.o \
        marshal.o memory.o misc.o miscucs.o mpint.o nullplug.o \
        pgssapi.o pinger.o portfwd.o proxy.o psftp.o psftp.res.o \
        psftpcommon.o settings.o sftp.o sftpcommon.o ssh.o ssh1bpp.o \
        ssh1censor.o ssh1connection.o ssh1connection-client.o \
        ssh1login.o ssh2bpp.o ssh2bpp-bare.o ssh2censor.o \
        ssh2connection.o ssh2connection-client.o ssh2kex-client.o \
        ssh2transhk.o ssh2transport.o ssh2userauth.o sshaes.o \
        ssharcf.o sshargon2.o sshauxcrypt.o sshblake2.o sshblowf.o \
        sshccp.o sshcommon.o sshcrc.o sshcrcda.o sshdes.o sshdh.o \
        sshdss.o sshecc.o sshgssc.o sshhmac.o sshmac.o sshmd5.o \
        sshprng.o sshpubk.o sshrand.o sshrsa.o sshsh256.o sshsh512.o \
        sshsha.o sshsha3.o sshshare.o sshutils.o sshverstring.o \
        sshzlib.o stripctrl.o timing.o tree234.o utils.o version.o \
        wcwidth.o wildcard.o wincapi.o wincliloop.o wincons.o \
        windefs.o wingss.o winhandl.o winhsock.o winmisc.o \
        winmiscs.o winnet.o winnohlp.o winnoise.o winnojmp.o \
        winnpc.o winnps.o winpgntc.o winproxy.o winsecur.o \
        winselcli.o winsftp.o winshare.o winstore.o wintime.o \
        winucs.o x11fwd.o -ladvapi32 -lcomdlg32 -lgdi32 -limm32 \
        -lole32 -lshell32 -luser32
gcc -mwindows -s -o putty.exe -Wl,-Map,putty.map agentf.o \
        aqsync.o be_all_s.o be_misc.o callback.o cmdline.o conf.o \
        config.o cproxy.o dialog.o ecc.o errsock.o ldisc.o logging.o \
        mainchan.o marshal.o memory.o minibidi.o misc.o miscucs.o \
        mpint.o nullplug.o pgssapi.o pinger.o portfwd.o proxy.o \
        putty.res.o raw.o rlogin.o sessprep.o settings.o sizetip.o \
        ssh.o ssh1bpp.o ssh1censor.o ssh1connection.o \
        ssh1connection-client.o ssh1login.o ssh2bpp.o ssh2bpp-bare.o \
        ssh2censor.o ssh2connection.o ssh2connection-client.o \
        ssh2kex-client.o ssh2transhk.o ssh2transport.o \
        ssh2userauth.o sshaes.o ssharcf.o sshargon2.o sshauxcrypt.o \
        sshblake2.o sshblowf.o sshccp.o sshcommon.o sshcrc.o \
        sshcrcda.o sshdes.o sshdh.o sshdss.o sshecc.o sshgssc.o \
        sshhmac.o sshmac.o sshmd5.o sshprng.o sshpubk.o sshrand.o \
        sshrsa.o sshsh256.o sshsh512.o sshsha.o sshsha3.o sshshare.o \
        sshutils.o sshverstring.o sshzlib.o stripctrl.o supdup.o \
        telnet.o terminal.o timing.o tree234.o utils.o version.o \
        wcwidth.o wildcard.o wincapi.o wincfg.o winctrls.o windefs.o \
        windlg.o window.o wingss.o winhandl.o winhelp.o winhsock.o \
        winjump.o winmisc.o winmiscs.o winnet.o winnoise.o winnpc.o \
        winnps.o winpgntc.o winprint.o winproxy.o winsecur.o \
        winselgui.o winser.o winshare.o winstore.o wintime.o \
        winucs.o winutils.o winx11.o x11fwd.o -ladvapi32 -lcomdlg32 \
        -lgdi32 -limm32 -lole32 -lshell32 -luser32

C:\Users\user\Downloads\putty-src_0-76\windows>

Check the result

C:\Users\user\Downloads\putty-src_0-76\windows> dir putty.exe
 Datenträger in Laufwerk C: ist Windows
 Volumeseriennummer: 1E1B-0142

 Verzeichnis von C:\Users\user\Downloads\putty-src_0-76\windows

16.08.2021  20:16           981.504 putty.exe
               1 Datei(en),        981.504 Bytes
               0 Verzeichnis(se), 265.798.283.264 Bytes frei

C:\Users\user\Downloads\putty-src_0-76\windows>

EXEcute it

C:\Users\user\Downloads\putty-src_0-76\windows> putty.exe
Putty 0.76 – compiled on my own using „gcc 8.1.0“

Final thought: Donate PuTTY

It is possible 😉 to donate to the original PuTTY developers – look here: https://www.chiark.greenend.org.uk/~sgtatham/putty/faq.html#faq-donations

MinGW as build-environment for native Windows Applications

It is possible to complie open source software like „PuTTY“ using the famous gcc open source compiler.

Choose your favourite MinGW „distribution“

There are several  „distribution“-like packages available on the web.

I found https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download which worked „out of the box“.

Install MinGw

Just a few settings to think about, I chose:

I changed from the default-settings:

  • Version:8.1.0
  • Architecture:i686
  • Threads:posix
  • Exception:dwarf
  • Build Revision:0

to

  • Architecture:x86_64
  • Threads:win32
  • Exception:seh

Check the Windows „PATH“-Environment Variable

I should contain C:\\Program Files\\mingw-w64\\x86\_64-8.1.0-win32-seh-rt\_v6-rev0\\mingw64\\bin

Run a „MinGW-Terminal“

Using the following shortcut

Provision a Cisco CSR1000V-Router as Virtual-Box-VM with sliptreamed Configuration, wait until it’s up and open an Putty-SSH-Connection

The existing Windows-Comman-Script has been enhanced so it now

  • waits until the Router-VM is up
  • got an IP-Address assigned using DHCP.

For Demonstration-Purposes an SSH-Connection will be established.

  • The public-key of my laptop-ssh-client is part of the slipstreamed Router-Configuration.

Deploy a Router-VM with hostname „CSY“.

C:\RH\work\entwicklung\csr1000v-provision-in-virtualbox>CSR1000v-Virtual-Box.cmd CSY
Virtual machine 'CSY' is created and registered.
UUID: 915a7495-0728-4fc5-9c4c-21b3106a07e5
Settings file: 'c:\RH\LAB\VM\CSY\CSY.vbox'
Creating ISO image at c:\RH\LAB\VM\CSY\CSY_config.iso, 1 Files, Size: 8,00 KB
100%
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
Medium created. UUID: b79d708a-0a0a-4866-853b-3ac45c6a6127
Waiting for VM "CSY" to power on...
VM "CSY" has been successfully started.
Waiting for VM "CSY" to be initialized...
Router "CSY" up and running, using IP=192.168.56.102
Establishing SSH-Connection as "labuser"
Done

Establish an SSH-Connection to the discovered Router-IP:

Have a look to the startup-config used:

This is the „CMD“-Script used:

@echo off

: Ronald Heitmann

:set VM=CSR1000vX
:set /p VM="Enter CSR1000v Hostname:"
: Parameter given? Use it as VM-Name
set VM=%1
if not defined VM set /p VM="Enter CSR1000v Hostname:"

:echo %VM%

set PUTTYUSER=labuser
set PUTTYPK=C:\RH\work\putty\labuser.ppk


set BASE=c:\RH\LAB\VM

set ISO=C:\Downloads\csr1000v-universalk9.16.09.0x.iso

: Create VM
:VBoxManage createvm --name %VM% --ostype "Linux_64" --basefolder %BASE% --register
VBoxManage createvm --name %VM% --ostype "Linux26_64" --basefolder %BASE% --register

:now the Path in the Filesystem to ...LOC... exists
set LOC=%BASE%\%VM%

: Create ISO containing slipstreamed config-file
: use UNXTOOLS "sed" to customize the "hostname"-Command
:
set CFGISO=%LOC%\%VM%_config.iso
set CFGSRC=C:\RH\LAB\VM\iosxe_config.txt
set CFGTXT=%LOC%\iosxe_config.txt
cat %CFGSRC% | sed "s/HOSTNAME/%VM%/g" > %CFGTXT%
"%ProgramFiles(x86)%"\CDBurnerXP\cdbxpcmd.exe --burn-data -file:%CFGTXT% -iso:%CFGISO% -format:iso

: Customize VM
VBoxManage modifyvm %VM% --memory 4096
VBoxManage modifyvm %VM% --vram 16
VBoxManage modifyvm %VM% --pae on --paravirtprovider default --hwvirtex on --nestedpaging on

: Storage
VBoxManage createhd --filename %LOC%\%VM%.vdi --size 8192
VBoxManage storagectl %VM% --name "IDE-CTL" --add ide --portcount 2 --bootable on
VBoxManage storageattach %VM% --storagectl IDE-CTL --port 0 --device 0 --type hdd --medium %LOC%\%VM%.vdi
VBoxManage storageattach %VM% --storagectl IDE-CTL --port 1 --device 0 --type dvddrive --medium %ISO%
VBoxManage storageattach %VM% --storagectl IDE-CTL --port 1 --device 1 --type dvddrive --medium %CFGISO%
VBoxManage modifyvm %VM% --boot1=dvd --boot2=disk --boot3=none --boot4=none

: Serial-Interfaces via "Pipe"
VBoxManage modifyvm %VM% --uartmode1 server \\.\pipe\%VM%
VBoxManage modifyvm %VM% --uart1 0x3f8 4
VBoxManage modifyvm %VM% --uartmode2 server \\.\pipe\%VM%_diag
VBoxManage modifyvm %VM% --uart2 0x2f8 4

: Audio
VBoxManage modifyvm %VM% --audio none

: NICs
VBoxManage modifyvm %VM% --nic1 nat --nic2 hostonly --nic3 hostonly --nic4 hostonly
VBoxManage modifyvm %VM% --nictype1 virtio --nictype2 virtio --nictype3 virtio --nictype4 virtio
VBoxManage modifyvm %VM% --nicpromisc1 allow-all --nicpromisc2 allow-all --nicpromisc3 allow-all --nicpromisc4 allow-all
VBoxManage modifyvm %VM% --hostonlyadapter2 "VirtualBox Host-Only Ethernet Adapter"
VBoxManage modifyvm %VM% --hostonlyadapter3 "VirtualBox Host-Only Ethernet Adapter"
VBoxManage modifyvm %VM% --hostonlyadapter4 "VirtualBox Host-Only Ethernet Adapter"

: Set the VM-Logo for the VirtualBox-Inventory
VBoxManage modifyvm %VM% --iconfile C:\RH\LAB\72px-Cisco_logo.svg.png

: Boot the VM, it'l reboot once to apply the running-config
VBoxManage startvm %VM% --type headless

: Wait for the VM to be fully initialized
: - with DHCP-IP-Address at "Gig 2"
: - and store this IP-Address in Variable VMIP
echo Waiting for VM "%VM%" to be initialized...
for /f %%I in ('python WaitForCDPNeighbor.py -n %VM% -c -i "VirtualBox Host-Only Ethernet Adapter" 2^> nul') do @(set VMIP=%%I)

echo Router "%VM%" up and running, using IP=%VMIP%

: Connect to Router using Putty/SSH
echo Establishing SSH-Connection as "%PUTTYUSER%"
start putty -ssh -i %PUTTYPK% %PUTTYUSER%@%VMIP%

echo Done

Python: Combine NetIfaces, Scapy and IPAddress to find local connected network

You got the task to generate a list of IP-Networks connected to LAN „VirtualBox Host-Only Network“. There might be more than one IP-Network.

Use Scapy to crawl through all Interfaces and get the human-readable interface name [only required for windows users]. Use NetIfaces to get a list of IP-Addresses connected to this interface. Use IPAddress to calculate the IP-Network(s) directly connected.

! multiple IPs per Interface supporte
!
from netifaces import AF_INET, AF_INET6, AF_LINK
import netifaces

from scapy.all import *

import ipaddress


if_name = "VirtualBox Host-Only Network"
if_id = ""
if_inet = []

for i in ifaces.data.keys():
  iface = ifaces.data[i]
  wname = iface.data['netid']
  if wname == if_name:
    if_id = i
    addresses = netifaces.ifaddresses(i)
    if AF_INET in addresses:
      for addr in netifaces.ifaddresses(i)[AF_INET]:
        print(addr)
        ipaddr = ipaddress.ip_interface(addr["addr"]+"/"+addr["netmask"])
        ipnetwork = ipaddr.network
        print(ipaddr,ipnetwork)
        if_inet.append(ipnetwork)

print("NAME: {0}\nIP: {1}\nID: {2}".format(if_name,if_inet,if_id))

In my case, only one subnet is directly connected:

  • 192.168.56.0/24
...
{'addr': '192.168.56.1', 'netmask': '255.255.255.0', 'broadcast': '192.168.56.255'}
192.168.56.1/24 192.168.56.0/24
>>> print("NAME: {0}\nIP: {1}\nID: {2}".format(if_name,if_inet,if_id))
NAME: VirtualBox Host-Only Network
IP: [IPv4Network('192.168.56.0/24')]
ID: {D30DEC05-D495-4DA1-81F1-42B07885B0EB}
>>>

Python netifaces and scapy: Getting meaningful Interface-names and full IP-Adresses-/Netmask-Information

Using Windows:

  • scapy reads:
    • meaningful interface-names
    • ip-address
    • but no netmask
  • netifaces reads:
    • full Ethernet/IP/IPv6-Information
    • but no meaningful interface-names

Mixing both, provides everything needed.

  1. Netifaces only
  2. from netifaces import AF_INET, AF_INET6, AF_LINK
    import netifaces
    
    for i in netifaces.interfaces():
       niif=netifaces.ifaddresses(i)
       print("i",i)
       for k,v in niif.items():
         print("Key",k)
         if k==AF_LINK:
           print("LINK:",v)
         if k==AF_INET:
           print("IPv4",v)
         if k==AF_INET6:
           print("IPv6",v)
       print()
    
    >>> for i in netifaces.interfaces():
    ...    niif=netifaces.ifaddresses(i)
    ...    print("i",i)
    ...    for k,v in niif.items():
    ...      print("Key",k)
    ...      if k==AF_LINK:
    ...        print("LINK:",v)
    ...      if k==AF_INET:
    ...        print("IPv4",v)
    ...      if k==AF_INET6:
    ...        print("IPv6",v)
    ...    print()
    ...
    i {07E9D8A4-E167-4FFF-B851-61A20C49AE6E}
    Key -1000
    LINK: [{'addr': '00:00:81:00:de:11'}]
    Key 23
    IPv6 [{'addr': 'fe80::8400:abb0:2a62:a173%4', 'netmask': 'ffff:ffff:ffff:ffff::/64', 'broadcast': 'fe80::ffff:ffff:ffff:ffff%4'}]
    
    i {D30DEC05-D495-4DA1-81F1-42B07885B0EB}
    Key -1000
    LINK: [{'addr': '0a:00:27:00:00:14'}]
    Key 23
    IPv6 [{'addr': 'fe80::1e0:4a4:8afc:90f7%20', 'netmask': 'ffff:ffff:ffff:ffff::/64', 'broadcast': 'fe80::ffff:ffff:ffff:ffff%20'}]
    Key 2
    IPv4 [{'addr': '192.168.56.1', 'netmask': '255.255.255.0', 'broadcast': '192.168.56.255'}]
    
    i {402C453F-4B74-4883-9257-BD31FAB7AB57}
    Key -1000
    LINK: [{'addr': '74:70:fd:bd:10:38'}]
    Key 23
    IPv6 [{'addr': 'fe80::2599:368f:e80d:94b6%8', 'netmask': 'ffff:ffff:ffff:ffff::/64', 'broadcast': 'fe80::ffff:ffff:ffff:ffff%8'}]
    
    i {2120C2CA-E7D4-45DF-8090-A8D7F48EFF42}
    Key -1000
    LINK: [{'addr': '76:70:fd:bd:10:37'}]
    Key 23
    IPv6 [{'addr': 'fe80::34d6:9683:4af5:afad%6', 'netmask': 'ffff:ffff:ffff:ffff::/64', 'broadcast': 'fe80::ffff:ffff:ffff:ffff%6'}]
    
    i {F931F123-70A4-4CFB-BD9C-C0A509080286}
    Key -1000
    LINK: [{'addr': '74:70:fd:bd:10:37'}]
    Key 23
    IPv6 [{'addr': 'fe80::1926:3c29:1b34:e1f6%22', 'netmask': 'ffff:ffff:ffff:ffff::/64', 'broadcast': 'fe80::ffff:ffff:ffff:ffff%22'}]
    Key 2
    IPv4 [{'addr': '192.168.1.163', 'netmask': '255.255.255.0', 'broadcast': '192.168.1.255'}]
    
    i {693A5869-6A31-11E8-85D1-806E6F6E6963}
    Key -1000
    LINK: [{'addr': ''}]
    Key 23
    IPv6 [{'addr': '::1', 'netmask': 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff/128', 'broadcast': '::1'}]
    Key 2
    IPv4 [{'addr': '127.0.0.1', 'netmask': '255.0.0.0', 'broadcast': '127.255.255.255'}]
    
  3. Adding Scapy to get meaningful interface names
  4. from scapy.all import *
    
    for i in ifaces.data.keys():
      print(i)
      iface = ifaces.data[i]
      wname = iface.data['netid']
      addresses = netifaces.ifaddresses(i)
      af_inet = [{"addr": "0.0.0.0", "netmask": "0.0.0.0", "broadcast": "0.0.0.0"}]
      if AF_INET in addresses:
        af_inet = netifaces.ifaddresses(i)[AF_INET]
      print(wname,af_inet)
    
    >>> for i in ifaces.data.keys():
    ...   print(i)
    ...   iface = ifaces.data[i]
    ...   wname = iface.data['netid']
    ...   addresses = netifaces.ifaddresses(i)
    ...   af_inet = [{"addr": "0.0.0.0", "netmask": "0.0.0.0", "broadcast": "0.0.0.0"}]
    ...   if AF_INET in addresses:
    ...     af_inet = netifaces.ifaddresses(i)[AF_INET]
    ...   print(wname,af_inet)
    ...
    {F931F123-70A4-4CFB-BD9C-C0A509080286}
    Wi-Fi [{'addr': '192.168.1.163', 'netmask': '255.255.255.0', 'broadcast': '192.168.1.255'}]
    {D30DEC05-D495-4DA1-81F1-42B07885B0EB}
    VirtualBox Host-Only Network [{'addr': '192.168.56.1', 'netmask': '255.255.255.0', 'broadcast': '192.168.56.255'}]
    {07E9D8A4-E167-4FFF-B851-61A20C49AE6E}
    ETH_DELL [{'addr': '0.0.0.0', 'netmask': '0.0.0.0', 'broadcast': '0.0.0.0'}]
    
    

Python „netifaces“ installation: „Microsoft Visual C++ 14.0 is required“

I expected a nobrainer:

C:\RH>pip install netifaces
Collecting netifaces
  Downloading https://files.pythonhosted.org/packages/81/39/4e9a026265ba944ddf1fea176dbb29e0fe50c43717ba4fcf3646d099fe38/netifaces-0.10.7.tar.gz
Installing collected packages: netifaces
  Running setup.py install for netifaces ... error
    Complete output from command c:\users\rh\appdata\local\programs\python\python37\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\RH\\AppData\\Local\\Temp\\pip-install-wbfanly3\\netifaces\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\RONALD~1.HEI\AppData\Local\Temp\pip-record-m26yfbyt\install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_ext
    building 'netifaces' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

The suggested URL to download the missing software is wrong (HTTP 404).

  1. Go to the Microsoft-Repository Tools for Visual Studio 2017 or use the direct link to vs_buildtools.exe

    • …it’s about 1.2MB
  2. run „vs_buildtools.exe“
    • …it downloads ~ 70 MB
  3. Select „Workloads => Windows => [x] Visual C++ Build Tools“ => [Install]
    • …it downloads 1.12 GB
    • …and installs
  4. and … unlucky…

  5. reboot required

Now netifaces can get installed:

C:\RH>pip install netifaces
Collecting netifaces
  Using cached https://files.pythonhosted.org/packages/81/39/4e9a026265ba944ddf1fea176dbb29e0fe50c43717ba4fcf3646d099fe38/netifaces-0.10.7.tar.gz
Installing collected packages: netifaces
  Running setup.py install for netifaces ... done
Successfully installed netifaces-0.10.7

Windows Command Shell: Store the output of another command in a variable.

How often had i to look up this in the web, always wondering about myself still using the Windows-CMD-shell… Should move on to powershell…

store the output of another command in a variable

  • Example: the „date“-command
  • c:\RH\>date /T
    30.10.2018
    
  • Copy the date into the variable „TTT“
  • c:\RH\>for /f %D in ('date /T 2^> nul') do @(set TTT=%D)
    
    c:\RH\>echo %TTT%
    30.10.2018
    

Not elegant, not intuitive, not self-explanatory: This Shell Scripting language seems not to be made for daily usage 😉