
Ferramentas para analisar firmware UEFI e verificar módulos UEFI com regras FwHunt
Ferramentas para analisar firmware UEFI e verificar módulos UEFI com regras FwHunt.
rizin (v0.6.2)
Instale com pip (testado em python3.6 e superior):
$ python -m pip install fwhunt-scan
Instalação manual:
$ git clone https://github.com/binarly-io/fwhunt-scan.git && cd fwhunt-scan
$ python setup.py install
Analisar/escanear módulo individual:
$ python3 fwhunt_scan_analyzer.py analyze-module {image_path} -o out.json
$ python3 fwhunt_scan_analyzer.py scan-module --rule {rule_path} {image_path}
Escanear toda a imagem de firmware:
$ python3 fwhunt_scan_analyzer.py scan-firmware -r rules/BRLY-2021-001.yml -r rules/BRLY-2021-004.yml -r rules/RsbStuffingCheck.yml test/fw.bin
Para evitar instalar dependências, você pode usar a imagem docker.
Você pode construir uma imagem docker localmente da seguinte forma:
docker build -t fwhunt_scan .
Ou faça pull da imagem mais recente de ghcr.
Exemplo de uso:
docker run --rm -it -v {module_path}:/tmp/image:ro \
fwhunt_scan analyze-module /tmp/image # to analyze EFI module
docker run --rm -it -v {module_path}:/tmp/image:ro -v {rule_path}:/tmp/rule.yml:ro \
fwhunt_scan scan-module /tmp/image -r /tmp/rule.yml # to scan EFI module with specified FwHunt rule
docker run --rm -it -v {module_path}:/tmp/image:ro -v {rule_path}:/tmp/rule.yml:ro \
fwhunt_scan scan-firmware /tmp/image -r /tmp/rule.yml # to scan firmware image with specified FwHunt rule
docker run --rm -it -v {module_path}:/tmp/image:ro -v {rules_directory}:/tmp/rules:ro \
fwhunt_scan scan-firmware /tmp/image --rules_dir /tmp/rules # to scan firmware image with specified rules directory
Todos esses passos são automatizados no script fwhunt_scan_docker.py:
python3 fwhunt_scan_docker.py analyze-module {module_path} # to analyze EFI module
python3 fwhunt_scan_docker.py scan-module -r {rule_path} {module_path} # to scan EFI module with specified FwHunt rule
python3 fwhunt_scan_docker.py scan-firmware -r {rule_path} {firmware_path} # to scan firmware image with specified FwHunt rule
python3 fwhunt_scan_docker.py scan-firmware --rules_dir {rules_directory} {firmware_path} # to scan firmware image with specified rules directory
Exemplos básicos de uso:
from fwhunt_scan import UefiAnalyzer
...
uefi_analyzer = UefiAnalyzer(image_path=module_path)
print(uefi_analyzer.get_summary())
uefi_analyzer.close()
from fwhunt_scan import UefiAnalyzer
...
with UefiAnalyzer(image_path=module_path) as uefi_analyzer:
print(uefi_analyzer.get_summary())
Em plataformas Linux, você pode passar um blob para análise em vez de um arquivo:
from fwhunt_scan import UefiAnalyzer
...
with UefiAnalyzer(blob=data) as uefi_analyzer:
print(uefi_analyzer.get_summary())
from fwhunt_scan import UefiAnalyzer, UefiRule, UefiScanner
...
uefi_analyzer = UefiAnalyzer(module_path)
# rule1 and rule2 - contents of the rules on YAML format
uefi_rules = [UefiRule(rule1), UefiRule(rule2)]
scanner = UefiScanner(uefi_analyzer, uefi_rules)
result = scanner.result