Home > OS >  Extract translatable strings from "NIBArchive" .nib files
Extract translatable strings from "NIBArchive" .nib files

Time:02-01

My goal is to extract the localization keys and strings from a Base.lproj's .nib files.

While most compiled nib files use the binary plist format, I ran into a few that are in a different format, where the file starts with "NIBArchive".

An example (in macOS Monterey) is the file at:

/System/Library/CoreServices/Finder.app/Contents/Resources/Base.lproj/ClipWindow.nib

For "bplist" files, I can easily read them via CFPropertyListCreateFrom… into a NSDictionary, and then find the translatable strings therein (inside the "$classes" entry they're always three consecurity dict, string and string entries, with the dict containing the keys "NS.string", "NSKey" and "NSDev", and the following strings being the key and value of a translation entry, similar to what .strings files contain).

The NIBArchive, however format doesn't seem to be documented anyway. Has anyone figured out how to decode the entries in a meaningful manner so that I could find the translation items in them? Or convert them into the bplist format?

Note that this kind of file is a compiled nib, and ibtool won't work because it gives the error: "Interface Builder cannot open compiled nibs".

I am working with random .nib files, for which I don't know the implementation specifics. All I want is to extract are the .strings contents that were originally compiled into the Base localization file.

CodePudding user response:

I had googled for this format before but found nothing. Now, with a slightly modified search, I ran into some answers.

My best hope to solving this so far is this format description, determined through reverse-engineering:

https://github.com/matsmattsson/nibsqueeze/blob/master/NibArchive.md

I can build a parser based on this, but still wonder if there are easier ways.

Another possible solution is to use NSKeyedUnarchiver to decode the data, after loading it into a NSNib object, as suggested here:

https://stackoverflow.com/a/4205296/43615

This method of decoding keyed archives of unknown types is also shown in the PlistExplorer project:

https://github.com/karstenBriksoft/PlistExplorer

CodePudding user response:

It seems https://github.com/kam800/MachObfuscator does include a NIBArchive-reader NibArchive Loading written in Swift.

  • Related