Friday 11 January 2013


How to find WiFi user name and password


Question : How to find WiFi user name and password in an android phone

Answer : As Android exposes WiFiManager API to access WiFi related information of the device but few OEM does not bother about securing the information exposed through these API's. So by using couple of lines of code you may find WiFi credentials.

1. Get WiFi manager instance.
WifiManager wifiManager = (WifiManager) getSystemService(Context.WIFI_SERVICE);

2. Get all WiFi configurations.
wifiManager.getConfiguredNetworks();

3. Traverse each WifiConfiguration returned in the above step and look for corresponding credentials.

For e.g. in the case of EAP protocol where EAP method is PEAP i.e. where user's domain credentials are used to connect to office WiFi. You can look for identity and password field and end up getting user's name and password.

POC : This works very well with HTC EVO running android 2.1 and HTC EVO spits out user's name and password. But it does not work with devices running latest android version. So keep exploring...

Thursday 12 July 2012

Remote service and threads

Question-1 : If some android application use remote service binder, does that binder methods get invoked in a new thread ?
Answer-1 : Yes, if some android application A invokes remote service binder methods then those methods get invoked in a new thread of that process. As that remote service is running in a separate process android creates a new thread from the thread pool of the process. But the calling thread of the application is kept blocked until remote service binder method returns. That means though android creates a new thread but the calling thread is kept blocked so do not invoke remote service binder methods from UI/Main thread of the application.

Question-2 : If some application A uses remote service binder and that remote service is part of this application A itself but running in a separate process, does that binder methods get invoked in a new thread ?
Answer-2 : its same as Answer-1. But think why do you need remote service in this scenario. Ideally remote service is not required here. Normal binder service is a solution for this scenario.

Question-3If some application A uses remote service binder and that remote service is part of this application A itself and running in a same process of application, does that binder methods get invoked in a new thread ?
Answer-3 : No, binder methods will not be invoked in a separate thread. It will be invoked in a caller thread itself.

Question-4If some application A uses remote service binder and that remote service is running in a same process of another application B, does that binder methods get invoked in a new thread ?
Answer-4its same as Answer-1. So either remote service is running in a separate process or another hosting application's process android creates a new thread from that process's thread pool and block the calling thread until binder method returns.


Thursday 21 June 2012

Service and Thread relationship


Question : If some android service starts a thread then will thread be terminated itself upon stopping of a service.

AnswerNo, thread will not be terminated by itself upon stopping of service, though if you force stop the application which owns the service by going to settings or uninstall the application then that thread will be terminated.