Git Product home page Git Product logo

fkie-cad / fact_core Goto Github PK

View Code? Open in Web Editor NEW
1.2K 33.0 220.0 58.12 MB

Firmware Analysis and Comparison Tool

Home Page: https://fkie-cad.github.io/FACT_core

License: GNU General Public License v3.0

Python 79.24% Shell 0.35% HTML 16.19% CSS 0.10% JavaScript 1.95% Dockerfile 0.13% YARA 1.87% Makefile 0.03% PHP 0.01% Ruby 0.01% C 0.10% Mako 0.03%
firmware-tools firmware-analysis security-automation security

fact_core's Introduction

FACT Logo

The Firmware Analysis and Comparison Tool (FACT)

codecov Codacy Badge Gitter chat

The Firmware Analysis and Comparison Tool (formerly known as Fraunhofer's Firmware Analysis Framework (FAF)) is intended to automate most of the firmware analysis process. It unpacks arbitrary firmware files and processes several analyses. Additionally, it can compare several images or single files.
Furthermore, Unpacking, analysis and comparisons are based on plug-ins guaranteeing maximal flexibility and expandability.
More details and some screenshots can be found on our project page.

Requirements

FACT is designed as a multiprocess application, the more Cores and RAM, the better.

Minimal Recommended Software
4 Cores
8GB RAM
10 GB disk space
16 Cores
64GB RAM
10* GB disk space
git
python 3.8 - 3.11
OS see below

~ 10 GB required to set up FACT code, container and binaries. Additional space is necessary for result storage. That can be on a separate partition or drive.

It is possible to install FACT on any Linux distribution, but the installer is limited to

  • Ubuntu 20.04 (stable)
  • Ubuntu 22.04 (stable)
  • Debian 11 (stable)
  • Kali (experimental)

โ— Caution: FACT is not intended to be used as public internet service. The GUI is not a hardened WEB-application and it may take your server at risk!

Installation

FACT can be installed and run via docker. See the FACT_docker repo for more.

The traditional installation is generally wrapped in a single script. Some features can be selected specifically though. See INSTALL.md for details.

Usage

You can start FACT by executing the start_all_installed_fact_components scripts. The script detects all installed components automatically.

$ ./start_all_installed_fact_components

Afterwards FACT can be accessed on http://localhost:5000 and https://localhost (nginx), respectively.

You can shut down the system by pressing Ctrl + c or by sending a SIGTERM to the start_all_installed_fact_components script.

Advanced Usage

๐Ÿ”ฅ We're currently working to improving our documentation, including installation, getting started and alike. Follow progress on our wiki pages. โœŒ๏ธ

REST API

FACT provides a REST API. More information can be found here.

User Management

FACT provides an optional basic authentication, role and user management. More information can be found here.

List of available community plug-ins and REST scripts

Vagrant

We provide monthly and ready-to-use vagrant boxes of our master branch. Vagrant is an easy and convenient way to get started with FACT without having to install it on your machine. Just setup vagrant and import our provided box into VirtualBox. Our boxes can be found here!

Check out on how to get started with FACT and vagrant in our tutorial.

Thanks to @botlabsDev, who initially provided a Vagrantfile that is now, however, deprecated.

Contribute

The easiest way to contribute is writing your own plug-in. Our Developers Manual can be found here.

Acknowledgments

This project is partly financed by German Federal Office for Information Security (BSI) and others.

Publications / Presentations

BlackHat Arsenal

We've been happy to show FACT in a number of BlackHat Arsenal sessions.

  • Black Hat Arsenal
  • Black Hat Arsenal
  • Black Hat Arsenal
  • Black Hat Arsenal

Other

Social

License

    Firmware Analysis and Comparison Tool (FACT)
    Copyright (C) 2015-2024  Fraunhofer FKIE

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
    
    Some plug-ins may have different licenses. If so, a license file is provided in the plug-in's folder.

fact_core's People

Contributors

0roman avatar 0xricksanchez avatar any333 avatar bolandi avatar decidedlygray avatar dependabot[bot] avatar dorpvom avatar eclipsotic avatar enkelmann avatar euwint avatar geierhaas avatar guedou avatar hairlessbear avatar jstucke avatar juju4 avatar lastpixl avatar lennarthenke avatar lwilms avatar maringuu avatar mellowcs avatar mic27m avatar nstarke avatar rhelmke avatar tbarabosch avatar timkoers avatar wankyoung avatar weidenba avatar wideglide avatar yazgoo avatar yehoudie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fact_core's Issues

Duplicate Firmware Support

Allow users to submit the same firmware with another name. Needed to support different devices sharing the same firmware. The current implementation feels like a bug as new submissions delete old ones.

Compare should be triggered from show_analysis view

Create some sort of compare buffer, to which one can append a firmware or a file object by clicking some button in the analysis view.
Maybe some sort of pop-up can be triggered that asks if compare shall be started once the second, third etc. item is selected.

Quick Search Feature

hash > name > vendor based free-text search field in header bar รก la github (search repository)

Improved Quicksearch

Two new features for the quicksearch would be appreciated:

  • search for file name: e.g. type dropbear and find all dropbear binaries including /usr/bin/dropbear or /sbin/dropbearmulti.
  • if only one result, show result directly. Could also be used in all other search requests.

file_path doesn't work as expected

I'm trying to do some simple analysis on the paths of files in a firmware bin. I expected that the file_object.file_path string would be the path of the file as it appears in the firmware (i.e. squashfs-root/web/apache2/conf), but instead it's a giant string of hex digits plus the absolute path on my machine.

Is there a way to get what I'm looking for? If I expand the file tree after everything is analyzed, all the files and folders have the correct names, but the analysis doesn't seem to have access to that.

refactor tabs in navbar

  1. Step: Database should be dropdown instead of page.
  2. Step: Reduce amount of tabs by merging some of them into new dropdown menues.

Presets for analysis systems

As of now the config file lists default plugins that are preselect on the upload page.

This could be enhanced to support custom presets. The upload page could then contain a dropdown menu to switch between presets.

Presets could be defined in config just as the default plugins are now.

Preset ideas:

  • Full (duh)
  • Fast (none selected)
  • UNIX Firmware (init systems, passwords, software components ..)
  • Component (binwalk, printable strings, ip finder)
  • ..

re organize tabs on fact navbar

In admin mode there are now 8 elements + logo + quicksearch button on the navbar.
Some of the elements should be reordered to allow for better overview.

e.g. profile and admin can be moved to one dropdown.

add preset variable to upload view rendering

As of now the list of presets - set in the config - is determined in the upload view by the line
analysis_plugin_dict[analysis_plugin_dict | first][2] | sort
this
a) introduces a bug that is hit whenever analysis_plugin_dict | first returns unpacker
b) is overly complicated since the notion of first on a dictionary is not trivial what makes this hard to understand

Now a more straight forward solution would be to generate this list in the route and adding it as a variable to the render_template method.

Report generation

It would be great if exists the posibility to create a report (HTML, for instance) given a firmware with all the information extracted.

Version Relation

We need a function to track relations between firmwares. The most common relation might be "previous" version.

create variety data takes too long

create_variety_data should be executed less often => It should be separated from the update_statistic script and get its own crontab entry. Execution once a week should be sufficient.

fix password bug with passlib/flask-security

If the plaintext of a password resembles a password hash (i.e. all 13 letters long passwords resemble DES hashes), it is stored in plaintext in the database and the password check does not work (meaning the user can't log in) due to a (intended?) bug in flask-security

possible solution: validate the password beforehand with the same hash identifying function used by passlib and disallow such passwords

file_path in Firmware object is obsolete

Parameter is used only in test code and can be omitted by fitting the binary service and a couple of other files.
The omission e.g. allows renaming of the storage directory.

Add web GUI for user management

Add pages for user management (a GUI version of the user management command line tool) and allow users to change their password

Generation of exploit mitigation stats fails in some cases

In some cases the calculation of the pie statistic fails raising the following error:

[2018-03-28 13:02:04][update_statistic][INFO]: Try to start Mongo Server...
[2018-03-28 13:02:04][MongoMgr][INFO]: start local mongo database
Traceback (most recent call last):
  File "src/update_statistic.py", line 48, in <module>
    sys.exit(main())
  File "src/update_statistic.py", line 38, in main
    updater.update_all_stats()
  File "/home/weidenba/git/FACT_core_github/src/statistic/update.py", line 45, in update_all_stats
    self.db.update_statistic('exploit_mitigations', self._get_exploit_mitigations_stats())
  File "/home/weidenba/git/FACT_core_github/src/statistic/update.py", line 102, in _get_exploit_mitigations_stats
    self.get_stats_pie(result, stats)
  File "/home/weidenba/git/FACT_core_github/src/statistic/update.py", line 175, in get_stats_pie
    total_amount_of_files = self.calculate_total_files_for_pie(pie_off, pie_on, pie_partial, pie_invalid)
  File "/home/weidenba/git/FACT_core_github/src/statistic/update.py", line 194, in calculate_total_files_for_pie
    total_amount_of_files = pie_on[0][1] + pie_off[0][1] + pie_partial[0][1] + pie_invalid[0][1]
IndexError: list index out of range

IP and URI statistic generation crashes if no IP result present in database

Traceback (most recent call last):
  File "src/update_statistic.py", line 48, in <module>
    sys.exit(main())
  File "src/update_statistic.py", line 38, in main
    updater.update_all_stats()
  File "/home/fact_restricted/git/FACT_core_github/src/statistic/update.py", line 44, in update_all_stats
    self.db.update_statistic('ips_and_uris', self._get_ip_stats())
  File "/home/fact_restricted/git/FACT_core_github/src/statistic/update.py", line 296, in _get_ip_stats
    stats['ips_v4'] = self._get_objects_and_count_of_occurrence_firmware_and_file_db('$processed_analysis.ip_and_uri_finder.ips_v4', unwind=True, sumup_function=sum_up_nested_lists)
  File "/home/fact_restricted/git/FACT_core_github/src/statistic/update.py", line 356, in _get_objects_and_count_of_occurrence_firmware_and_file_db
    combined_result = sum_up_lists(result_firmwares, result_files)
  File "/home/fact_restricted/git/FACT_core_github/src/helperFunctions/merge_generators.py", line 46, in sum_up_lists
    _add_list_to_dict(list_a, tmp)
  File "/home/fact_restricted/git/FACT_core_github/src/helperFunctions/merge_generators.py", line 18, in _add_list_to_dict
    if item[0] in input_dict.keys():
TypeError: unhashable type: 'list'

Using binary search via API

It would be very nice to use the binary search function via the API.
The return would then be the matching UIDs of the firmware images.

Improve Compare Performance

Two major bottlenecks:

  • get_object method is called at least "number-of-compared-firmwares" x "number-of-objects-in-db" times, creating a miss basically each time as the firmware collection is queried first.
  • file_coverage doesn't use the analysis_filter in get_object creating massive overhead

Recursivly download a whole firmware

The download included files functions just provides one layer of files. It would be nice to get the whole file tree of unpacked files of all layers.

Firmware Meta-Data: Module

In some cases you might have different parts of a firmware, that you want to add. E.g. Kernel, bootloader, filesystem. Therefore Firmware meta data should provide a "module" entry.

Replace apt in bootstrap

apt is a wrapper for apt-get and does not provide a stable interface.
Citation:
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.

For this reason the scripts should simply use apt-get instead.
The following lines still make use of apt:

bootstrap_common.sh:7:sudo apt install -y apt-transport-https
bootstrap_common.sh:8:sudo apt update
bootstrap_common.sh:9:sudo apt upgrade -y
bootstrap_common.sh:10:sudo apt autoremove -y
bootstrap_common.sh:11:sudo apt clean
bootstrap_db.sh:17:sudo -E apt update
bootstrap_db.sh:18:sudo -E apt install -y mongodb-org
bootstrap_db.sh:19:sudo -E apt upgrade -y

No intercom backend binding for "delete file"

The intercom backend binding for "delete file" exists but doesn't get started. Therefore, the delete file jobs that are sent over the intercom are not executed.

There might be old delete jobs in the database. Moreover, these old jobs might collide with new analyses: Files that should previously have been deleted were again inserted into the database and the old delete jobs might delete them erroneously. Therefore, a safety check should be implemented to secure that the files that are to be deleted aren't used by existing firmware entries.

Live storage of analysis results leads to possible bug in compare

In short:
The file coverage compare plugin has the file type analysis plugin as dependency. When objects are stored in the database before file type is finished, the compare plugin can run into an error.

What can be done:
It has to be evaluated, what the reaction to such a missing dependency is.
If this is an unwanted szenario - because analysis should always finish before compare - we can error-log this case.
We could also catch the ensuing exception and ignore the affected objects.
The most complex way would be to add something like analysis dependencies to compare plugins. But this would likely involve besides some changes to the scheduling a re-write of nearly all plugins.

Add Links to Rest API Responses

Good practice for REST APIs include rich responses.
This includes providing links to all content related to the request.

Examples include previous and next links when using browsing parameters as well as links to newly created resources (e.g. on firmware upload request).

fix signature import path

The generation of yara signature files is based on their plugin directories name, while the base plugin looks for them based on the plugin name.
Once directory name and plugin name deviate, the signature file is not found.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.