Best way to access computer CMD from android - android

I'd like to create and Android app which allows me to control some aspects of my computer (volume, open pre-defined URL's..etc).
Would it be feasible to create a Windows client from an Android device? I'd like to access my PC's terminal in order to execute some commands.
If so..could you please point me out the right direction?

One possibitly (maybe not the best one) would be to host a apache webserver with access to the cmd by executing it with PHP. You could predefine commands which you call from specific URL paths like http://192.168.1.1/myHomeControl/muteSpeakers/ for muting the speakers.
You can execute cmd commands in PHP with
exec('ping');
or
system('ping');
Then you just need to call the URL from your android Device and it should work.

There are many ways to control Windows machine from another device. Every type of connection depends on particular type of protocol. And as result each protocol has its own rules, pros and cons and restrictions.
You can connect to the machine by SSH using JSCH. But you also need to install SSH server on your machine.
Or you can develop your own protocol using TCP/UDP as transport.

Try this software -- https://play.google.com/store/apps/details?id=com.sonelli.juicessh
Install the ssh on your machine:
For Mac:
http://www.maclife.com/article/howtos/how_enable_ssh_your_mac
For
Linux:
http://www.cyberciti.biz/faq/how-to-installing-and-using-ssh-client-server-in-linux/
For Windows:
http://comptb.cects.com/install-configure-ssh-on-windows/
Connect to it and do whatever you want to do. Have Fun!
If you want to create an application, than there is two options again: either you create a SSH tunel to the pc and you kinda let the user configure their SSH or create an External APP such the PHP , or VB.net that kinda detects by protocols and different ports the access to the machine.
I use this software to control volume and stuff : http://www.unifiedremote.com/ it is pretty good when it comes to control the laptop and and certain types even using the mobile as a mousepad -- To do this they created a software that needs to be installed on the machine to control doing so lets call this software the CONVERTER / RECEPTOR that converts all request that i do from mobile to the pc. Seems simple but not rlly :)
Regards!

Related

how to connect two different ssh connections to same ssh server

I am developing a system that connects two remote devices. I have used ssh for the whole communication. Scenario is such :
Both devices connect to same ssh server having public ip
Both devices are inside NAT
Connection is initiated by both devices
Problem is that both connections are treated as different sessions and I want to make communication b/w the two devices possible.
I am using JSch
Another problem is that I want to use JSch in android and have no idea how to integrate and use JSch example files(say shell.java) in android
The two devices have already established connections to the server,this implies that the settings has to be at sshd (ssh server) that is maintaining this two authenticated sessions. Does SSH server allows this? If yes then how it could be done? Tell me if their is any another way to perform this i.e connecting two remote devices in different networks to communicate by connecting through one public IP.
I am using OpenSSH server just for relaying purpose but dont know how to relay input from one session to another session back and forth i.e I dont know how to configure SSH server
You would have to build a "server" software on the server that would facilitate the communication between the devices.
You can still use the SSH and run the "server" software (or communicate with it) via the SSH/JSch session.
You will run the software using JSch using the "exec" channel. The software will communicate with other instances of itself using mechanism available on that platform, for example using named pipes.
If you want a really trivial solution, you can just use cat - > file on one side and tail -f file on the other side. Try that in two SSH terminals to get the idea.
You can hardly communicate between the devices directly otherwise.

How to capture app traffic on Android

I'm trying to capture traffic from an app on an Android phone and although I've set the proxy on the phone and can capture all other internet traffic coming from the phone (using Charles Proxy), I can't see any traffic for this one app.
How is this done, and how can I capture the traffic?
UPDATE:
If you need help setting up a wifi hotspot from your computer, so you
can connect your phone to it and Wireshark the traffic, just look at
the following link for directions:
http://www.wi-fiplanet.com/tutorials/article.php/3849841/How-to-Create-Wireless-Hosted-Networks-in-Windows-7.htm
If you want help decompiling an IOS app to assembly, look at this
link: http://www.infointox.net/?tag=arm
If you want a better Dex to Java decompiler than dex2jar, check this
out: https://github.com/skylot/jadx
There're several ways:
Connect your phone to your internal wifi access point (before connecting check advanced options and set a manual proxy).. Note: this method do not work for all network data.. some connections ignore this setting.
(works on rooted phones only) Install 'Shark for Root' application on your device... it will capture ALL traffic.. it will generated dump files that can be analized on your PC using Wireshark software
The best way: Setup your PC as a wifi access point and make your android device to use this wifi connection, then sniff the traffic using the same Wireshark application.
I strongly recommend you use something like "CharlesProxy" (or similar). Be aware of 2 things when u setup the proxy (I hope it is an application you are developing, otherwise be sure of what you do cause it can be ILEGAL):
1 - If you want to attack from your Android/iOS phone to the proxy installed in your local computer, you need the proxy to be configured to use the local IP:PORT (which means CharlesProxy needs to be configured as an address as 192.168.x.x if using a normal wifi network). Then, the Android/iOS phone needs to be setting the proxy to the same IP:PORT
2 - If the app uses https, there are several ways to manage HTTPS connections:
a) If your application accepts ALL Certificates, then it is not a problem for whatever proxy to capture and decrypt the information.
b) If your application accepts only system (and trusted) certificates, you have to export the charlesproxy certificate to your Android phone and to add it into the list of user's trusted certificates.
c) If your application is correctly doing "Certificate pinning", you won't be able to capture the traffic, unless you have the private certificate of your server and you add it in both (your phone) and the proxy configuration.
Hope it helps!

Create application to connect with computer

I want to create application which I want to use to turn off my computer. I think about connection phone with computer in WIFI. But I don't know how can I send commend to computer and how computer translate this commend and turn off computer. Can you show me the way how can I start and what I should to know to create application like this?
You can achieve that with the client/server paradigm. You'll need to develop an android app that will work as client and a pc app that will work as server.
On the server side you need to wait for two commands:
Discover: Used for the client to know what servers are available
Action: Used to let the server know that it must shutdown itself

Capturing mobile phone traffic on Wireshark

How can I capture mobile phone traffic on Wireshark?
Here are some suggestions:
For Android phones, any network: Root your phone, then install tcpdump on it. This app is a tcpdump wrapper that will install tcpdump and enable you to start captures using a GUI. Tip: You will need to make sure you supply the right interface name for the capture and this varies from one device to another, eg -i eth0 or -i tiwlan0 - or use -i any to log all interfaces
For Android 4.0+ phones: Android PCAP from Kismet uses the USB OTG interface to support packet capture without requiring root. I haven't tried this app, and there are some restrictions on the type of devices supported (see their page)
For Android phones: tPacketCapture uses the Android VPN service to intercept packets and capture them. I have used this app successfully, but it also seems to affect the performance with large traffic volumes (eg video streaming)
For IOS 5+ devices, any network: iOS 5 added a remote virtual interface (RVI) facility that lets you use Mac OS X packet trace programs to capture traces from an iOS device. See here for more details
For all phones, wi-fi only: Set up your Mac or PC as a wireless access point, then run wireshark on the computer.
For all phones, wi-fi only: Get a capture device that can sniff wi-fi. This has the advantage of giving you 802.11x headers as well, but you may miss some of the packets
Capture using a VPN server: Its fairly easy to set-up your own VPN server using OpenVPN. You can then route your traffic through your server by setting up the mobile device as a VPN client and capture the traffic on the server end.
In addition to rupello's excellent answer, a "dirty" but very effective trick:
For all phones, any (local) network: Set up your PC to Man-In-The-Middle your mobile device.
Use Ettercap to do ARP spoofing between your mobile device and your router, and all your mobile's traffic will appear in Wireshark. See this tutorial for set-up details
Another option which has not been suggested here is to run the app you want to monitor in the Android emulator from the Android SDK. You can then easily capture the traffic with wireshark on the same machine.
This was the easiest option for me.
Wireshark + OSX + iOS:
Great overview so far, but if you want specifics for Wireshark + OSX + iOS:
install Wireshark on your computer
connect iOS device to computer via USB cable
connect iOS device and computer to the same WiFi network
run this command in a OSX terminal window: rvictl -s x where x is the UDID of your iOS device. You can find the UDID of your iOS device via iTunes (make sure you are using the UDID and not the serial number).
goto Wireshark Capture->Options, a dialog box appears, click on the line rvi0 then press the Start button.
Now you will see all network traffic on the iOS device. It can be pretty overwhelming. A couple of pointers:
don't use iOS with a VPN, you don't be able to make sense of the encrypted traffic
use simple filters to focus on interesting traffic
ip.addr==204.144.14.134 views traffic with a source or destination address of 204.144.14.134
http views only http traffic
Here's a sample window depicting TCP traffic for for pdf download from 204.144.14.134:
For Android phone I used tPacketCapture:
https://play.google.com/store/apps/details?id=jp.co.taosoftware.android.packetcapture&hl=en
This app was a lifesaver I was debugging a problem with failure of SSL/TLS handshake on my Android app. Tried to setup ad hoc networking so I could use wireshark on my laptop. It did not work for me. This app quickly allowed me to capture network traffic, share it on my Google Drive so I could download on my laptop where I could examine it with Wireshark! Awesome and no root required!
Packet Capture Android app implements a VPN that logs all network traffic on the Android device. You don't need to setup any VPN/proxy server on your PC. Does not needs root. Supports SSL decryption which tPacketCapture does not. It also includes a good log viewer.
Preconditions: adb and wireshark is 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 after you've captured enough packets.
exit
exit
adb pull /sdcard/dump.pcap ~/Downloads/
Now you can open the pcap file using Wireshark.
Install Fiddler on your PC and use it as a proxy on your Android device.
Source: http://www.cantoni.org/2013/11/06/capture-android-web-traffic-fiddler
Similarly to making your PC a wireless access point, but can be much easier, is using reverse tethering. If you happen to have an HTC phone they have a nice reverse-tethering option called "Internet pass-through", under the network/mobile network sharing settings. It routes all your traffic through your PC and you can just run Wireshark there.
Make your laptop a wifi hotspot for your phone (any) and connect it to internet. Sniff Traffic on your wifi interface using wireshark.
you will get to know a lot of anti privacy stuff!
As a Wireshark alternative/companion for Android, you can try my open source app PCAPdroid. On non-rooted devices, it uses the VPNService to capture the traffic with some limitations. On rooted devices, it works like a user-friendly tcpdump.
You can analyze connections and packets payload directly into the app, or export the traffic in PCAP format to analyze it on a PC with Wireshark. It has many other cool features, give it a try!
For Android, I previously used tPacketCapture but it didn't work well for an app streaming some video. I'm now using Shark. You need to be root to use it though.
It uses TCPDump (check the arguments you can pass) and creates a pcap file that can be read by Wireshark. The default arguments are usually good enough for me.
I had a similar problem that inspired me to develop an app that could help to capture traffic from an Android device. The app features SSH server that allows you to have traffic in Wireshark on the fly (sshdump wireshark component). As the app uses an OS feature called VPNService to capture traffic, it does not require the root access.
The app is in early Beta. If you have any issues/suggestions, do not hesitate to let me know.
Download From Play
Tutorial in which you could read additional details
For iOS Devices:
⦿ Open Terminal and simply write:
rvictl -s udid
it'll open an interface on Wireshark with a name, In my case its rvi0.
udid is iPhone's unique device id.
(How to find my iOS Device UDID)

Communication between Android Emulators

I wanted to know if it is possible the comunication between two Android Emulators started on two different machines networked.
For example
- Emulator A run on machine M1
- Emulator B run on machine M2
Can A and B exchange messages?
If yes, what ip address do I use?
Thank you very much
Deborah
You might know this already. As of android-sdk-tools_r7 it should at least be possible to connect two emulators to each other. Whether is works between physical machines is not something I know. It might be possible to set up masquerading between the two hosts for this specific broadcast.
From the android commit
Enable interconnection of emulators
This patch adds a -shared-net-id option to the emulator which
joins the emulator in a shared network.
If the option is given the emulator is started with an additional
network interface bound to a multicast socket. This multicast socket
emulates a network hub, interconnecting emulators.
If the -shared-net-id option is not given, nothing changes.
To connect two emulators, use the -shared-net-id <number> command line option when starting the emulator. They will then directly share everything sent to or read from ip 10.1.2.<number> on the emulator.
Another approach would be to enable port forwarding between the emulators using adb, and then set up masquerading for those ports on the networked machines.
I'm not really sure that either of these solutions match the use case that you're asking after. If not, adding more details to the original question might help. :)
Disclaimer: I have not tried the first approach, and the second I've only used to make sure that an emulator could bypass a nasty corporate firewall and HTTP proxy so that we could test the android browser. The principle should be sound though.
Update:
Nope, I played around with it a whole lot and found no nice solutions. I am not good enough at iptables to set up a valid tunnel that way that works for the server end.
Regards,
Mikael
An emulator normally has outbound access to the development machine's LAN or internet connection, so the problem is on the inbound side.
You can use an emulator or ADB port forward to send traffic into the emulator, but possibly only locally originating traffic on the development machine's loopback interface, and not external traffic. If that is indeed the case, the simplest thing would probably be to write or configure a port forwarder that listens on the development machine's external interface and forwards to the port that is forwarded into the emulator.

Categories

Resources