fkie-cad / FACT_core

Firmware Analysis and Comparison Tool
https://fkie-cad.github.io/FACT_core
GNU General Public License v3.0
1.18k stars 224 forks source link

why are there missing files #820

Open Oren-i opened 2 years ago

Oren-i commented 2 years ago

For some firmware images, the analysis never finishes, and there are missing files in the Admin/Find Missing Analysis tab.

Is this expected? In case no, how can I see what it went wrong to fix it? There are no messages on the Logs tab, and I am using FACT_docker.

jstucke commented 1 year ago

Hi,

For some firmware images, the analysis never finishes

Do you mean that entries in "Currently analyzed firmware" (/system_health) never complete? That could happen if there are errors during analysis or unpacking and the file gets lost during scheduling (but it should obviously not happen). Since there don't seem to be any helpful log messages, it could be complicated to debug the problem. Did you maybe see any errors or stack traces in the terminal output (docker logs could help here since you are using FACT_docker)? There could be unexpected errors that don't result in log messages.

Oren-i commented 1 year ago

Do you mean that entries in "Currently analyzed firmware" (/system_health) never complete?

Correct.

I rerun the test and reproduced the error, but I now see that there is a time out exception that seems to be not handled correctly, maybe because when handling an exception other exceptions were raised. Attached is the exception log message. fact_log.txt

The extractor that seems to take a long time before the exception is binwalk as seen by ps.

jstucke commented 1 year ago

The error is indeed not handled correctly. Nevertheless, it is also not clear what caused the error in the first place. Was it a particularly large or in some other way unusual file? Running binwalk usually takes some time for large files (which may be the cause of the timeout). You could also try to run the extractor manually on the file as documented here to maybe see what causes the error.

Oren-i commented 1 year ago

The issue here I think is that binwalk does indeed take too much time for some files, and that FACT_core does not correctly handle timeouts in FACT_extractor. In some cases binwalk extracts bogus data and as FACT_extractor is called in a recursive manner, a very large file can be sent to binwalk for further extraction.

Feel free to assign this to me.

jstucke commented 1 year ago

We are always happy to receive external contributions and will try to support you, so feel free to try to improve this. Some things to note:

Oren-i commented 1 year ago

I submited a merge request to fix any timeout in fact_extractor. I tested this on v3.3. Unfortunately I could not test this on main, but I think it should still work.

Oren-i commented 1 year ago

I also submited a patch to fact_extractor to try to get partial results in case binwalk does not finish.

dgutson commented 1 year ago

I think it's worth to mention the PR: https://github.com/fkie-cad/FACT_core/pull/852

Oren-i commented 1 year ago

And the other PR is https://github.com/fkie-cad/fact_extractor/pull/94

rhelmke commented 1 year ago

Hello!

First of all: thank you guys so much for the contributions here.

Unfortunately, our lead developer @jstucke and his right hand @maringuu are pretty busy this week, which is why probably nothing will happen until the 19th.

Just giving you a heads up - normally both PRs would've already been considered :-)