Archive (ZIP) bomb scanner for PHP.
- Detection of the ZIP archive bombs
- No dependencies
- Very fast
- ZIP
- PHP 7.2+
composer require selective/archive-bomb-scanner
use Selective\ArchiveBomb\Scanner\ArchiveBombScanner;
use Selective\ArchiveBomb\Engine\ZipBombEngine;
use SplFileObject;
$file = new SplFileObject('42.zip');
$scanner = new ArchiveBombScanner();
$scanner->addEngine(new ZipBombEngine());
$scannerResult = $scanner->scanFile($file);
if ($scannerResult->isArchiveBomb()) {
echo 'Archive bomb detected!';
} else {
echo 'File is clean';
}
use Selective\ArchiveBomb\ArchiveBombScanner;
use Selective\ArchiveBomb\Engine\ZipBombEngine;
use SplTempFileObject;
$file = new SplTempFileObject();
$file->fwrite('my file content');
$scanner = new ArchiveBombScanner();
$scanner->addEngine(new ZipBombEngine());
$isArchiveBomb = $detector->scanFile($file)->isArchiveBomb(); // true or false
- MIT