2

Is it possible to extract a binary, to get the code that is behind the binary? With Class-dump you can see the implementation addresses, but is it possible to also see the code thats IN the implementation addresses? Is there ANY way to do it?

1
  • 2
    Disassemble with otool -tV . And be sure to practice your assembly. Commented Oct 25, 2011 at 19:27

3 Answers 3

5

All your code compiles to single instructions, placed in the text section of your executable. The compiler is responsible for translating your higher level language to the processor specific instructions, which are simpler. Reverting this process would be nearly impossible, unless the code is quite simple. Some problems are ambiguity of statements, and the overall readability: local variables, for instance, will be nothing but an offset address.

If you want to read the disassembled code (the instructions of which the higher level code was compiled to) use this command in an executable:

otool -tV file

Sign up to request clarification or add additional context in comments.

Comments

3

You can decompile (more accurately, disassemble) a binary and get it's assembly, but there is no way to get back the original Objective-C.

My curiosity begs me to ask why you want to do this!?

6 Comments

I want to learn from the code. You might think that I want to copy code, but thats not my intention, I want to see how others do stuff that I have been thinking about for ages and haven't figured out how to do it.
@Maxner: In general, it would be a much better idea just to look at open-source projects and ask questions about things you want to know rather than disassemble closed-source programs. Disassembled code is typcally not very beginner-friendly at all.
So when I have disassembled a binary, Terminal gives me thousands of lines like this: 00002134 e58d1024 str r1, [sp, #36] what can I do with that? How can I get any information of it?
@Maxner this is a store instruction given to the processor. If you really want to know about these, read a little on computer architecture. As Chuck said, this might not be the best path. PS: It was otool that gave you thousands of lines, not Terminal.app :-) Terminal.app just showed them to you.
|
2

otx http://otx.osxninja.com/ is a good tool for symbolicating the otool based disassembly It will handle both x86_64 and i386 disassembly.

and

Mach-O-Scope https://github.com/smorr/Mach-O-Scope is a a tool built on top of otx to dump it all into a sqlite3 database for browsing and annotating.

It won't give you the original source -- but it will get you pretty close providing you with the messages that are being sent around in methods.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.