Open flankerhqd opened 10 years ago
My hook code is like:
dalvik_hook_setup(&dpdu, "Landroid/telephony/SmsManager;", "sendTextMessage", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/app/PendingIntent;Landroid/app/PendingIntent;)V", 6, my_dispatch);
dalvik_hook(&d, &dpdu);
However my_dispatch will never get executed, since Landroid/telephony/SmsManager cannot be resolved in dalvik_hook_setup, thus dalvik_hook_setup fails.
I'm using a 4.1.2 arm emulator in SDK.
I guess the class name is wrong, look at the internal classes such as: com.android.internal.telephony.....
Can't find com.android.internal.telephony.SmsManager.sendTextMessage or com.android.internal.telephony.sendTextMessage, however one can find android.telephony.SmsManager.sendTextMessage at http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/4.1.2_r1/android/telephony/SmsManager.java#SmsManager.sendTextMessage%28java.lang.String%2Cjava.lang.String%2Cjava.lang.String%2Candroid.app.PendingIntent%2Candroid.app.PendingIntent%29
if you find android.telephony.SmsManager, you can call dalvik_dump_class(dexstuff_ptr, "android.telephony.SmsManager"); to show all methods of that class.
Thanks for your kind reply. The problem is the class "android.telephony.SmsManager" cannot be resolved or found in ddi's world, dalvik_dump_class(&d, "Landroid/telephony/SmsManager;");
output nothing and I think there is no problem with spelling.
What process are you hooking?
On May 8, 2014 9:03:41 PM EDT, flankerhqd notifications@github.com wrote:
Thanks for your kind reply. The problem is "android.telephony.SmsManager" cannot be resolved or found in ddi's world, dalvik_dump_class(dexstuff_ptr, "android.telephony.SmsManager"); output nothing.
Reply to this email directly or view it on GitHub: https://github.com/crmulliner/ddi/issues/3#issuecomment-42624206
Tried com.android.phone
, com.android.mms
and a custom application calling sendTextMessage, none succeeded in resolving and hooking Landroid/telephony/SmsManager;
. Lcom/android/internal/telephony/SMSDispatcher;
and Ljava/lang/String
are OK.
can you try the system_server?
Tried system_server without luck, still cannot resolve
E/hook-dexstuff( 149): dalvik_hook: class Landroid/telephony/SmsManager;
E/hook-dexstuff( 149): class = 0x0
E/hook-dexstuff( 149): target_cls == 0
source pasted here: https://gist.github.com/flankerhqd/afbe1a40531837d09f32
I came here to add an issue and found this, its describes my problem exactly. Has this been resolved in anyway?
can you try to see what classes are present in .phone/.mms ? using dalvik_dump_class(XX, NULL); <- dumps all loaded classes in a process. My guess is that there is just some renaming or name mangle going on.
example:
static int my_epoll_wait(int epfd, struct epoll_event _events, int maxevents, int timeout) { int (_orig_epoll_wait)(int epfd, struct epoll_event _events, int maxevents, int timeout); orig_epollwait = (void)eph.orig; // remove hook for epoll_wait hook_precall(&eph); // resolve symbols from DVM dexstuff_resolv_dvm(&d);
// dump all classes dalvik_dump_class(&d, 0);
// call original function
int res = orig_epoll_wait(epfd, events, maxevents, timeout);
return res;
}
I have tried this several times now. each time the emulator disconnects. I have captured the logcat which covers the time frame, upto the point where the interface is reset. It shows an error in the m.android.phone caused by the call to dalvik_dump_class as seen in dexdump.c. I also tested doing the class dump on SmsDispatch and on SmsManager. Dispatch returned a full list of the methods available and Manager returned nothing, not even the header section.
Class dump pasted here: https://gist.github.com/flankerhqd/c47916dc61386cd9f6e4, no sign of SMS
to avoid the problem of SmsManager not being available I have attempted to hook the SmsDispatcher. I have added: dalvik_hook_setup(&srpdu, "Lcom/android/internal/telephony/SMSDispatcher;", "sendRawPdu", "([B[BLandroid/app/PendingIntent;Landroid/app/PendingIntent;Ljava/lang/String;)V", 6, my_sendRawPdu); dalvik_hook(&d, &srpdu); log ("hooked srpdu\n")
to the example smsdipatch.c provided, however this causes the hooks to fail and the log file remains empty. I have taken the method name and signature directly from the output of dalvik dump. Is there something I have missed?
sendRawPdu is only available on a few HTC devices. Are you sure your phone supports this?
the class name and method + signature look good.
is your "my_sendRawPdu" function called at all?
@VirtualBim try dalvik_dump_class(&d, ""); 0 a.k.a NULL will cause SF on strlen, thus crashing the process
No, I am not certain, I am using the Emulator and trying to catch all the Sms leaving the device. Following the code it looked as though all sms went through sendRawPdu on their way to sendSms. With those 2 (hook setup & hook) calls that I added the hooks do not run at all. i.e. it seems the epoll function does not complete. So no, my function is definitely not called.
I assumed that sendRawPdu being in the dalivk dump meant it was available.
My only real question is where should I hook to catch the sms leaving the machine? given that SmsManager is not available.
Thanks for all your help btw :)
@flankerhqd thank you, i'll try that.
I have discovered that most if not all messages go through the call SendSMS in the dispatcher class, however as this is abstract you have to catch the calls to it in gsmDispatcher and cmdaDispatcher. I have hooked on there and caught calls sent through smsManager. Unfortunately the smsbody needs pulling out of the tracker which I have not yet solved. I can get the address string but the hashmap is proving resilient.
Hello,
I am facing same issue. I found some how below mentioned dalvik symbol not hooking method. ddi/dalvikhook/jni/dalvik_hook.c
dex->dvmUseJNIBridge_fnPtr(h->method, h->native_func);
I want to know how to debug into the line.
Thanks & Regards Hardik Joshi
Hi thanks for the great tool! However I found I cannot hook functions like
android.telephony.SmsManager.sendTextMessage
. By turning the debug option in dalvik_hook.c (h->debug_me = 1), I found the reason is classandroid.telephony.SmsManager
resolved to NULLThe log is:
Why the class cannot be resolved? java.lang.String works fine.