Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List HTTP requests from android phone

What I want is to be able to see the HTTP requests my Galaxy S4 produces. I wanna build a web application and want to use the API that is used in some application. I know for sure that there is a HTTP request, and I want to capture as much as possible, but at the very least, the URL.

So far I've tried a couple of things:

  1. Look for Android apps that capture HTTP requests. So far I have found some apps that can supposedly do the thing I need. But they all require root access, and I do not want to root my phone.

  2. Look for Windows applications that tether my wifi signal, which means every request is ported through my computer. So far I've tried 1 application, MyPublicWIFI, and I tried using netsh start hostednetwork. The application didn't display any of the URLs, and right now it doesn't even share my wifi signal. The hostednetwork I tried to set up in CMD doesn't share the wifi connection (I enabled this option in the properties).


I need a way to do this. Is there any way that I can get the URLs by porting the requests through my computer?

like image 855
Nicky Smits Avatar asked Mar 12 '14 13:03

Nicky Smits


People also ask

How do I see network requests on Android?

From the Android Studio navigation bar, select View > Tool Windows > App Inspection. After the app inspection window automatically connects to an app process, select Network Inspector from the tabs.

How do I check HTTP requests?

To view the request or response HTTP headers in Google Chrome, take the following steps : In Chrome, visit a URL, right click , select Inspect to open the developer tools. Select Network tab. Reload the page, select any HTTP request on the left panel, and the HTTP headers will be displayed on the right panel.


2 Answers

Charles Web Debugging Proxy will allow you to do what you want. It is an HTTP proxy application that runs on Windows, OS X, and Linux.

You will need your phone and computer to be connected to the same LAN, and to adjust your phone's Wi-Fi settings to use a proxy, pointing it to your computer's IP address with port 8888. Then, all web traffic to/from your phone will travel via your computer and be visible in Charles.

You will be able to see the full details of any HTTP requests and responses (URL, headers, body etc.), the only limitation being encrypted traffic, but by installing the Charles SSL certificate on your phone you can access this as well.

Since this is just an HTTP proxy, it doesn't require a rooted device.

The only downside I can see is that it is licensed software ($50US for a single user license), but the 'free trial' does not expire - the app simply closes after it's been open for 30 minutes, if I recall correctly.

For most devices (Android 4.0 upwards I'm guessing), the proxy can be set like this:

  1. Go to Wi-Fi settings
  2. Long press on desired network
  3. Select 'Modify network'
  4. Check 'show advanced options'
  5. Set
    • Proxy: Manual
    • Proxy hostname: {your computer's IP address}
    • Proxy port: 8888
  6. Save
like image 163
Ellis Avatar answered Sep 18 '22 13:09

Ellis


I finally figured it out, and got the API I was interested in. It is done in a few simple steps: Tether your internet connection to your phone, Connect your phone to the newly created wireless ad-hoc network, make wireshark capture your requests.

For tethering you have to set up a wireless network so your phone can connect to it. You do this using CMD, and view network connections in windows. You might also have to open the device manager for troubleshouting. I'll run you through it step by step


1- Start CMD in Admin mode so that it has all the permissions that are needed. Then type the following code (trying to start our hostednetwork):

netsh wlan set hostednetwork mode=allow ssid=networkname key=networkpass
netsh wlan start hostednetwork

if it works, move on to step 2. Otherwise, you'll have some troubleshooting to do. Sadly enough, there is not one easy way to do this. First view your networkconnections, and find your wifi, right click and disable it. Then go to device manager, head over to network adapters, and uninstall everything with virtual in it, these are virtual hosts, which make your CMD requests fail. You can enable your wifi again. Now wait a few minutes, and then try the first part again. If it still doesn't work, reboot your pc, and repeat this step. It seems like a hassle, and it is, but it's the only way i found out to do it.

2- view your network connections and right click on it, choose properties. Now head over to the sharing tab, enable sharing your connection with others. Now look for wifi networks on your phone and select your network name and type your password. (connect to internet with your phone):

You should be able to browse the internet with your phone now. If not, i do not know what to do. Try a browser first to check for your internet connection because some apps are blocked in this setting. This is for security reasons (you wouldn't want someone to raid your banking app).

3- Download wireshark, install it, start capturing. Now make the requests you want to trace on your phone. Then stop capturing. You can now click on protocol, to arrange all the requests, you only have to check HTTP protocol. You can see the url on the right. (checking the HTTP request)


Summary: We made our phone connect to the PC for using the internet. The PC makes all the requests to external servers and sends it results back to the phone. The requests made by the pc (thus both for the pc itself and the phone) can be viewed by wireshark.

like image 22
Nicky Smits Avatar answered Sep 16 '22 13:09

Nicky Smits