fisy-fuzz
fisy-fuzz copied to clipboard
can't keep the framework running correctly
hello,i recently restarted studying your research and want to test ubuntu ext4 file system. When i installed all requirements and run python3 run.py in terminal,it seems the whole framework is running correctly,but after several minutes,everything stopped due to some errors as belows:
File src/Fuzzer/file_system_magic/ext_superblock_parser.py", line 155, in find_all_superblocks
matches = re.finditer(self.sb["e2fs_uuid"], data)
sre_constants.error: unterminated character set at position 2
or:
File src/Fuzzer/file_system_magic/ext_superblock_parser.py", line 155, in find_all_superblocks
matches = re.finditer(self.sb["e2fs_uuid"], data)
sre_constants.error: unbalance parenthesis at posiition 4
I have tried to re-run for several times, but each time it ended with one of the above error scenarios. How can i keep the framework running without these errors? Looking forward to your reply!
Hi,
It's been a while the last time I looked at this and wasn't running this for quite a while now. However, from what I can recall:
@staticmethod
def get_offset_in_sb(fn):
off = 0
sb = EXT_SB
for i, v in sb:
if i == fn:
return off, sizeof(v)
off += sizeof(v)
return None, None
def read_superblock_in_dict(self, loc=SBLOCK_EXT2):
with open(self.fs, "rb") as f:
f.seek(loc)
for field in self.fields_sb:
self.sb[field[0]] = f.read(sizeof(field[1]))
def find_all_superblocks(self):
self.read_superblock_in_dict()
with open(self.fs, "rb") as f:
f.seek(0)
data = f.read()
# Using uuid because the EXT2 magic is too short to yield good results
matches = re.finditer(self.sb["e2fs_uuid"], data)
for m in matches:
bytearr = bytearray()
sb = m.span()[0] - 104
bytearr.append(data[sb + MAGIC_BYTES_OFF])
bytearr.append(data[sb + MAGIC_BYTES_OFF + 1])
if bytearr == EXT_MAGIC:
self.sb_locs.append(sb)
return self.sb_locs
This code was tested and ran with mostly ext2 at the time, as BSD had no full support for any of the advanced ext features. It sounds that the naive pattern matching there fails for recent EXT-based file systems. In particular, the aforementioned sections would need some verification/updating and tests..
I'd be happy to test and merge a PR, as I currently don't have the time to fiddle with this myself :)!