Decoding an arbitrary NSData block?

If I have an arbitrary NSData block as a hexadecimal value, is there a way to determine what the object can be before it is archived or serialized? I don't mind a few guessing and checking methods, but I need some pointers in the right direction.

I have an NSData object with some hex in it. What NSData methods should I look for? There are other classes to try [/ p>

I don’t want to scare people away from the answer, but I have a game data file, which was probably encoded using the Cocoa Touch class. The data, when viewed in a hex editor, shows gibberish and username, which makes me suspect that this is an archived or encoded object. I copied hex from a hex editor into a sample project, which I use to try to parse the data.

I do not believe that this is due to the 3D format, the file extension is arbitrary.

Here are the data. I hope that he does not get lost in the translation:

'µköXN[ÎÀü÷h/F9ó9Vìñ°ceE¸z¶=Hmoshbermú«ó¼Ppù#ÝVÔ=4â®L,K;Êç;ASÀ&Ë÷ëÓ%È;Úf¬G}tmQ;µéüø_87´y©ã©!ß¶óQòAçÛl©âSG4S½3ýJת9äô¡wxiD²M¼ÏB]39øþ:óñ7ª¾÷躣È3Ï¢ÍEFÍ¢ª»r]BmÁ'Ò+åygÞÅQ?luó>÷ú¼è6¸|}[¼[¶Ñ¦g!\OÎÒJSE..pSß&_ÈEäø)6òëó¨¼2¶ð°æà`ï7Ë=Ã¥:cƧ=L4qG-"µ(ÐÝïß ÓãXkÀ4fzæ·p\ññT<tu¥Æ©;Ìn4£³Ï¢ÌFåG´ 

And the corresponding hex:

 27 B5 6B F6 01 00 00 00 58 4E 5B CE C0 FC F7 68 2F 46 86 87 83 39 F3 39 9E 56 EC F1 B0 63 9E 65 45 B8 7A B6 3D 07 99 48 6D 6F 73 68 62 65 72 6D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 90 86 FA 03 0E AB F3 BC 0B 50 70 F9 23 DD 87 56 03 D4 3D 34 90 E2 AE 4C 2C 94 9E 8E 15 4B 0C 83 8C 3B 03 CA E7 3B 1B 41 53 C0 26 04 CB F7 EB D3 25 C8 3B DA 66 8A AC 47 7D 8A 7F 74 6D 51 3B B5 19 E9 FC F8 5F 38 37 B4 11 0C 79 A9 12 E3 A9 21 DF B6 F3 51 F2 41 E7 DB 85 02 9F 6C A9 E2 53 47 1F 34 86 53 BD 33 FD 4A D7 AA 39 C3 A4 F4 A1 77 78 69 44 B2 4D BC CF 42 5D 33 39 F8 FE 97 3A 81 F3 F1 10 37 AA BE 86 91 F7 1F E8 83 BA A3 C8 33 CF 1D A2 CD 45 7F 46 1F CD A2 AA BB 1A 72 5D 42 02 6D C1 0F 27 D2 2B E5 0B 79 67 DE C5 1A 51 3F 14 6C 75 F3 3E F7 FA BC E8 36 8E B8 7C 02 1C 7D 01 00 92 8C 19 5B BC 5B B6 D1 A6 67 7F 21 5C 84 13 4F CE 0C D2 4A 53 19 82 45 1B 2E 2E 96 70 53 DF 26 5F C8 1C 45 8F E4 F8 29 36 F2 EB 9D 95 F3 A8 BC 32 B6 F0 B0 E6 91 98 1A E0 99 60 EF 37 CB 3D C3 A5 3A 63 0C C6 A7 3D 4C 34 71 47 2D 22 B5 28 D0 DD EF DF 09 D3 E3 58 6B C0 17 34 66 7A E6 B7 70 5C F1 F1 54 3C 74 94 75 A5 C6 15 A9 9E 14 3B CC 15 10 83 6E 34 A3 B3 CF 0F A2 9C CC 8E 46 8C E5 00 00 47 B4 17 05 00 00 00 00 

If someone wants to help understand this, he will greatly appreciate it.

+6
source share
2 answers

If I have an arbitrary NSData block as a hexadecimal value, is there a way to determine what the object can be before it is archived or serialized?

Not really. This is about as "trivial" as reading arbitrary files without using a UTI, extension, such as MIME. Of course, your program should also support reading all of these files / formats.

I don't mind a few guessing and checking methods, but I need some pointers in the right direction.

You need to narrow down your problems / inputs if you don't need a difficult task.

I have an NSData object with some hex in it. What NSData methods should I look for?

This is just a drop of data length bytes. He can represent anything - if you do not know where it came from.

Are there any other classes?

You might start by storing all your data through NSCoder or another serializer / archiver that offers some introspection and support for entering your own information (which would be comparable to a UTI or MIME type).

Edit:

I don’t want to scare people away from the answer, but I have a game data file, which was probably encoded using the Cocoa Touch class. The data, when viewed in a hex editor, shows gibberish and username, which makes me suspect that this is an archived or encoded object. I copied hex from a hex editor into a sample project, which I use to try to parse the data.

Using these APIs, data can be represented in several ways. Probably, you are faced with something in the field of 1) a proprietary file format through 2) an archive with keys.

The latter is easier for nontrivial data representations. You will need to define any objc classes that you will not have available when they are unpacked. In this case, a few examples of views would suggest a rough outline of the data structures that you will need (in regular implementations). It can also be an archive similar to NSDictionary if it can open it. This is a problem that is simpler than with other languages, because archiving is often discarded on keys and values ​​mapped to members in Cocoa.

Edit2:

The file came from the Draw Something directory. It is called gamedata.i3d

(spread your arms)

+2
source

Try using NSKeyedUnarchiver to read it. It’s not uncommon to use only standard Foundation containers such as NSArray, NSDictionary, and NSString to store data, so you might be lucky. Obviously this will not work if custom classes are involved, but it may cost 15 minutes of your time to try.

0
source

Source: https://habr.com/ru/post/913289/


All Articles