Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImportError: No module named pylibmpsse #38

Closed
nikhilh-20 opened this issue Nov 25, 2019 · 9 comments
Closed

ImportError: No module named pylibmpsse #38

nikhilh-20 opened this issue Nov 25, 2019 · 9 comments

Comments

@nikhilh-20
Copy link

nikhilh-20 commented Nov 25, 2019

I'm new to IoT firmware RE and I was following the blog at https://nvisium.com/blog/2019/08/07/extracting-firmware-from-iot-devices.html.

The author mentioned the following command:
sudo python spiflash.py -s 15000000 -r firmware.bin

I git cloned this repository, ran the above command and got the error:
ImportError: No module named mpsse

So, I ran the mpsse.py file in the src directory and got the error:
ImportError: No module named pylibmpsse

What is this library? How do I get spiflash.py to execute?

More information:

root@malnet:/opt/libmpsse/src/examples# python spiflash.py 
Traceback (most recent call last):
  File "spiflash.py", line 3, in <module>
    from mpsse import *
ImportError: No module named mpsse

root@malnet:/opt/libmpsse/src# python mpsse.py 
Traceback (most recent call last):
  File "mpsse.py", line 1, in <module>
    import pylibmpsse as _mpsse
ImportError: No module named pylibmpsse

root@malnet:/opt/libmpsse/src# python examples/spiflash.py 
Traceback (most recent call last):
  File "examples/spiflash.py", line 3, in <module>
    from mpsse import *
ImportError: No module named mpsse

root@malnet:/opt/libmpsse/src/examples# uname -a
Linux malnet 4.19.0-kali5-amd64 #1 SMP Debian 4.19.37-5kali1 (2019-06-20) x86_64 GNU/Linux

root@malnet:/opt/libmpsse/src/examples# python -V
Python 2.7.16
@nikhilh-20 nikhilh-20 changed the title ImportError: No module named mpsse ImportError: No module named pylibmpsse Nov 25, 2019
@Brets0150
Copy link

Hello,
Did you resolve this issue? If so how? Running into the same problem myself.

@whoot
Copy link

whoot commented Sep 4, 2020

Hello,
Did you resolve this issue? If so how? Running into the same problem myself.

@Brets0150 The error says it clearly. Just install the missing library ;)
python2 -m pip install libmpsse

@nikhilh-20
Copy link
Author

I don't remember exactly what I did but I think I switched over to using flashrom for firmware extraction. @whoot's solution seems simple enough if it works.

@hassan-salloum
Copy link

hassan-salloum commented Sep 3, 2023

Hi guys, i would like to re-open this topic, after a lot of adaptation for the spiflash.py script, to make it work with python3, like:
1- add () for all print""
2- change the exception try from (except GetoptError, e:) to be (except getopt.GetoptError as e:)

Then i tried to run the script and i got this error:
image

After many search i didn't succeed to install the libmpss:
image

any suggestion please ? i am using kali linux 2023.2
thx

@whoot
Copy link

whoot commented Sep 3, 2023

As far as I know there is no Python 3 version of libmpsse.
However, you could try this patch here: #10

@hassan-salloum
Copy link

hassan-salloum commented Sep 3, 2023

@whoot thanks, well in that case i believe the best approach is to make the script run with python2 on latest kali version (in my case kali 2023.2)

These are my steps that can be a fix for this issue:

1- Change python version system-wide with update-alternatives python to temporary force it on python2 while using the spiflash.py script:. (Note: don't forget to switch back to your default python version once you finish using the script since your system packages will probably based on the lasted python version.)

2- Then i installed the missing library libmpsse (you need to install first the pip for python2):

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
python2 -m pip install libmpsse

3- Libmpsse requires swig as well as the libftdi and python development packages. as mentioned here.

in case you are using latest debian version like kali 2023.2, this command may not work:
image

so use this instead:
image

Result:
image

image

To fix this as well : please added (import getopt) to the spiflash.py code
image
like that:
image

@whoot
Copy link

whoot commented Sep 4, 2023

@whoot thanks, well in that case i believe the best approach is to make the script run with python2 on latest kali version (in my case kali 2023.2)

These are my steps that can be a fix for this issue:

1- Change python version system-wide with update-alternatives python to temporary force it on python2 while using the spiflash.py script:. (Note: don't forget to switch back to your default python version once you finish using the script since your system packages will probably based on the lasted python version.)

This should not be necessary. Kali has python2 already installed.

@hassan-salloum
Copy link

hassan-salloum commented Sep 4, 2023

@whoot Yes its necessary, and my steps not about installing python2. You have to read with attention my steps. But i will explain:
1- new version kali linux once you install, dominate python3. and in case you need to use python2 you need to update-alternative (sometime)
2- pip for python2 not installed by default on new kali version, you have to install.

None of my steps was without a POC (you can see the screenshoot ! )

The best thing you can do is to install kali linux 2023.2 VM and try with python2 to run the spiflash script directly without my steps and you will understand the struggle i passed.

@whoot
Copy link

whoot commented Sep 5, 2023

I just said that you should use python2, because there is no support for python3.
You got it working, so everything is fine, right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants