How to run an offline DNS Server on Android? - android

Let me explain the situation:
I am using my android phone as WiFi hotspot that gives a code (that user can reedem on my shop) when he has completed a registration.
I need to use my phone because I do this on the beach and the only way to to this is having something portable.
Okay, so:
I have used this tecnique so far and everithing gone well, i have set up a webserver on my phone and using some iptables i redirected all the traffic to my captive portal when a user tries to surf the net.
It worked like this:
USER asked my phone: "Hey what's the IP for google.com?"
MY PHONE connected to DNS and received the correct IP.
IPTABLES manipulated this IP to send to USER the local ip of my captive portal.
But there's a big problem: i need mobile data on!! And on the beach many times i do not have signal and when a user connect to my hotspot, it gives DNS error instead of my captive portal.
The only solution is to run an offline DNS server that doesn't require internet to hijack all the request to the captive portal.
I use BitWebServer as ligthhttpd server and i looked for DNS Server to run my DNS offline but i am really confused and i don't know where to start.
Someone of you have and idea? I just need to redirect all the request that comes from USER connected to my hotspot to the captive portal WITHOUT using internet.
Thanks in advice, regards
Giorgio

Related

Captive portal: Android phone not sending data to private access point DNS server. Windows laptop and iPhone works

For my ESP32 project, I need a captive portal where the user can enter their WiFi SSID and password. This is a commercial project that needs to work across a wide consumer base. But there are some issues with Android phones. Since things worked several weeks ago, I suspect they changed some security settings in the last few months, but I can't figure out what they are or how to work around them.
In short, the solution opens an access point and sets up a DNS server that reroutes all requests to the AP. The AP serves up an HTML form page asking for the user's SSID and PW. I'd be happy to share the code, but I think this is about Android. The code follows a template that all successful projects do. For example this one
iPhone test:
DNS server receives ␇captive␅apple␃com and opens up the captive portal.
Windows 11 laptop test:
DNS server receives a bunch of names:
␃www␏msftconnecttest␃com
␄bolt␇dropbox␃com
␃api
dropboxapi␃com
␆client␃wns␇windows␃com
␃geo␄prod␂do␃dsp␂mp microsoft␃com
␃nav␋smartscreen microsoft␃com
␆client␃wns␇windows␃com
␇gateway␇discord␂gg
␅mtalk␆google␃com
I still need to enter local IP to see captive portal page.
Android phone (Galaxy X) test:
DNS server receives nothing.
Can't reach captive portal in any way.
Question: What could be going on here? I can't even find the documentation of what Android could be doing. I would really appreciate any pointers.

Find out ip of server android app is using

So, i am testing my app, it saves data of accounts to a server, and i am wondering if it is possible to get server ip by just having app instaled.
Is there some methods?
Of course. You can get the IP just by checking the router and seeing where requests were made to, you don't even need to run the app- just someone on the network needs to. IP addresses aren't secret.

Debugging an App, that needs a URL to a server

I have a Xamarin Solution with an Android, iOS, and Windows mobile solution. I also have a Web Server that sits on localhost:XXXX.
I need to be able to access the URI endpoints on my local, while debugging on Mobile.
While the Web Server is running I go to fiddler, and compose http://localhost:XXXX/api/Locationsand everything is correct, I get the JSON data and life is good.
However when debugging the App on any phone, I suspect the endpoint on the phone is trying to access it's own "localhost". Is there a hosts file that I can edit on the emulators? or another solution?
If you have WiFi, change localhost to your local IP address and connect phone to that WiFi

Limited wifi Tethering Facility

I wanted to create a payment portal, where the offline users would connect to my store Hotspot and make online payments. However, due to obvious reasons, i would like the users to be able to connect to the payment portal only. Is there a way i could do a whitelisting (or Blacklisting) of the URLs to which the network packets are destined ? Is there possibility that source code of tethering could be modified and an application could be built upon it that would get the job done ? If yes, then can it be done without rooting the phone.
P.S - I don't want to use Proxy.

cookies are not received on mobile data but received with wifi during registration in android(device is sony xperia)

I am doing registration in my app using HTTP. If I do registration via MOBILE DATA my cookies are not coming from server But If i do the same task via WIFI cookies are coming properly. And this problem is being faced on just one handset i.e. "SONY XPERIA M". On other handset, cookies are coming on both via mobile data and via wifi too.
Why so?
It is almost impossible to answer this question with this little information, but here's some general help to get your problem sorted out:
Take a look at your cookie parameters. The domain, path, etc have to match the domain, path, etc. you are serving the page from. Some devices may be more lenient, others may not be.
Try to route your internet traffic via a VPN, so you bypass any wonky filtering or CGN your network provider may apply.
Switch your application to HTTPS. HTTPS cannot be manipulated by intermediaries, so your cookies should be safe.
Do extensive traffic logging on the server if possible. You can capture packets from your mobile device if you know it's IP address using tcpdump and then display them in Wireshark. This should enable you to piece together why it isn't working.
In the traffic dump take a look at the headers sent from the client. Be suspicious of any headers that may indicate the presence of proxies. Also take a look if the IP address your device thinks has is the same the traffic is coming from. If it isn't, a NAT or transparent proxy is in place.
Try to sniff the traffic directly on the device and compare it to what the server sees. If the traffic differs, there is some proxying in place. There are some android apps for that.
I hope this helps. If you need additional help, please post a lot more information, especially the exact cookie header you are sending out.

Categories

Resources