Commit 9b505a7b by devttys0

Fixed magic.py bug

parent b666c8fb
......@@ -700,6 +700,16 @@ class Magic(object):
return tags
def match(self, data):
'''
Match the beginning of a data buffer to a signature.
@data - The data buffer to match against the loaded signature list.
Returns a list of SignatureResult objects.
'''
return self.scan(data, 1)
def scan(self, data, dlen=None):
'''
Scan a data block for matching signatures.
......@@ -732,7 +742,7 @@ class Magic(object):
# If this offset has already been matched to a previous signature, ignore it unless
# self.show_invalid has been specified. Also ignore obviously invalid offsets (<1)
# as well as those outside the specified self.data range (dlen).
if (offset not in matched_offsets or self.show_invalid) and offset >= 0 and offset <= dlen:
if (offset not in matched_offsets or self.show_invalid) and offset >= 0 and offset < dlen:
# Analyze the data at this offset using the current signature rule
tags = self._analyze(signature, offset)
# Generate a SignatureResult object and append it to the results list if the
......
......@@ -123,7 +123,14 @@
>20 ubelong x data offset: 0x%X
# http://lxr.free-electrons.com/source/fs/ubifs/ubifs-media.h
0 lelong 0x06101831 UBIFS superblock,
0 lelong 0x06101831 UBIFS master node,
>20 ubyte !7 {invalid} # Only look for the master node
>22 leshort !0 {invalid}
>24 lequad x highest inode: %d,
>32 lequad x commit number: %d
# http://lxr.free-electrons.com/source/fs/ubifs/ubifs-media.h
0 lelong 0x06101831 UBIFS superblock node,
>20 ubyte !6 {invalid} # Only look for the superblock node
>4 ulelong x CRC: 0x%X,
#>8 lequad x sqnum: %ld,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment