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

Image extraction failed #50

Closed
CaledoniaProject opened this issue Jul 29, 2020 · 8 comments
Closed

Image extraction failed #50

CaledoniaProject opened this issue Jul 29, 2020 · 8 comments

Comments

@CaledoniaProject
Copy link

I'm trying to emulate the firmware provided in your blog post

And it failed somewhere:

[+] Firmware: WNAP320.zip
[+] Extracting the firmware...
[!] Image extraction failed

What can I do now?

@extremecoders-re
Copy link
Collaborator

Are you using the latest Firmware Analysis Toolkit? FAT has been updated since the blog post. In particular the PostGreSQL dependency has been removed.

@CaledoniaProject
Copy link
Author

CaledoniaProject commented Jul 31, 2020

Steps to reproduce:

  1. Start Ubuntu 20.04
  2. Download master branch and execute setup.sh with ROOT

And I see this error (Ubuntu is shipped with python3 now)

sudo: pip: command not found

And in setup.sh both pip and pip3 are used, is that a mistake?

sudo -H pip3 install git+https://github.com/ahupp/python-magic
sudo -H pip install git+https://github.com/sviehb/jefferson
cd ..

I executed pip3 for jefferson manually and it runs into another error

Traceback (most recent call last):
  File "./fat.py", line 5, in <module>
    import pexpect
ModuleNotFoundError: No module named 'pexpect'

So I manually installed pexpect with pip3

pip3 install pexpect

And started emulation.

# ./fat.py WNAP320\ Firmware\ Version\ 2.0.3.zip

                               __           _
                              / _|         | |
                             | |_    __ _  | |_
                             |  _|  / _` | | __|
                             | |   | (_| | | |_
                             |_|    \__,_|  \__|

                Welcome to the Firmware Analysis Toolkit - v0.3
    Offensive IoT Exploitation Training http://bit.do/offensiveiotexploitation
                  By Attify - https://attify.com  | @attifyme

[+] Firmware: WNAP320 Firmware Version 2.0.3.zip
[+] Extracting the firmware...
[!] Image extraction failed

It stuck for a few minutes and finally failed.

@extremecoders-re
Copy link
Collaborator

Thank you for the detailed steps. I was able to reproduce the issue.

The main reason is because several Python 2 related packages have been removed from Ubuntu 20.04. Unfortunately we cannot just switch to Python 3 yet because some of the dependencies of firmadyne specifically require Python 2. For example, while installing Binwalk manually, it immediately complained about the following missing packages.

python-pip
cramfsprogs
python-lzo
python-lzma

So as of now you have to stick to Ubuntu 18.04 or lower.

@CaledoniaProject
Copy link
Author

CaledoniaProject commented Aug 1, 2020

This is still needed on Ubuntu 16.04, ./setup.sh does not install them:

apt install -y unzip python-pip
pip install pexpect

@CaledoniaProject
Copy link
Author

Also, please consider add set -e to the script

@extremecoders-re
Copy link
Collaborator

Added set -e

unzip and python-pip are already specified.

sudo apt install -y python-pip python3-pip python3-pexpect unzip busybox-static fakeroot kpartx snmp uml-utilities util-linux vlan qemu-system-arm qemu-system-mips qemu-system-x86 qemu-utils

We are using python3-pexpect installed by apt.

Just tested on a 16.04 LXC container and it's working as expected.

@CaledoniaProject
Copy link
Author

There is a python error during installation, but seems harmless:

Collecting matplotlib
  Downloading https://files.pythonhosted.org/packages/7d/d4/e4c40c62cd8608ca09f0684e64139c56512e195f2351ac41a472d4dc8b38/matplotlib-3.3.0.tar.gz (38.8MB)
    100% |████████████████████████████████| 38.8MB 47kB/s
    Complete output from command python setup.py egg_info:

    Beginning with Matplotlib 3.1, Python 3.6 or above is required.
    You are using Python 3.5.2.

    This may be due to an out of date pip.

    Make sure you have pip >= 9.0.1.


    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-hzk7vw11/matplotlib/

Everything worked today. I was on a minimal Ubuntu Server 16.04 installation.

Thanks!

@jollytrivedi2019
Copy link

I am getting the same error while I am trying to extract the Firmware.

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

3 participants