Score:0

How to bypass DNSMASQ traffic redirect (address=/#/10.0.0.1) after Captive Portal Authentication?

do flag

I wanted to write a captive portal from scratch using the following:

  • hostapd v2.10 to setup my wlan0 as an AP and eth0 is connected to the internet router.
    #/etc/hostapd/hostapd.conf

    interface=wlan0
    driver=nl80211
    ssid=MyWIFI
    hw_mode=g
    channel=11

  • dnsmasq v2.86 as DHCP & DNS
    #/etc/dnsmasq.conf

    interface=wlan0
    dhcp-range=10.0.0.2,10.0.0.250,24h
    dhcp-option=3,10.0.0.1
    dhcp-option=6,10.0.0.1
    domain-needed
    bogus-priv
    no-resolv
    address=/#/10.0.0.1

  • iptables to share internet of eth0 to wlan0
    sysctl -w net.ipv4.ip_forward=1
    sysctl -p
    iptables -X
    iptables -F
    iptables -F INPUT
    iptables -F OUTPUT
    iptables -F FORWARD
    iptables -F -t mangle
    iptables -X
    iptables -t nat -X
    iptables -t nat -F

    iptables -t nat -I POSTROUTING -o eth0 -j MASQUERADE

  • Ubuntu 22.04 Server
  • Apache v2.4.52 as my webserver
    #Added below config in /etc/apache2/sites-available/000-default.conf.  Just right 
    #below the </VirtualHost>

    <Directory "/var/www/html">
        RewriteEngine On
        RewriteBase /
        RewriteCond ${HTTP_HOST} ^www\.(.*)$ [NC]
        RewriteRule ^(.*)$ http://%1/$1 [R=301,L]

        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteRule ^(.*)$ / [L,QSA]
    </Directory>

  • Angular is used to write the Captive Portal
  • nodejs is used to write the APIs for the Captive Portal

I managed to trigger the Sign-in to network for Android which when tapped redirects to the Captive Portal & for iOS the redirection is automatic.

In the Captive Portal, I have a button to accept a Voucher Code that is validated in the backend (nodejs). My objective is to allow the device with a valid Voucher Code to access the internet with a limited time and should not be redirected anymore to the Captive Portal.

But I don't know how to proceed since in my dnsmasq.conf I have configured address=/#/10.0.0.1 and as far as I know this will redirect back network traffic to my dnsmasq server where apache is configured to redirect the request to the Captive Portal.

Hope someone could lead me to the right direction. Thank you very much.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.