I recently had to bypass Android's Factory Reset Protection again, this time for a Samsung Galaxy J4. The procedure at the end turned out to be relatively simple (find a way to get to a browser from the initial screen, download a pair of APKs, finish the Google account login with a random Google account, uninstall the APKs). However, due to the circumstances I was operating in, I spent a lot of time figuring out how to share an internet connection from my laptop with a second Android phone so I could share it with the J4 using the second phone as a wi-fi hostspot. This post documents what I learned.
There are dozens of videos on YouTube explaining how to do it. I will summarize the information here.
https://frpfile.com/bypass/. DISCLAIMER: I don't know if those APKs can be trusted.
Sharing your Android phone's internet connection with your computer is pretty easy: you just enable USB tethering on the phone, and everything magically works (at worst, you have to call
dhclient YOUR-USB-INTERFACE on Linux if you don't have NetworkManager running). Doing the opposite, i.e., sharing your (Linux) computer connection with the phone, has to be done manually. Here is how it goes (I'm assuming a rooted phone; mine runs LineageOS 14.1 (Android 7)):
adb shellfrom the computer), set up the interface with some IP of choice, e.g.,
ip addr add 10.0.5.2/24 dev rndis0 ip link set rndis0 up
sudo ip addr add 10.0.5.1/24 dev rndis0 sudo ip link set rndis0 up
Note: Most likely you will have to replace
rndis0 with something else, depending on the name your system decided to give to the USB interface.
ping 10.0.5.2from the computer should work).
sudo service network-manager stop).
Now, to share the internet connection:
iptablesrule to do NAT forwarding:
sudo iptables -t nat -A POSTROUTING -o <your-internet-interface> -j MASQUERADE
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
ip route add default via 10.0.5.1
ping 184.108.40.206should work).
ip rule add from all lookup main
We still have to set DNS. Android does not seem to have a
resolv.conf file; I found multiple ways you can set DNS (using
220.127.116.11 as the DNS servers in the examples):
setprop net.dns1 18.104.22.168; setprop net.dns2 22.214.171.124
setprop net.rndis0.dns1 126.96.36.199; setprop net.rndis0.dns1 188.8.131.52
ndc resolver setnetdns rndis0 184.108.40.206 220.127.116.11
The last one is the only one that worked for me – and it requires two DNS servers as arguments.
By now, you should have a working internet connection on your phone (you can try it in the browser, for example).
If you want to share it with other devices via wi-fi, you can now enable Wi-Fi Hotspot on the phone. However, there is another weird thing here: for some reason, my phone would reject all DNS queries coming from the other devices. The 'solution' I ended up using was to redirect all requests to port 53 (DNS) coming from other devices to the DNS server I wanted to use:
iptables -t nat -A PREROUTING -p tcp --dport 53 -j DNAT --to-destination 18.104.22.168:53 iptables -t nat -A PREROUTING -p udp --dport 53 -j DNAT --to-destination 22.214.171.124:53
This will skip the Android builtin DNS server entirely, and send DNS requests directly to the desired DNS server.
Copyright © 2010-2023 Vítor De Araújo
O conteúdo deste blog, a menos que de outra forma especificado, pode ser utilizado segundo os termos da licença Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International.
Powered by Blognir.