DHCP Captive portal using scapy

317 views Asked by At

I'm writing a simple dhcp server in python using Scapy, and i'm trying to make a new connected clients to the network have a browser popup with captive portal (of my choice)

For what I've read over the internet, it is required to set up DHCP option 33 (Static-Routes) and in addition to that, i also have set up DHCP option 160 v4-captive-portal, but unfortunately it seems like I'm missing something, and i'm not sure what it is.

The client authenticating against my Python DHCP server receives an IP address with no problem, and my server and client can communicate with each other with no problem

Some things worth mentioning:

  1. My client is my Macbook
  2. The connection is Wires, and NOT wireless (not wifi)
  3. I have a simple HTTP service running on my DHCP server, so it can serve both DHCP and HTTP requests (for the captive portal)

My total DHCP configuration:

packet_to_send = (BOOTP(op=2, yiaddr=client_ip, siaddr=server_ip, giaddr=server_ip, chaddr=pkt[BOOTP].chaddr, xid=pkt[BOOTP].xid) /
                    DHCP(options=[('message-type', 'offer'),
                            ('static-routes', socket.inet_aton(server_ip)*2), # Is that the correct configuration?      # Option: 33
                            ('server_id', server_ip),           # Option: 54
                            ('lease_time', 3600),               # Option: 51
                            ('subnet_mask', subnet_mask),       # Option: 1
                            ('router', server_ip),              # Option: 3
                            ('name_server', server_ip),         # Option: 6
                            ('domain', my_domain_name),         # Option: 15
                            ('v4-captive-portal', server_ip),   # Option: 160
                            ('renewal_time', 1800),             # Option: 58
                            ('rebinding_time', 3150),           # Option: 59
                            "end"])) # 255
0

There are 0 answers