Jump to content

Stuffit Magic Numbers


Recommended Posts

In a different thread (over in software), @Dog Cow mentioned that there are magic numbers which can be used to distinguish which version of the stuffit algorithm was used to compress a file.  Does anyone have more information on this?  I would like to build a utility that can sort *.sit files, or perhaps improve the unix 'file' command to report a bit more than just "StuffIt Archive" when it sees "SIT!".  I believe I can compress the same file with different versions and reverse engineer it, but figured I'd ask in case someone had this info somewhere.

 

Thanks,

Nathan

Link to post
Share on other sites

That’s a fun idea for a project. It’s not immediately obvious to me how to do that, since the Finder (or more likely a DRVR running in the background, launched by the INIT) would need to actually open the StuffIt archive and read far enough into it to get the magic number (if it’s there) each time it needed to decide what icon to draw. Patch _GetResource, and if the Finder is the foreground app and it’s getting an ICN# resource corresponding to an archive document from StuffIt, look up the file whose icon is being drawn (but how do I know which one that is???) in the precomputed hashtable of known archives and return the appropriate icon you designed ... and if the file hasn’t been seen before, stop and open it up to check the type and populate the hashtable entry? ...... or something. If I didn’t have a newborn, I would try it. Unless someone is super expert at how the Finder draws file icons, it would probably require a long Macsbug session.

Link to post
Share on other sites
  • 5 months later...
  • 3 weeks later...
On 6/21/2020 at 5:44 PM, Iesca said:

@equant Did you end up having any luck with this? :D

A little luck, but not a lot.  You can reliably tell the difference between "5.5 or later" or "pre 5.5".  I found this to be a useful distinction when browsing archives.  I implemented it into the RetroBridgeBBS interface so that I can tell (when browsing online archives) if the file I want to download is compatible with my machines running system 6 or early system 7 software or not.

 

https://github.com/equant/RetroBridgeBBS

 

This shows the basic idea of predownloading just the file's header, and then determining if it's old or new Stuffit.

    sit_patterns = [
            [b"^SIT!",  "StuffIt pre 5.5"],
            [b"^StuffIt", "StuffIt 5.5 or later"],
    ]

    headers = {"Range": "bytes=0-200", 'User-Agent': USER_AGENT}
    header = requests.get(self.url, headers=headers).content
    for p in self.sit_patterns:
        r = re.compile(p[0])
        m = r.match(header)
        if m:
            print(f"File is archived with: {p[1]}")

 

Getting a more precise version out of an archive is certainly possible, but it wasn't worth the work to me.

 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...