1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import os
import binwalk
from nose.tools import eq_, ok_
def test_firmware_jffs2():
'''
Test: Open firmware.jffs2, scan for signatures.
Verify that only JFFS2 signatures are detected.
Verify that only the first one was displayed.
'''
input_vector_file = os.path.join(os.path.dirname(__file__),
"input-vectors",
"firmware.jffs2")
scan_result = binwalk.scan(input_vector_file,
signature=True,
quiet=True)
# Test number of modules used
eq_(len(scan_result), 1)
# Test number of results for that module, should be more than one
ok_(len(scan_result[0].results) > 1)
first_result = scan_result[0].results[0]
# Check the offset of the first result
eq_(first_result.offset, 0)
# Make sure we found the jffs file system
ok_(first_result.description.startswith("JFFS2 filesystem"))
# Check to make sure the first result was displayed
ok_(first_result.display == True)
# Make sure we only found jffs2 file system entries
# and that nothing but the first entry was displayed
for result in scan_result[0].results[1:]:
ok_(result.description.startswith("JFFS2 filesystem"))
ok_(result.display == False)