Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

All the simple programs have been written.


computers / alt.internet.wireless / How do we find the random Android wireless LAN debugging port from a Windows PC?

SubjectAuthor
* How do we find the random Android wireless LAN debugging port from a Windows PC?Andy Burnelli
`- Re: How do we find the random Android wireless LAN debugging port from a Windowscris

1
How do we find the random Android wireless LAN debugging port from a Windows PC?

<tcbltf$1k5f$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=329&group=alt.internet.wireless#329

  copy link   Newsgroups: alt.comp.os.windows-10 alt.internet.wireless comp.mobile.android
Path: i2pn2.org!i2pn.org!aioe.org!htnL9PrEhukO41EXSqWbXA.user.46.165.242.75.POSTED!not-for-mail
From: spa...@nospam.com (Andy Burnelli)
Newsgroups: alt.comp.os.windows-10,alt.internet.wireless,comp.mobile.android
Subject: How do we find the random Android wireless LAN debugging port from a Windows PC?
Date: Tue, 2 Aug 2022 18:12:41 +0100
Organization: Aioe.org NNTP Server
Message-ID: <tcbltf$1k5f$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="53423"; posting-host="htnL9PrEhukO41EXSqWbXA.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.6.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: Andy Burnelli - Tue, 2 Aug 2022 17:12 UTC

How do we find the random Android wireless debugging port from a Windows
PC?

Or, if we can't find the exact port, maybe we can search a set of ports?

But an official MS portqry.exe search takes forever even with the official
MS portqryui.exe GUI (ask me how I know this)?
<https://docs.microsoft.com/en-us/troubleshoot/windows-server/networking/portqry-command-line-port-scanner-v2>
<https://www.microsoft.com/en-us/download/details.aspx?id=17148>

What would be faster is to guess which ports Android uses, given they
always seem (in my experience) to be between ports 3#### & 4####, but
searching even just those ports using the Microsoft tools takes forever.

Hence the question...

What ports does Android 12 randomly set when connecting wirelessly to adb
via either the Wireless debugging "pair" or the "connect" adb PC commands?

*Brief history:*
While Android has forever been able to initially connect over TCP Port
5555 over USB first, and then the USB cable could have been disconnected
to mirror Android over to the PC wirelessly on your LAN...

... As of Android 12, there are fantastic new "Developer options"
for "Wireless debugging" which allow us to mirror Android over to any
PC (Mac/Windows/Linux) without ever needing a USB cable ever again!

*Brief background:*
The wonderful screen mirroring tools (Vysor, Scrcpy, Sndcpy,etc.)
connect using adb using your local Wi-Fi LAN (which is great!).

We write scripts on the PC to mirror multiple devices onto the
PC sans consoles.

Each Android device has a random port assignment for adb "pair"
for adb "connect" commands (the difference likely being encryption).
C:\> adb connect 192.168.0.2:[RANDOM-PORT]
C:\> adb pair 192.168.0.2:[RANDOM-PORT] [RANDOM-PIN]

Our scripts need a tool to TEST which random port Android 12 sets Developer
options Wireless debugging to.

We have a variety of tools but those port-scanning tools take FOREVER to
run on all possible ports.

Hence it behooves us to limit the port scan to just the ports Android 12
uses for Wireless debugging.

Examples:
C:\> portqry -n 192.168.0.2 -r 30000:40000
C:\> netstat -ano -p tcp | findstr "92.168.0.2"
C:\> adb shell "ifconfig|grep -A 1 wlan0|tail -n 1|cut -f2 -d:|cut -f1 -d' '"
C:\> adb mdns services
C:\> nmap 92.168.0.2
etc.

The need for a more efficient port scan is the reason I ask this very
specific question:
Q: What ports does Android 12 use for Developer options Wireless
debugging?
--
The question is asked hoping to find someone who knows more than I do
somewhere in the world of Usenet who can answer the question so that the
result will be EVERYONE benefits from the ability to run scripts to recover
from the random assignment of Android ports when connecting wirelessly.

Re: How do we find the random Android wireless LAN debugging port from a Windows PC?

<tch31e$35g72$1@news.mixmin.net>

  copy mid

https://www.novabbs.com/computers/article-flat.php?id=330&group=alt.internet.wireless#330

  copy link   Newsgroups: alt.comp.os.windows-10 alt.internet.wireless comp.mobile.android alt.msdos.batch
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.mixmin.net!.POSTED!not-for-mail
From: cri...@removespam.me.com (cris)
Newsgroups: alt.comp.os.windows-10,alt.internet.wireless,comp.mobile.android,alt.msdos.batch
Subject: Re: How do we find the random Android wireless LAN debugging port from a Windows PC?
Date: Thu, 4 Aug 2022 15:57:20 -0230
Organization: Mixmin
Message-ID: <tch31e$35g72$1@news.mixmin.net>
References: <tcbltf$1k5f$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 4 Aug 2022 18:26:55 -0000 (UTC)
Injection-Info: news.mixmin.net; posting-host="a112537deea7100e63648454b2f8da25ce49846c";
logging-data="3326178"; mail-complaints-to="abuse@mixmin.net"
User-Agent: Usenapp/0.93/l for MacOS - Full License
 by: cris - Thu, 4 Aug 2022 18:27 UTC

Andy Burnelli <spam@nospam.com> wrote:

> How do we find the random Android wireless debugging port from a Windows PC?
>
> Or, if we can't find the exact port, maybe we can search a set of ports?

You and everyone else since Android 11 wants to know the same answer.
https://medium.com/@amanshuraikwar.in/connecting-to-android-device-with-adb-over-wifi-made-a-little-easy-39439d69b86b

If you can port this to Windows command line it might work but you might need to be an admin.
https://gist.githubusercontent.com/amanshuraikwar/384ed1a77b1c5bfe577c219297b5882e/raw/4d80e2e1f25d017276c298f076d4f7c86c442728/adbwificonnect.sh

# Purpose: Shell script to connect a USB connected device via adb over WiFi
#
# Author: Amanshu Raikwar
#
# Assumptions:
# 1. USB debugging is enabled in the Android device
# 2. The Android device is connected to the computer via USB
# 3. The Android device is connected to the same wifi as the computer
# 4. The Android device is accessible through port 5555 over the wifi network
#
# How To Use (without any options):
# 1. Paste the file where adb resides, for mac it is ~/Library/Android/sdk/platform-tools/
# 2. Run ./adbwificonnect
# 3. Choose the device by typing X in [X] --> ... when prompted
# 4. Wait around 6-7 seconds
# 5. Connected!
#
# Options:
# -a
# To connect to all available devices
#
# -d device_id
# Specifies the device id to be connected to

# if no command line params provided
if [ -z "$1" ]; then

clear

# list available devices
echo "Available devices:"
devices="$(./adb devices)"

export IFS=$'\n'

declare -a devicemap

i=0

# save device info in an array
for word in $devices; do
devicemap+=("$(echo $word | awk '{print $1}')")
echo "[$i] --> $word"
i=$((i+1))
done

# wait for user input to choose device
read -p "Choose device: " choice

# chosen device id
device=${devicemap[choice]}

devicename="$(./adb devices -l | grep $device | awk '{print $4}' | cut -d: -f2)"
devicemodel="$(./adb devices -l | grep $device | awk '{print $5}' | cut -d: -f2)"

echo "Connecting to device $device $devicename $devicemodel..."

# restart adb in tcpip mode for the device
./adb -s $device tcpip 5555

# wait for adb to restart
# note: this may change depending on the computer
sleep 5s

# find out the wlan0 ip of the device by running ifconfig in device's shell
ip="$(./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')"
echo "Connecting to $ip..."

# connect to the device
./adb connect $ip:5555

# connect to all available devices
elif [ $1 == "-a" ]; then

# list available devices
echo "Connecting to all available devices..."
devices="$(./adb devices)"

export IFS=$'\n'

declare -a devicemap

i=0

# iterate for each device and connect
for word in $devices; do

# device id
device=("$(echo $word | awk '{print $1}')")

# skip the first line
if [ "$i" != "0" ]; then

echo "---"

devicename="$(./adb devices -l | grep $device | awk '{print $4}' | cut -d: -f2)"
devicemodel="$(./adb devices -l | grep $device | awk '{print $5}' | cut -d: -f2)"

echo "Connecting to device $device $devicename $devicemodel..."

# restart adb in tcpip mode for the device
./adb -s $device tcpip 5555

# wait for adb to restart
# note: this may change depending on the machine
sleep 5s

# find out the wlan ip of the device by running ifconfig in device's shell
ip="$(./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')"
echo "Connecting to $ip..."

# connect to the device
./adb connect $ip:5555

fi

i=$((i+1))
done

# connect to a specific device
elif [ $1 == "-d" ]; then

if [ -z "$2" ]; then
echo "-d expects device id as the second parameter"
exit 1
fi

device="$2"

devicename="$(./adb devices -l | grep $device | awk '{print $4}' | cut -d: -f2)"
devicemodel="$(./adb devices -l | grep $device | awk '{print $5}' | cut -d: -f2)"

echo "Connecting to device $device $devicename $devicemodel..."

# restart adb in tcpip mode for the device
./adb -s $device tcpip 5555

# wait for adb to restart
# note: this may change depending on the machine
sleep 5s

# find out the wlan ip of the device by running ifconfig in device's shell
ip="$(./adb -s $device shell ifconfig wlan0 | grep 'inet addr' | cut -d: -f2 | awk '{print $1}')"
echo "Connecting to $ip..."

# connect to the device
./adb connect $ip:5555

else
echo "Flag '$1' is not supported!"
fi

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor