pr0v3rbs / FirmAE

Towards Large-Scale Emulation of IoT Firmware for Dynamic Analysis
MIT License
603 stars 117 forks source link

Extracting root filesystem failed #55

Open DrizzlingSun opened 1 year ago

DrizzlingSun commented 1 year ago

root@attifyos:/home/iot/tools/firmAE/FirmAE# ./run.sh -c dlink /home/iot/tools/firmware-analysis-toolkit/DIR816.img [*] /home/iot/tools/firmware-analysis-toolkit/DIR816.img emulation start!!!

General Error: Cannot open file --run-as=root (CWD: /tmp/tmpuhbydzva) : [Errno 2] No such file or directory: '--run-as=root'

General Error: Cannot open file --preserve-symlinks (CWD: /tmp/tmpuhbydzva) : [Errno 2] No such file or directory: '--preserve-symlinks'

Traceback (most recent call last): File "./sources/extractor/extractor.py", line 446, in extract File "/usr/local/lib/python3.6/dist-packages/binwalk/init.py", line 10, in scan objs = m.execute() File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 784, in execute obj = self.run(module) File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 803, in run obj = self.load(module, kwargs) File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 834, in load argv.update(self.dependencies(module, argv['enabled'])) File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 866, in dependencies raise ModuleException("Failed to load " + dependency.name + " module") binwalk.core.exceptions.ModuleException: Failed to load General module

General Error: Cannot open file --run-as=root (CWD: /tmp/tmpmm1kal4s) : [Errno 2] No such file or directory: '--run-as=root'

General Error: Cannot open file --preserve-symlinks (CWD: /tmp/tmpmm1kal4s) : [Errno 2] No such file or directory: '--preserve-symlinks'

Traceback (most recent call last): File "./sources/extractor/extractor.py", line 446, in extract File "/usr/local/lib/python3.6/dist-packages/binwalk/init.py", line 10, in scan objs = m.execute() File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 784, in execute obj = self.run(module) File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 803, in run obj = self.load(module, kwargs) File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 834, in load argv.update(self.dependencies(module, argv['enabled'])) File "/usr/local/lib/python3.6/dist-packages/binwalk/core/module.py", line 866, in dependencies raise ModuleException("Failed to load " + dependency.name + " module") binwalk.core.exceptions.ModuleException: Failed to load General module [-] Extracting root filesystem failed! root@attifyos:/home/iot/tools/firmAE/FirmAE#

pr0v3rbs commented 1 year ago

Currently, FirmAE uses binwalk 2.3.3.

Please check your binwalk version.

fdgnneig commented 1 year ago

I had the same problem, and I'm sure my binwalk is version 2.3.3 Binwalk v2.3.3+28f7eb4

fdgnneig commented 1 year ago

Installed in ununtu20.04 can be used normally

pr0v3rbs commented 1 year ago

I can't reproduce the situation on the cleanly installed system in ubuntu 20.04.

The current version of the binwalk can be checked in the python3 with this command import binwalk; binwalk.__version__. (In the root)

If the version is not correct, please re-install the binwalk using this command (https://github.com/pr0v3rbs/FirmAE/blob/master/install.sh#L25-L31)

The binwalk need to be installed in the root.

nhtri2003gmail commented 1 year ago

Hey @pr0v3rbs, the binwalk repo has file deps.sh, which is corrupted due to a change of repo ubi_reader, hence that file cannot work properly. But just installing using command sudo python3 setup.py install as instructed of binwalk will install binwalk. Then we just need to install sasquatch to make FirmAE work.

I modified the install.sh file of FirmAE a bit so it can install binwalk and work properly

Result of diff:

--- install.sh  2023-05-29 11:48:56.740200200 +0700
+++ install_modified.sh 2023-05-29 12:03:27.027966600 +0700
@@ -26,13 +26,19 @@
 wget https://github.com/ReFirmLabs/binwalk/archive/refs/tags/v2.3.3.tar.gz && \
   tar -xf v2.3.3.tar.gz && \
   cd binwalk-2.3.3 && \
-  sed -i 's/^install_unstuff//g' deps.sh && \
-  echo y | ./deps.sh && \
-  sudo python3 setup.py install
+  sudo python3 setup.py install && \
+  sudo apt-get install build-essential liblzma-dev liblzo2-dev zlib1g-dev && \
+  git clone https://github.com/devttys0/sasquatch && \
+  cd sasquatch/patches && \
+  wget https://github.com/devttys0/sasquatch/files/7776843/M1-Kali.patch.txt && \
+  patch patch0.txt M1-Kali.patch.txt && \
+  cd .. && \
+  echo "y" | ./build.sh && \
+  cd .. && \
+  rm -rf sasquatch && \
+  cd ..
 sudo apt-get install -y mtd-utils gzip bzip2 tar arj lhasa p7zip p7zip-full cabextract fusecram cramfsswap squashfs-tools sleuthkit default-jdk cpio lzop lzma srecord zlib1g-dev liblzma-dev liblzo2-dev unzip

-cd - # back to root of project
-
 sudo cp core/unstuff /usr/local/bin/

 python3 -m pip install python-lzo cstruct ubi_reader

install.sh.zip

cnitlrt commented 7 months ago

I solved this issue using the following command Maybe could help you

sudo apt-get autoremove binwalk
cd binwalk-2.3.4
sudo python3 setup.py install