[Q] Secure ADB connection over network - Android Q&A, Help & Troubleshooting

I am using Geniatech ATV Android Set Top Boxes running android 4.2.2 for a current project. I might put some of those devices in public places like shopping centers. These boxes are connected to the local network there by cable or wireless.
I have a VPN connection to ssh remotely into the boxes (using debian kit) and on the boxes USB debugging is enabled, so that i have ADB access, which I use for chrome browser observation as well as for updating or installing new applications.
The problem is that everyone on the same local network as the box can also use adb to connect to the boxes and then have full access to everything, which is a big security problem.
What I want to do is restrict the interface of adb to only work over the vpn connection.
Alternatively I need a way to stop and start the adb daemon using my ssh connection to the box. The problem here is that I only connect to a debian kit instance running on the same box, which uses the same filesystem but doesn't have access to the start or stop adb commands.
Does anyone have an idea how to achieve this? I can't find a lot of information on this special requirements.

Related

Use PC internet connection on phone through USB!

USB tethering on froyo works if you need to use the phone's internet on PC. Sometimes, we just need to do it the other way around (lets say the PC doesn't have a wireless card, or we only have ad-hoc networks that are not discoverable without patching) and use our PC's net on android through USB.
Few people have done it using bridges. I did it using squid proxy server on ubuntu.
1.) Install squid and allow http access to all required clients.
2.) Connect the phone with usb tethering on.
3.) Ubuntu detects it as usb0. Now change the ip of usb0 from 'Automatic DHCP' to 'Shared to other computers'.
4.) Fire up the terminal emulator and enter the following.
#su
#netcfg usb0 dhcp
If all went well, you should now be able to connect to the internet.
Tried it and it's not working for me...
Or maybe i didn't setup squid right.
I'm not so good on ubuntu OS
I tried making a bridge connection on windows...the networks
The network seems to be connected but no internet connection...
Is it necessary to have Ubuntu OS?
Maybe some another how-to will help:
http://forum.xda-developers.com/showthread.php?t=793102
To setup squid to work:
type in:
sudo gedit /etc/squid/squid.conf
In that file find the section called
# ACCESS CONTROLS
Under the section find the line
#Recommended minimum configuration:
and add this line next to it
acl all src all
then find the section
# TAG: http_access
Under this section find the line
#Default:
and add the following line to look like
#Default:
http_access allow all
Close the file and restart squid as:
sudo start squid
That should setup squid to share your internet on all clients.
If required, reboot.
You can try out a similar approach on any other distro other than ubuntu.
i tried several searches about this topic, but none of them succeeded,
any update on this?
can i install ubuntu in my Win7?
syruz said:
can i install ubuntu in my Win7?
Click to expand...
Click to collapse
Well, you can virtualize it in Virtual box. It's free for personal use.
by the way what is the squid your talking about?
@ TS
maybe you can provide us with the link for ubuntu and squid?
Come on.. if you don't already know what ubuntu and squid are there's no point in trying this.
Ubuntu = Linux, that's another operating system. Squid is a proxy.
You ashould at least have the decency of Googling those for yourself..
Sent from my LG-P500 using XDA App
harshaxdadevelopers said:
USB tethering on froyo works if you need to use the phone's internet on PC. Sometimes, we just need to do it the other way around (lets say the PC doesn't have a wireless card, or we only have ad-hoc networks that are not discoverable without patching) and use our PC's net on android through USB.
Few people have done it using bridges. I did it using squid proxy server on ubuntu.
1.) Install squid and allow http access to all required clients.
2.) Connect the phone with usb tethering on.
3.) Ubuntu detects it as usb0. Now change the ip of usb0 from 'Automatic DHCP' to 'Shared to other computers'.
4.) Fire up the terminal emulator and enter the following.
#su
#netcfg usb0 dhcp
If all went well, you should now be able to connect to the internet.
Click to expand...
Click to collapse
Hi guys,
Do you know why I wouldn't be able to see "USB tethering" option? No matter what I did so far, all I can see is the "Portable Wi-Fi hotspot" option and that works fine. But I need to use the USB Tethering!!!
Thanks for the help!
If someone is having the same problem as me (ie usb tethering mode not visible) just use a program called togglesettings lite. It can turn on the usb tethering for you. Now the reverse usb tethering works for me like a charm. Peace!
Sent from my LG-P500 using XDA App
harshaxdadevelopers said:
USB tethering on froyo works if you need to use the phone's internet on PC. Sometimes, we just need to do it the other way around (lets say the PC doesn't have a wireless card, or we only have ad-hoc networks that are not discoverable without patching) and use our PC's net on android through USB.
Few people have done it using bridges. I did it using squid proxy server on ubuntu.
1.) Install squid and allow http access to all required clients.
2.) Connect the phone with usb tethering on.
3.) Ubuntu detects it as usb0. Now change the ip of usb0 from 'Automatic DHCP' to 'Shared to other computers'.
4.) Fire up the terminal emulator and enter the following.
#su
#netcfg usb0 dhcp
If all went well, you should now be able to connect to the internet.
Click to expand...
Click to collapse
Thank you for sharing this trick. But i dont have netcfg utility, since i use ubuntu maverick 10.10, it is not in source list. is ther any other way to do "netcfg usb0 dhcp"?
This is by far the easiest solution I've found to reverse tether. Thanks!
jadeiceman said:
This is by far the easiest solution I've found to reverse tether. Thanks!
Click to expand...
Click to collapse
Sorry and wich is the solution ????
syruz said:
@ TS
maybe you can provide us with the link for ubuntu and squid?
Click to expand...
Click to collapse
sudo apt-get install squid
This should install squid.
netcfg is not there on recent ubuntu versions not even software list but you can configure via app indicator at right but still i can't use reverse tethering although i followed you pretty well.
netcfg is a utlility on the phone... u need to run that command at the terminal of the phone not on your computer. (get a terminal emulator from the market)
Wow I'm feeling stupid.Will give it a go now.

[TUT] ADB over WI-FI

ADB over Wi-Fi​Some of us might like to connect the device over WiFi for debugging, instead of using the data cable. Here's the required tutorial to do so
Requirements
1. Android device (duh!!!)
2. ADB in the computer (again duh!!!)
3. Root privileges
4. Terminal emulator (download from here)​
Let's begin then​Open terminal emulator on your device. Enter the following code
Code:
su [color="red"]Grant superuser here[/color]
setprop service.adb.tcp.port 5555 [color="red"]Can be anything else[/color]
stop adbd
start adbd
Check it with this
Code:
getprop service.adb.tcp.port
It will return 5555 or the number you entered in the above code​
Enter the following code on your computer in command prompt or shell
Code:
adb connect 192.168.0.151
Instead of 192.168.0.151, enter your device IP address​
To make your device listen on USB again, just restart the device. And enter the code on your computer
Code:
adb usb
I would definitely use the USB cable to push large files or even small files that you really don't want to risk corrupting (partition images you plan on dding, etc).
Very importantly, keep in mind, when your phone is listening for adb via WiFi, it's wide open... anybody that has adb installed and knows your device's IP address can access it without a password. Again, a simple reboot will turn it off though.​
Credits
JeepFreak for this post in the One X forum​
Reserved
Reserved for app​
I want to thank the OP, however belatedly, for writing these root instructions for users to connect their PC and phone via adb over Wi-Fi without USB cables being involved.
As the OP is well aware, non-rooted Android 10 and below allowed wireless adb connections AFTER a USB connection was first established (adb start-server && adb tcpip 5555 && adb connect [IP]:5555), but that changed (for the better) in Android 11 and above with the new new Developer options Wireless debugging random port assignments (adb connect [IP]:[PORT] or adb pair [IP]:[PORT] [PIN]) such that the adb wireless connection never needs USB cable ever again.
Given Android 11 allows Developer options Wireless debugging via a random port, and Android 12 new Developer options Wireless debugging allows that to be accessed even easier with a new Developer options Wireless debugging tile, the only thing missing is a way to get, after the fact, the random port assignment that Android uses for the adb wireless connection to your PC.
Some related threads for reference might be...
[adb,scrcpy,vysor] What ports does Android 12 randomly set when Wi-Fi connecting via Wireless debugging adb "pair" or "connect" commands?
(PSA) Using the new Android 12 TILE for 'Developer options' 'Wireless debugging' to establish adb connection over Wi-Fi without USB
What's the difference between Windows/Android adb "connect" versus adb "pair" when mirroring Android 12 over Wi-Fi onto a Windows PC?
The only question that's missing an answer preventing a perfect completely Wi-Fi automatic solution is...
Does anyone know how to obtain that random Android port address from the PC?

View/Control Android device from PC (without ROOT)

Hi all. What I need is a way to control Android device (s) from PC via Wi-Fi. I found a lot of apps (and Desktop programs) to do it, but I didn't found a way to View OR control the Android device WITHOUT ROOT. I work on the company which asked me to find a way to do this without root with their Android devices. After googling a lot I started to think that where is no way to do this, because either way I need to root them . Is it true or maybe there is somewhere an app which could do this? It doesn't care if it's paid or not.
I have downloaded and tester these apps:
MyMobiler - Doesn't work because when I restart Android device, app doesn't start WiFi, just keyboard mode only. I need that when the app starts it should run itself and start WiFi automatically.
VMLite VNC Server - Don't know why but it didn't worked for me. Just cannot start server from the browser.
Thank you for any responses and appreciate any help.
What error messages do you get from vmlite vnc server? Make sure you enable USB debugging. We have tens of thousands of users using our app, and your device should work.
Well, actually now I tried to launch VMLite VNC one more time and IT WORKED (don't know how, because earlier I tried it and I was unable to enter to VNC Viewer in the Browser). So yeah, in this case it works perfectly now, but I just realized, that I have no way of connected more Android devices. Because what I need to do is to connect multiple Android devices to computer with USB (as I understand it's required for the first time) and when use it with WiFi. For now I see that I only capable of connecting single Android device with desktop program and everytime I want to connect to Android deice from computer, I need to connect it via USB (where is no way to save Android devices to use it any time I want to via WiFi). Or am I wrong? And it is a problem because in my company all Android devices are far away from each other. Anyway, thank your for such an awesome app, I really don't know how it is capable of connecting to my Android device WITHOUT ROOT (because I found like 10 apps, read a lot of forums, and every solution was with ROOTED devices, I am very interseting of the actual app functionality), but thank you.
You can connect to multiple devices using multiple USB cables. There is a drop down list to display devices, and you choose one by one to start the server. Alternatively, you can write some scripts to auto start the vnc servers.
There are quite some testing companies using our app this way to automate regression tests.
Alternatively, you can write some scripts to auto start the vnc servers.
Click to expand...
Click to collapse
Can I get more information about it? Thank you.
Basically you can automate the starting process using adb command:
adb shell "am start -a android.intent.action.MAIN -n com.vmlite.vncserver/.MainActivity"
adb shell /data/data/com.vmlite.vncserver/files/vmlitevncserver
Deimantas007 said:
Can I get more information about it? Thank you.
Click to expand...
Click to collapse
Thank you for this script (it's very cool, I didn't know this kind of stuff before), but it requires USB connection as well.
I googled a few things and found this app - ADB Wireless (no-root) on Google Play Store. Basically it connects ADB via WiFi and I don't need no USB cable and connection with it. But VMLite Android App Controller program on my Desktop doesn't recognize it (it requires USB connection). Can I actually connect Android device with PC with this method or I am missing something and there is no way of doing it with this method? Thank you (I promise, this is the last question from me, no more dumb questions).
I don't think it will work for you. You mentioned your android device will reboot, right?
If your device gets rebooted, you will have to use a USB connection to a PC. the ADB wireless app has same requirement.
Steps to get it working: (from ADB Wireless app page)
1. Enable USB Debugging on your phone.
2. Connect your phone via usb cable to your PC.
3. Run adb tcpip 5555.
4. Run ADB Wireless (no root).
5. Connect to the IP address.
Deimantas007 said:
Thank you for this script (it's very cool, I didn't know this kind of stuff before), but it requires USB connection as well.
I googled a few things and found this app - ADB Wireless (no-root) on Google Play Store. Basically it connects ADB via WiFi and I don't need no USB cable and connection with it. But VMLite Android App Controller program on my Desktop doesn't recognize it (it requires USB connection). Can I actually connect Android device with PC with this method or I am missing something and there is no way of doing it with this method? Thank you (I promise, this is the last question from me, no more dumb questions).
Click to expand...
Click to collapse
huisinro said:
I don't think it will work for you. You mentioned your android device will reboot, right?
If your device gets rebooted, you will have to use a USB connection to a PC. the ADB wireless app has same requirement.
Steps to get it working: (from ADB Wireless app page)
1. Enable USB Debugging on your phone.
2. Connect your phone via usb cable to your PC.
3. Run adb tcpip 5555.
4. Run ADB Wireless (no root).
5. Connect to the IP address.
Click to expand...
Click to collapse
What's right. It needs to connect my phone via USB. But I thought that maybe there is a way to automate this process, I mean maybe there is a solution to TURN DEBUGGING MODE between phone and pc programs via WiFi connection (not USB) and communicate with VMLite VNC Server program on startup. Either way, again, thank you for your software (app). I will say to my boss that we need to stay where we are at the moment. It's just awesome to have an app which doesn't require ROOT.

Connect Android phone over Wi-Fi using ADB

(Many will consider this question a duplicate of similar questions but I don't think this question should be marked as duplicate because the answer requested here is different than others.)
I am searching for the solutions since many years and read a lot of pages on internet and StackOverflow but hasn't found any solution.
Once an non-rooted Android phone is authorized over USB using ADB then how to connect it over Wi-Fi every time without ever connecting the phone over USB?
I know that executing
Code:
adb start-server
then
Code:
adb tcpip 5555
and then
Code:
adb connect <IP.address.of.phone>
will connect the phone over Wi-Fi IF it is connected using USB when issuing these commands.
According to the answers/forums, there are 2 ways to connect Android phone over Wi-Fi:
The user has to first connect to USB even though the device is already authorized.
The phone needs to be rooted.
But I think, what I want to achieve, as per the question, must be possible because if ADB can connect over USB and then Wi-Fi, then there must be some way to accomplish with directly connecting over Wi-Fi if computer is already authenticated. The missing thing is to know what exactly ADB is doing when switching from USB to Wi-Fi. I think, it could be getting authorization again. But what if we store the authorization information (finger print? or encryption key?) once and use it every time to connect over Wi-Fi? (Please note that when first time authenticating the computer over USB, its finger print is showed in the Android phone, and it never asks again until the authorization is revoked/invalidated somehow. So, I think the requirement here is to revalidate the computer.)
I viewed the ADB repository and read the text files mentioning how ADB works. In one txt file I read that
Code:
adbd
(ADB Daemon) is started on port 5555 on the Android phone/emulator when
Code:
adb connect ___
command is executed. Is there anyway to manually start the daemon through a terminal app on the installed on phone? I tried 'adb', 'adbd' and 'setprop' commands in the Termux app but these commands doesn't exist. According to the txt files of the repository, the ADB on computer is sending the commands to the Android device/emulator and can start 'adbd' or set/open the port 5555 using
Code:
setprop service.adb.tcp.port 5555
command. Is there a way to do this on Android phone using a terminal app on a non-rooter phone?
Somebody who has knowledge of networking, Android and C/C++ language may be able to answer. One can look in the GitHub repo of ADB source code if they want to know what is happening during the connection process.
I'm a little late to answer your question at the time you asked it, but if it still helps the OP, non-rooted Android 10 and below allowed wireless adb connections AFTER a USB connection was first established (adb start-server && adb tcpip 5555 && adb connect [IP]:5555), but that changed (for the better) in Android 11 and above with the new new Developer options Wireless debugging random port assignments (adb connect [IP]:[PORT] or adb pair [IP]:[PORT] [PIN]) such that the adb wireless connection never needs USB cable ever again.
Given Android 11 allows Developer options Wireless debugging via a random port, and Android 12 new Developer options Wireless debugging allows that to be accessed even easier with a new Developer options Wireless debugging tile, the only thing missing is a way to get, after the fact, the random port assignment that Android uses for the adb wireless connection to your PC.
Here are some related posts about that subject which may help the OP.
[adb,scrcpy,vysor] What ports does Android 12 randomly set when Wi-Fi connecting via Wireless debugging adb "pair" or "connect" commands?
(PSA) Using the new Android 12 TILE for 'Developer options' 'Wireless debugging' to establish adb connection over Wi-Fi without USB
What's the difference between Windows/Android adb "connect" versus adb "pair" when mirroring Android 12 over Wi-Fi onto a Windows PC?
The only question that's missing an answer preventing a perfect solution is...
Does anyone know how to obtain that random Android port address from the PC?

ADB over Internet

Has anyone tried to ADB over different wifi? My friend lives far away and wants to root his phone but doesn't have a computer. Is it possible for me to use my computer TO root for him, maybe via hamachi??
Thanks in advice for suggestions
ADB Wireless requires the phone's Android must be rooted.
More info here:
Setting Up ADB on Windows and Connecting Wirelessly to Android
How to Set up ADB on Windows Platform Android Debug Bridge (ADB) is a tool that gives you options to modify, tweak, or debug your Android device. The ADB establishes a connection between your PC and Android device or emulator (for development purposes) through a built-in server.
www.gizbeat.com

Categories

Resources