Object c 汇编debug(转)

有时间看看object c 的汇编,先转一个,有时间了再学习。

One of the reasons I have not been posting as regularly is because of a big project I am currently working on. I have delved into the world of Objective-C, and have been enjoying it a ton. One of the pleasant surprises I found was the XCode utilizes GCC and GDB to do its compilation and debugging. Although they provide a nice GUI to interact with the debugger (create breakpoints, etc), it still will give you the normal ASM dump on errors. I imagine many developers out there just glaze over when they see this, but I got very excited! After doing some research and reading, I found some very useful Phrack articles to help me with my debugging.

If you are brand new to ASM I would recommend you go over to SecurityTube and check out their ASM primer. For those who know some ASM, you should be able to understand mostly.

Useful Commands

Identify Selector

When a message fails it is important to know which exactly selector threw the error. That selector can be found referenced within $ecx. The following is the command to display the value of $ecx, as well as a GDB command to display every call and selector made:

Single Command:
x/s $ecx


Script:
break
commands
x/s $ecx
c
end

The script works by creating designating a command to print out the value of $ecx as a string, then continue the process. See the above Phrack article for more details.

Identify Class Name

When an object is going to execute a method the method pointer is loaded into $ecx (as seen above) and the pointer to the id/object is loaded into $eax.The class name can be found within a struct that exists within each object. It exists as a pointer (4-bytes) 8-bytes into the struct. We can access it in two ways:

printf:
printf "%s\n", *(long*)($eax+8)


call getName method:
call (char *)class_getName($eax)

That is just the basics, but I hope you will find it helpful.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值