Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Microware OS-9/68000 magic support, including validation #620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/binwalk/magic/executables
Original file line number Diff line number Diff line change
Expand Up @@ -487,3 +487,13 @@
>>8 byte !0x2F {invalid}
>3 string x shebang: "%s"

# Microware OS-9/68000 module
0 string \x4a\xfc Microware OS-9/68000 module,
>2 beshort x Revision: %d,
>4 belong x Size: %d,
>4 belong x {size:%d}
>4 belong x {jump:%d}
>8 beshort x Group ID: %d,
>10 beshort x User ID: %d,
>(12.L) string x Name: %s
>(12.L) string x {name:%s}
22 changes: 22 additions & 0 deletions src/binwalk/plugins/os9_68kvalid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import struct

import binwalk.core.plugin

class MWOS9_68000Validate(binwalk.core.plugin.Plugin):
# This module does a header parity check to verify it is a OS-9 module
parity = 0

def _header_parity(self, string):
parity = 0
shorts = struct.unpack('>'+'H'*24, string)
for short in shorts:
parity ^= short
return ~parity
def scan(self, result):
if result.description.lower().startswith('microware os-9/68000 module'):
fd = self.module.config.open_file(result.file.path, offset=result.offset)
words = binwalk.core.compat.str2bytes(fd.read(48))
fd.close()

if self._header_parity(words) & 0xFFFF != 0:
result.valid = False