I found a couple of guides online about how to get the python Impacket scripts working on Windows, but they didn’t quite work for me (on Windows 7 x64) so here’s what I ended up having to do:
- Download and install the X86 version of Python 2.7 from here (has to be version 2.x, not version 3.x): https://www.python.org/download/releases/2.7/
- Download and install the Win32 version of PyCrypto for Python 2.7 from here: http://www.voidspace.org.uk/python/pycrypto-2.6.1/pycrypto-2.6.1.win32-py2.7.msi
- Open command prompt as Administrator and run the following commands:
pip install pyasn1
pip install pyasn1-modules
pip install impacket
After that you should be good to go, and if you navigate to C:\Python27\Scripts you can run the Impacket scripts like GetNPUsers.py or GetUserSPNs.py etc
The important part that got this all working for me was the pip install pyasn1-modules command. The other guide I found online did not include that, so whenever I tried to run an Impacket script I got an error stating “No module named pyasn1.codec.der”. Once I had done the pyasn1-modules install though, then ran the impacket install again, all worked fine.
One other tip is to add the C:\Python27 directory and the C:\Python27\Scripts directory to your PATH environment variable. There’s plenty of guides online about how to do that if you’re not sure. Once you’ve done this then you can run the Impacket scripts from anywhere and don’t have to navigate to the C:\Python27\Scripts folder first.