Beispiel #1
0
            try:
                self.rules = yara.compile(filepaths=filepaths)
            except yara.SyntaxError as e:
                test.add_fail('YARA',
                              'Failed to compile rules: {}'.format(str(e)))
                return

        # run analysis on the component and any shards
        for md in fw.mds:
            if md.blob:
                _run_on_blob(self, test, md, md.filename_contents, md.blob)
            for shard in md.shards:
                if shard.blob:
                    _run_on_blob(self, test, md, shard.name, shard.blob)


# run with PYTHONPATH=. ./env/bin/python3 plugins/blocklist/__init__.py
if __name__ == '__main__':
    import sys
    from lvfs.models import Firmware, Component

    plugin = Plugin('blocklist')
    _test = Test(plugin.id)
    _fw = Firmware()
    _md = Component()
    _md.blob = b'CN=DO NOT TRUST - AMI Test PK'
    _fw.mds.append(_md)
    plugin.run_test_on_fw(_test, _fw)
    for attribute in _test.attributes:
        print(attribute)
Beispiel #2
0
        for md in fw.mds:
            if not md.blob:
                continue
            if self._require_test_for_md(md):
                _run_intelme_on_blob(self, test, md)
        db.session.commit()


# run with PYTHONPATH=. ./.env3/bin/python3 plugins/intelme/__init__.py ./firmware.bin
if __name__ == '__main__':
    import sys
    from lvfs.models import Firmware, Component, Protocol, Category

    plugin = Plugin()
    _test = Test('intelme')
    _fw = Firmware()
    _md = Component()
    _md.protocol = Protocol('org.uefi.capsule')
    _md.category = Category('X-ManagementEngine')
    _fw.mds.append(_md)

    with open(sys.argv[1], 'rb') as f:
        _md.blob = f.read()
    plugin.run_test_on_fw(_test, _fw)
    for attribute in _test.attributes:
        print(attribute)
    for _shard in _md.shards:
        if not _shard.checksums:
            continue
        print(_shard.info.guid, _shard.checksums[0])
Beispiel #3
0
# pylint: disable=protected-access,wrong-import-position

import os
import sys

# allows us to run this from the project root
sys.path.append(os.path.realpath('.'))

from lvfs.models import Test, Firmware, Component, Protocol, Category
from plugins.intelme import Plugin

if __name__ == '__main__':
    for _argv in sys.argv[1:]:
        print('Processing', _argv)
        plugin = Plugin('intelme')
        _test = Test(plugin.id)
        _fw = Firmware()
        _md = Component()
        _md.component_id = 999999
        _md.category = Category('X-ManagementEngine')
        _md.filename_contents = 'filename.bin'
        _md.protocol = Protocol('org.uefi.capsule')
        with open(_argv, 'rb') as _f:
            _md.blob = _f.read()
        _fw.mds.append(_md)
        plugin.run_test_on_fw(_test, _fw)
        for attribute in _test.attributes:
            print(attribute)
        for shard in _md.shards:
            print(shard.info.guid, shard.info.name, shard.checksum)