Skip to content

Instantly share code, notes, and snippets.

@Fuseteam
Last active November 25, 2025 13:41
Show Gist options
  • Select an option

  • Save Fuseteam/52851ed10aed0f680883c71c4949e6a1 to your computer and use it in GitHub Desktop.

Select an option

Save Fuseteam/52851ed10aed0f680883c71c4949e6a1 to your computer and use it in GitHub Desktop.
wirelessly connect adb over ip and port discovered by nmap
#!/usr/bin/awk -f
# USAGE:
# download and save in ~/.local/bin (e.g. as adbw)
# make executable chmod +x ~/.local/bin/adbw
# run adbw 192.168.1.232
BEGIN{
FS = "[ /]"
ARGC=2
# Use -Pn to skip host discovery, --max-retries to only try each port once, --min-rate to send package no slower than 2000 per second
c="nmap -Pn --max-retries 2 --min-rate 2000 "ARGV[1]" -p 32768-60999"
print "scanning "ARGV[1]"..."
while(c|getline) {
if (/\/tcp/) {
device=ARGV[1]":"$1
print "found: "device
}
}
close(c)
if( device != ""){
print "connecting..."
system("adb connect "device)
}else {
print "No ADB port found"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment