Closed r00tb3 closed 6 years ago
The scripts are intended to be run on Python 2.7 and wont work with other versions.
Looking at the error trace, the database is probably not configured. Can you try the steps below
sudo apt-get install postgresql
sudo -u postgres createuser -P firmadyne
, with password firmadyne
sudo -u postgres createdb -O firmadyne firmware
sudo -u postgres psql -d firmware < ./firmadyne/database/schema
@extremecoders-re
I've already followed the steps above but now I'm stuck on this:--
Welcome to the Firmware Analysis Toolkit - v0.2
Offensive IoT Exploitation Training - http://offensiveiotexploitation.com
By Attify - https://attify.com | @attifyme
[?] Enter the name or absolute path of the firmware you want to analyse : AP699E8C.CW125A-5-DLINK-R1B011D81870(0519085924)(1).img
[?] Enter the brand of the firmware : dlink
[+] Now going to extract the firmware. Hold on..
[+] Firmware : AP699E8C.CW125A-5-DLINK-R1B011D81870(0519085924)(1).img
[+] Brand : dlink
[+] Database image ID : 1
[+] Identifying architecture
[+] Architecture : line 7: ${/home/myuser/re-tools/firmadyne}/binaries/: bad substitution
Traceback (most recent call last):
File "./fat.py", line 122, in <module>
main()
File "./fat.py", line 114, in main
arch = identify_arch(image_id)
File "./fat.py", line 62, in identify_arch
child.expect("Password for user firmadyne: ")
File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 341, in expect
timeout, searchwindowsize, async_)
File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 369, in expect_list
return exp.expect_loop(timeout)
File "/usr/local/lib/python2.7/dist-packages/pexpect/expect.py", line 114, in expect_loop
return self.eof(e)
File "/usr/local/lib/python2.7/dist-packages/pexpect/expect.py", line 61, in eof
raise EOF(msg)
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
<pexpect.pty_spawn.spawn object at 0x7ff94f4578d0>
command: /home/myuser/re-tools/firmadyne/scripts/getArch.sh
args: ['/home/myuser/re-tools/firmadyne/scripts/getArch.sh', './images/1.tar.gz']
buffer (last 100 chars): ''
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: 1
flag_eof: True
pid: 4434
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
0: re.compile("Password for user firmadyne: ")
I figured out what the prob was...
In firmadyne.config the var FIRMWARE_DIR I mistakenly replaced the var to my location of firmadyne and messed up everything now I've set the var correctly and everything is working fine.
Thanks for the support.
root@kali:~/firmware-analysis-toolkit/firmadyne# python fat.py
__ _
/ _| | |
| |_ __ _ | |_
| _| / _` | | __|
| | | (_| | | |_
|_| \__,_| \__|
Welcome to the Firmware Analysis Toolkit - v0.2
Offensive IoT Exploitation Training - http://offensiveiotexploitation.com
By Attify - https://attify.com | @attifyme
[?] Enter the name or absolute path of the firmware you want to analyse : DIR830LA1_FW100B07.bin
[?] Enter the brand of the firmware : dlink
[+] Now going to extract the firmware. Hold on..
[+] Firmware : DIR830LA1_FW100B07.bin
[+] Brand : dlink
[+] Database image ID : 1
[+] Identifying architecture
[+] Architecture : mipseb
[+] Storing filesystem in database
[+] Building QEMU disk image
[+] Setting up the network connection, please standby
Traceback (most recent call last):
File "fat.py", line 122, in
File "fat.py", line 90, in setup_network
child.expect("Interfaces:", timeout=None)
File "/usr/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 321, in expect
timeout, searchwindowsize, async)
File "/usr/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 345, in expect_list
return exp.expect_loop(timeout)
File "/usr/lib/python2.7/dist-packages/pexpect/expect.py", line 105, in expect_loop
return self.eof(e)
File "/usr/lib/python2.7/dist-packages/pexpect/expect.py", line 50, in eof
raise EOF(msg)
pexpect.exceptions.EOF: End Of File (EOF). Exception style platform.
<pexpect.pty_spawn.spawn object at 0xb75bf66c>
command: /usr/bin/sudo
args: ['/usr/bin/sudo', '/root/firmware-analysis-toolkit/firmadyne//scripts/inferNetwork.sh', '1', 'mipseb']
buffer (last 100 chars): ''
before (last 100 chars): 'e-analysis-toolkit/firmadyne//scripts//run.mipseb.sh: line 25: qemu-system-mips: command not found\r\n'
after: <class 'pexpect.exceptions.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 6876
child_fd: 5
closed: False
timeout: 30
delimiter: <class 'pexpect.exceptions.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
searcher: searcher_re:
0: re.compile("Interfaces:")
@V33RU From the error trace, it looks like qemu-system-mips
is not installed.
command: /usr/bin/sudo
args: ['/usr/bin/sudo', '/root/firmware-analysis-toolkit/firmadyne//scripts/inferNetwork.sh', '1', 'mipseb']
buffer (last 100 chars): ''
before (last 100 chars): 'e-analysis-toolkit/firmadyne//scripts//run.mipseb.sh: line 25: qemu-system-mips: command not found\r\n'
You can run qemu-system-mips
in a terminal to check whether its installed properly.
To install just qemu-system-mips you can run sudo apt-get install qemu-system-mips
or alternatively sudo apt-get install qemu-system
to install qemu for all supported archs.
maybe you need try your binwalk and see if it works correctly.
I've had the same problem. It's been bothering me for a long time. However, I don't think the problem arises from the wrong path. What should I do?
`root@lessiewang-Lenovo-Product:/home/lessiewang/firmware-analysis-toolkit/firmadyne# '/home/lessiewang/firmware-analysis-toolkit/firmadyne/fat.py'
__ _
/ _| | |
| |_ __ _ | |_
| _| / _` | | __|
| | | (_| | | |_
|_| \__,_| \__|
Welcome to the Firmware Analysis Toolkit - v0.2
Offensive IoT Exploitation Training - http://offensiveiotexploitation.com
By Attify - https://attify.com | @attifyme
[?] Enter the name or absolute path of the firmware you want to analyse : '/home/lessiewang/firmware-analysis-toolkit/firmadyne/wr841nv9_wr841ndv9_en_3_16_9_up_boot(150310).bin'
[?] Enter the brand of the firmware : dlink
[+] Now going to extract the firmware. Hold on..
[+] Firmware : '/home/lessiewang/firmware-analysis-toolkit/firmadyne/wr841nv9_wr841ndv9_en_3_16_9_up_boot(150310).bin'
[+] Brand : dlink
Traceback (most recent call last):
File "/home/lessiewang/firmware-analysis-toolkit/firmadyne/fat.py", line 122, in
after: <class 'pexpect.exceptions.EOF'> match: None match_index: None exitstatus: None flag_eof: True pid: 31920 child_fd: 5 closed: False timeout: None delimiter: <class 'pexpect.exceptions.EOF'> logfile: None logfile_read: None logfile_send: None maxread: 2000 ignorecase: False searchwindowsize: None delaybeforesend: 0.05 delayafterclose: 0.1 delayafterterminate: 0.1 searcher: searcher_re: 0: re.compile('Database Image ID: ') `
I've had the same problem. It's been bothering me for a long time. However, I don't think the problem arises from the wrong path. What should I do?
`root@lessiewang-Lenovo-Product:/home/lessiewang/firmware-analysis-toolkit/firmadyne# '/home/lessiewang/firmware-analysis-toolkit/firmadyne/fat.py'
__ _ / _| | | | |_ __ _ | |_ | _| / _` | | __| | | | (_| | | |_ |_| \__,_| \__| Welcome to the Firmware Analysis Toolkit - v0.2 Offensive IoT Exploitation Training - http://offensiveiotexploitation.com By Attify - https://attify.com | @attifyme
[?] Enter the name or absolute path of the firmware you want to analyse : '/home/lessiewang/firmware-analysis-toolkit/firmadyne/wr841nv9_wr841ndv9_en_3_16_9_up_boot(150310).bin' [?] Enter the brand of the firmware : dlink [+] Now going to extract the firmware. Hold on.. [+] Firmware : '/home/lessiewang/firmware-analysis-toolkit/firmadyne/wr841nv9_wr841ndv9_en_3_16_9_up_boot(150310).bin' [+] Brand : dlink Traceback (most recent call last): File "/home/lessiewang/firmware-analysis-toolkit/firmadyne/fat.py", line 122, in main() File "/home/lessiewang/firmware-analysis-toolkit/firmadyne/fat.py", line 109, in main image_id = run_extractor(firm_name, firm_brand) File "/home/lessiewang/firmware-analysis-toolkit/firmadyne/fat.py", line 48, in runextractor child.expect("Database Image ID: ") File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 341, in expect timeout, searchwindowsize, async) File "/usr/local/lib/python2.7/dist-packages/pexpect/spawnbase.py", line 369, in expect_list return exp.expect_loop(timeout) File "/usr/local/lib/python2.7/dist-packages/pexpect/expect.py", line 117, in expect_loop return self.eof(e) File "/usr/local/lib/python2.7/dist-packages/pexpect/expect.py", line 63, in eof raise EOF(msg) pexpect.exceptions.EOF: End Of File (EOF). Exception style platform. <pexpect.pty_spawn.spawn object at 0x7fd9fd514090> command: /home/lessiewang/firmware-analysis-toolkit/firmadyne/sources/extractor/extractor.py args: ['/home/lessiewang/firmware-analysis-toolkit/firmadyne/sources/extractor/extractor.py', '-b', 'dlink', '-sql', '127.0.0.1', '-np', '-nk', "'/home/lessiewang/firmware-analysis-toolkit/firmadyne/wr841nv9_wr841ndv9_en_3_16_9_up_boot(150310).bin' ", 'images'] buffer (last 100 chars): ''
after: <class 'pexpect.exceptions.EOF'> match: None match_index: None exitstatus: None flag_eof: True pid: 31920 child_fd: 5 closed: False timeout: None delimiter: <class 'pexpect.exceptions.EOF'> logfile: None logfile_read: None logfile_send: None maxread: 2000 ignorecase: False searchwindowsize: None delaybeforesend: 0.05 delayafterclose: 0.1 delayafterterminate: 0.1 searcher: searcher_re: 0: re.compile('Database Image ID: ') `
Can you please tell me the exact setup by which you actually installed all the tools, because looking at the log it looks more like a bit of a misconfig issue.
Thank you for your patient help
The following is the beginning of firmadyne.config `#!/bin/sh
FIRMWARE_DIR=/home/lessiewang/firmware-analysis-toolkit/firmadyne/
BINARY_DIR=${FIRMWARE_DIR}/binaries/ TARBALL_DIR=${FIRMWARE_DIR}/images/ SCRATCH_DIR=${FIRMWARE_DIR}/scratch/ SCRIPT_DIR=${FIRMWARE_DIR}/scripts/
The following is the beginning of fat.py
`#!/usr/bin/python
import os import pexpect import sys
firmadyne_path = "/home/lessiewang/firmware-analysis-toolkit/firmadyne" binwalk_path = "/home/lessiewang/firmware-analysis-toolkit/binwalk"`
In my case, the same issue was resolved by having the fat.py file in the same directory as that of firmadyne directory. It might be the issue as I find no problems with your installation and path specs and just for confirmation check your binwalk path as well, sometimes that might also cause an issue.
Thank you for your sincere suggestion. I tried it, but it didn't seem to work. I'll try something else. If it works, I'll come back.
Could this be the reason, the extractor.py mention password is toor.
self.database = psycopg2.connect(database="firmware", user="firmadyne", password="toor",
However, the installation manual say the default password is firmadyne
firmadyne@47c379a86a91:/firmadyne$ ./fat.py
__ _
/ _| | |
| |_ __ _ | |_
| _| / _` | | __|
| | | (_| | | |_
|_| \__,_| \__|
Welcome to the Firmware Analysis Toolkit - v0.2
Offensive IoT Exploitation Training - http://offensiveiotexploitation.com
By Attify - https://attify.com | @attifyme
[?] Enter the name or absolute path of the firmware you want to analyse : /firmadyne/firmware/netgear.zip
[?] Enter the brand of the firmware : netgear
[+] Now going to extract the firmware. Hold on..
[+] Firmware : /firmadyne/firmware/netgear.zip
[+] Brand : netgear
[+] Database image ID : 1
[+] Identifying architecture
[+] Architecture : mipseb
Traceback (most recent call last):
File "./fat.py", line 125, in
sudo ./fat.py Gaw5.6T02-4-DL-R1B020-ME.EN_upgrade(0322113411).en_upgrade
__ _
/ _| | |
| |_ __ _ | |_
| _| / _` | | __|
| | | (_| | | |_
|_| \__,_| \__|
Welcome to the Firmware Analysis Toolkit - v0.3
Offensive IoT Exploitation Training http://bit.do/offensiveiotexploitation
By Attify - https://attify.com | @attifyme
[+] Firmware: Gaw5.6T02-4-DL-R1B020-ME.EN_upgrade(0322113411).en_upgrade
[+] Extracting the firmware...
Traceback (most recent call last):
File "/home/ayman/Downloads/firmware-analysis-toolkit/firmadyne/./fat.py", line 172, in
help please
I'm getting the following error:--
Tried with python2.7/3/3.5 it runs only with 2.7 with the error above.
After going through closed issues I figured out to move the fat.py and reset.py to firmadyne directory and start the PostgreSQL service but now I get the following error:--
To bypass the authentication error this worked for me :--
sudo apt-get install postgresql
sudo -u postgres createuser -P firmadyne, with password firmadyne
sudo -u postgres createdb -O firmadyne firmware
After that running fat.py gives me EOF error again:--
I guess the problem is with the database ID but I don't know how to resolve!!
Please help me resolve. Thanks!