impacket module not found but installed

edited December 2020 in Exploits

Hey guys, I hope you can help me.
I'm trying to execute a python script and get following error:

$ python test.py
Traceback (most recent call last):
File "test.py", line 11, in <module
from impacket import smb
ImportError: No module named impacket

The impacket module is installed as you can see:

$ pip show impacket
Name: impacket
Version: 0.9.23.dev1+20201209.133255.ac307704
Summary: Network protocols Constructors and Dissectors
Home-page: https://www.secureauth.com/labs/open-source-tools/impacket
Author: SecureAuth Corporation
Author-email: [email protected]
License: Apache modified
Location: /usr/local/lib/python3.9/dist-packages
Requires: ldapdomaindump, pycryptodomex, pyasn1, six, ldap3, pyOpenSSL, flask
Required-by:

Content of my test file:

cat test.py
#!/usr/bin/python

import struct
import time
import sys

from threading import Thread #Thread is imported incase you would like to modify

from impacket import smb
from impacket import uuid
from impacket import dcerpc
from impacket.dcerpc.v5 import transport

print('works')

I already uninstalled impacket via pip and also get impacket from git and install it from there. But still no luck.

Tagged:

Comments

  • Hard to be sure but the likely issue is you have Impacket installed in a different version of python than your script is calling.

    Note: I am not going to be available much in September.

    TazWake

    Note: https://www.nohello.com/

    Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.

  • Type your comment> @TazWake said:

    Hard to be sure but the likely issue is you have Impacket installed in a different version of python than your script is calling.

    Hey TazWake, thx for you response.
    Well, I've copied just the import section from the following script (searched via searchsploit) to test why it does not work exactly:

    Microsoft Windows - 'NetAPI32.dll' Code Execution (Python) (MS08-067) | windows/remote/40279.py

    Any ideas how to be sure if maybe the version of impacket is wrong.

  • You could try python --version to see what the default runs as. If you have it installed in python3 you may need to specify that on the command line, or with python2 if you have it that way round.

    I've no idea about the version of impacket.

    Note: I am not going to be available much in September.

    TazWake

    Note: https://www.nohello.com/

    Happy to help people but PLEASE explain your problem in as much detail as possible! If you say vague things like "It's not working", I cant help. This isn't Twitter so my DMs are always open.

  • edited December 2020

    Finannly found a solution, after hours of googling.

    See here: https://twitter.com/pry0cc/status/1323294727261868032

    Long story short:
    pip uninstall impacket

    Install pip2:
    curl bootstrap.pypa.io/get-pip.py -o get-pip.py; python2 get-pip.py
    python2 get-pip.py

    Then pip2 install impacket

  • Yeah python is being bonkers over the last new updates.
    Lots of stuff broken. You just have to find a way to install the missing packages in a lot of them but python2 -m pip or python3 -m pip is your friend.

Sign In to comment.