Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Android Chroot DNS Updater Script (Linux Deploy / Nethunter)
#!/system/xbin/bash
# Android Linux chroot DNS Updater Script
# Written by: Geofferey @ XDA / IG
# For updating /etc/resolv.conf in chroot
# Tested on Kali Nethunter / Linux Deploy
# Chroot placed in directory not file.img
# Works on Android Version Nougat 7.1.2
# Place in init.d of Nethunter or Android
## Begin main loop
while true; do
##Retrieve current Android DNS setting & assign to var
CHROOT_RESOLV_CONF=/data/local/nhsystem/kali-armhf/etc/resolv.conf
DNS_1="$(getprop net.dns1)"
## Begin secondary loop
while true; do
## Retrieve comparison Android DNS setting & assing to var
DNS_COMP="$(getprop net.dns1)"
sleep 5
## Compare the vars, if diff break secondary loop
if [ "$DNS_COMP" != "$DNS_1" ]; then
break
fi
done
## Obtain & set the name servers in chroot resolv.conf
DNS_1="$(getprop net.dns1)"
DNS_2="$(getprop net.dns2)"
echo "nameserver" $DNS_1 > $CHROOT_RESOLV_CONF
echo "nameserver" $DNS_2 >> $CHROOT_RESOLV_CONF
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.