pr0v3rbs / FirmAE

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

PostgreSQL not initialized correctly #7

Closed 0BuRner closed 3 years ago

0BuRner commented 3 years ago

Hello,

I follow the README but got some issue when trying to emulate the firmware.

My command: sudo ./run.sh -c dlink ./firmwares/DIR868L_B1_FW205WWb02.bin Result:

[*] ./firmwares/DIR868L_B1_FW205WWb02.bin emulation start!!!
[-] extract failed

I found out the ./install.sh need to be run with sudo because my postgres server wasn't initialized correctly (no user firmadyne, no database firmware were existing).

After creating initialized the database correctly, it went further.

I'm running Ubuntu 20.04 on WSL2.

pr0v3rbs commented 3 years ago

I only tested the FirmAE on Ubuntu 18.04 LTS in VMware. And in my environment, the emulation was successful.

I think that your debug message is generated while emulating with docker-helper.py. And maybe the docker container failed to connect to the hosts' PostgreSQL.

I updated the code to check the connection of the PostgreSQL (fedc1af248e6e330e78002a9085f9a1632b0e337), please check your PostgreSQL or restart the service.

0BuRner commented 3 years ago

I'm not using Docker... I will try to explain in another way:

I installed following the README. At step 3, it says :

Run install.sh script.
$ ./install.sh

Which I did. The next step is to run ./init.sh that in fact simply restart postgresql service. After this step, I tried with a SQL Database explorer tool to connect to the database but I wasn't able to. Then I saw that the default user firmadyne was not created and the user postgres (the default user) is the only one available.

To me, it means there is some issue with the command that initialize the database by creating the user and tables structures. This command can be found in install.sh:12. This command was not successfully executed.

I don't really know why, I thought it was because install.sh was not run as superuser...

But yeah at least your change will warn the user if database was not correctly initialized.

pr0v3rbs commented 3 years ago

I changed the PostgreSQL start command before adding firmadyne user.

Please check it e9153e41226e0cc06b6bf77efa6e171f7be657fa.

Thank you.