Monitoring Outgoing Requests For Images Xamarin [duplicate] - c#

I would like to monitor network traffic of my Android Phone. I was thinking using tcpdump for Android, but I'm not sure if I have to cross-compile for the phone.
Another question is the following, If I want to monitor the trafic data for a certain application, there's any command for doing that?

TCPDUMP is one of my favourite tools for analyzing network, but if you find difficult to cross-compile tcpdump for android, I'd recomend you to use some applications from the market.
These are the applications I was talking about:
Shark: Is small version of wireshark for Android phones). This program will create a *.pcap and you can read the file on PC with wireshark.
Shark Reader : This program allows you to read the *.pcap directly in your Android phone.
Shark app works with rooted devices, so if you want to install it, be sure that you have your device already rooted.
Good luck ;)

If you are doing it from the emulator you can do it like this:
Run emulator -tcpdump emulator.cap -avd my_avd to write all the emulator's traffic to a local file on your PC and then open it in wireshark
There is a similar post that might help HERE

Note: tcpdump requires root privileges, so you'll have to root your phone if not done already. Here's an ARM binary of tcpdump (this works for my Samsung Captivate). If you prefer to build your own binary, instructions are here (yes, you'd likely need to cross compile).
Also, check out Shark For Root (an Android packet capture tool based on tcpdump).
I don't believe tcpdump can monitor traffic by specific process ID. The strace method that Chris Stratton refers to seems like more effort than its worth. It would be simpler to monitor specific IPs and ports used by the target process. If that info isn't known, capture all traffic during a period of process activity and then sift through the resulting pcap with Wireshark.

For Android Phones(Without Root):- you can use this application tPacketCapture this will capture the network trafic for your device when you enable the capture.
See this url for more details about network sniffing without rooting your device.
Once you have the file which is in .pcap format you can use this file and analyze the traffic using any traffic analyzer like Wireshark.
Also see this post for further ideas on Capturing mobile phone traffic on wireshark

The DDMS tool included in the Android SDK includes a tool for monitoring network traffic. It does not provide the kind of detail you get from tcpdump and similar low level tools, but it is still very useful.
Oficial documentation: http://developer.android.com/tools/debugging/ddms.html#network

Preconditions: adb and wireshark are installed on your computer and you have a rooted android device.
Download tcpdump to ~/Downloads
adb push ~/Downloads/tcpdump /sdcard/
adb shell
su root
mv /sdcard/tcpdump /data/local/
cd /data/local/
chmod +x tcpdump
./tcpdump -vv -i any -s 0 -w /sdcard/dump.pcap
Ctrl+C once you've captured enough data.
exit
exit
adb pull /sdcard/dump.pcap ~/Downloads/
Now you can open the pcap file using Wireshark.
As for your question about monitoring specific processes, find the bundle id of your app, let's call it com.android.myapp
ps | grep com.android.myapp
copy the first number you see from the output. Let's call it 1234. If you see no output, you need to start the app. If you still don't see the app via ps try using top.
Download strace to ~/Downloads and put into /data/local using the same way you did for tcpdump above.
cd /data/local
./strace -p 1234 -f -e trace=network -o /sdcard/strace.txt
Now you can look at strace.txt for ip addresses, and filter your wireshark log for those IPs.

You would need to root the phone and cross compile tcpdump or use someone else's already compiled version.
You might find it easier to do these experiments with the emulator, in which case you could do the monitoring from the hosting pc. If you must use a real device, another option would be to put it on a wifi network hanging off of a secondary interface on a linux box running tcpdump.
I don't know off the top of my head how you would go about filtering by a specific process. One suggestion I found in some quick googling is to use strace on the subject process instead of tcpdump on the system.

Without root, you can use debug proxies like Charlesproxy&Co.

Packet Capture is the best tool to track network data on the android.
DOesnot need any root access and easy to read and save the calls based on application.
Check this out

Try this application
https://play.google.com/store/apps/details?id=app.greyshirts.sslcapture
We can view all networking communications .. even SSL encrypted communications.

The common approach is to call "cat /proc/net/netstat" as described here:
Android network stats

Related

Can I send signed APK though bluetooth to device to quickly test build

I am creating a Xamarin android application. Most time consuming is build deployment which everyone known.
I tried to send signed APK via Bluetooth from my development machine to device. It gets successfully deployed, but instantly closes after start.
Have anyone tried this way and is there problem testing in device by copying APK?
You can definitely send the signed APK file (as produced by the build process) via Bluetooth, email or even USB, but it's not likely to offer an improvement on speed.
I do this sometimes when I work from home, as I can't easily connect a device to my work PC (which I'm accessing over a VPN).
If your application is crashing on load when you do that, you've almost certainly got a bug in the application that is causing it.

Send command from PC application to Jailbroken iphone

I am making an simple application on PC by C# to send command to jailbroken iphone (exp: open app, get list application installed on iphone..e.t.c..) but I do not know how to send to iphone, searching google but can not find a thing to do this. Anyone know how to send command to iphone please point me out or some documents to learn about this.
Thank you.
in my opinion the best way to go is using SSH, here's the steps
On the Jailbroken device (Skip this steps if you already have an ssh server installed and running)
Download the SSH server from Cydia
Take note of your device's IP address
Default username: root and password: alpine Remember to change that!, also i would recommend creating another user for your app
In your application
Download and install the SSH.NET library from NuGET here
Implement your appropriate methods to connect,disconnect and send commands, se those examples:
using (var client = new SshClient("phoneIp", "phoneUsername", "phonePassword")) {
client.Connect();
//Open the Facebook app and show your profile
client.RunCommand("open fb://profile");
//Alternative method using `uiopen`
client.RunCommand("uiopen fb://profile");
//Read device network info (install network-cmds first)
Console.WriteLine(client.RunCommand("ifconfig"));
//List all apps installed via Cydia
Console.WriteLine(client.RunCommand("dpkg –list"));
//List all apps that are installed from iTunes/Appstore
Console.WriteLine(client.RunCommand("cat /private/var/mobile/Library/Caches/com.apple.mobile.installation.plist"));
client.Disconnect();
}
I haven't tested this code of course, and I have no Jailbroken iOS device, but this should put you on the right path at least!
First you have to create a daemon on your jailbroken iDevice. It will contain a TCP server, which accepts connections from your PC and translates them into your commands. After that commands will be executed by your daemon and you have to write code to process each type of command.
Another one easy solution would be to use Cycript in conjunction with SSH.
If Cycript is installed on the jailbroken phone and a SSH server is running, you could write some scripts and upload it to the phone.
By running them, it would output relevant informations to the standard output.
You would still have to do some very basic reversing stuff to know what you want to to display (i.e. asking the right SpringBoard controller to have the desired information)

How to save/retrieve data with android device sd-card, via USB Debugging mode?

Is there a way to save/retrieve files from an android device, via the USB debugging mode.
That means I want my application to get connected even if the Device is charging via the USB cable connected to the PC.
I think the ADB (Android Debug Bridge) is capable of rendering this service, however I am not quite sure if it works, If it does how can I use it with C# to simply save and get some files from the SD-Card
ADB can indeed accomplish that for you.
to pull a file from the device:
adb pull /mnt/sdcard/somefile.txt
to push a file to the device
adb push somefile.txt /mnt/sdcard/
(Note: obviously you'll need to replace somefile.txt with your own path and/or filename.)
I am not very familiar with C# but surely you could make something with that that can interact with the ADB binary to accomplish these tasks.
See here for a more complete listing of ADB functionality / syntax

Using Bluetooth to RECEIVE file - From Mobile to PC

I took me several time and days to research and try some codes applicable to my problem but unfortunately I wasn't able to see codes that pair and receive files (text, images etc..NOT audio or video in particular) from a mobile device.
Most of the examples found are for SENDING only (From PC to Mobile).
I have bluetooth device (USB) physically attached to my PC.
Summary:
All I need is a sample code that automatically detect/pair when a device is trying to send the file (like in Kodak kiosk but not limited to images only).
I also wanted to understand and study the code.
Perhaps use my 32feet.NET library and its ObexListener class see e.g. http://32feet.codeplex.com/wikipage?title=Server-side&referringTitle=OBEX
For more advanced scenarios use Andy Hume's Brecham.Obex library and his server sample application. See http://inthehand.co.uk/files/folders/objectexchange/entry9942.aspx
Which Bluetooth stack does your PC have installed? Microsoft, Widcomm, BlueSoleil...? See e.g. http://32feet.codeplex.com/wikipage?title=Supported%20Hardware%20and%20Software On Widcomm for instance the build-in OBEX server would have to be disabled to allow your server to get all the incoming connections...

Connect and disconnect USB programmaticaly "WITHOUT UNPLUG AND REPLUG"

I need to connect and disconnect USB programmatically. That is, I have inserted the USB device. I need to transfer the file using C#, .NET application. The application will watch the particular folder and transfer the file from that folder to a USB drive. I need to disconnect the USB device after the file is transfered and connect the USB when needed - without unplug and replug.
What would be some code to do it or is there any DLL file available?
Main thing: NOTE, NOTE: Without unplugging and replugging the USB device.
If your goal is to make a certain disk volume unavailable while you're not using it, a more sensible approach might be to use the volume management APIs, e.g. by using the IOCTL_VOLUME_OFFLINE control code. (I'm assuming that you know which drive letter belongs to your USB disk.)
Alternatively, you can disable and enable the volume device programmatically with the CfgMgr / SetupAPI -- the same as right-clicking the volume in Device Manager and choosing Disable would do. (For information about using SetupAPI, please review the DevCon sample code provided with the Windows WDK, and see MSDN for functions such as SetupDiChangeState.)
The latter option might require a privileged user account.
I'm not exactly sure, but it can be done. In Linux, I've experienced certain situations where power is disconnected to a device programmatically. The kernel usually does this if the connected USB device is exhibiting too many errors. So, it should be possible to do this even in Windows. You may need to write your own external DLL to do it though.

Categories