Tagged: captive portals
- This topic has 3 replies, 2 voices, and was last updated 4 years, 3 months ago by Diego Pérez.
- AuthorPosts
- July 14, 2020 at 1:00 pm #42046Marek KovalcikParticipant
Hello, I have a problem while setting up a captive portal.
Here is a printscreen: https://pasteboard.co/JhBFnyA.png
i am using this adapter: https://zsecurity.org/product/realtek-rtl8812au-2-4-5-ghz-usb-wireless-adapter/I have the dnsmasq.conf and hostapd.conf files. I added the redirecting part to 000-default.conf file for apache2.
Then I run following (these lines I have in start_captive_portal.sh)
#!/bin/bash
service network-manager stop
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables –flush
iptables –table nat –flush
iptables –delete-chain
iptables –table nat –delete-chain
iptables -P FORWARD ACCEPTdnsmasq -C dnsmasq.conf
hostapd hostapd.conf -B
ifconfig wlan0 10.0.0.1 netmask 255.255.255.0
service apache2 startAnd got these errors:
root@kali:~/CaptivePortal# ./start_captive_portal.sh
iptables: Directory or file does not exist c/sys/net/ipv4/ip_forwarddnsmasq: failed to bind DHCP server socket: Address is in use
Configuration file: hostapd.conf
Using interface wlan0 with hwaddr 54:c9:ff:00:16:57 and ssid “Free WiFi”
wlan0: interface state UNINITIALIZED->ENABLED
wlan0: AP-ENABLED
Job for apache2.service failed because the control process exited with error code.
See “systemctl status apache2.service” and “journalctl -xe” for details.Can you help me?
July 15, 2020 at 4:10 am #42088Diego PérezModeratorHi!
I would recommend to run the commands manually, it would be better.
The first error is something related to the script you created and the use of >
The second (dnsmasq) is weired as the address is not being used or you are running the script for a second time.
For the apache issue use this command before starting it:
systemctl enable apache2At the end of all it saids AP-ENABLED which means that the fake AP should be satrted, but the other errors might be interfering with it.
Let me know how it goes!
DiegoJuly 15, 2020 at 8:26 am #42098Marek KovalcikParticipantHello, I run the commands manually but I still get this error after running service apache2 start. I get this error only if I added following to the 000-default.conf file.
<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>root@kali:~/CaptivePortal# service apache2 start
Job for apache2.service failed because the control process exited with error code.
See “systemctl status apache2.service” and “journalctl -xe” for details.$ systemctl status apache2.service
OUTOUT: https://pasteboard.co/JhJkeZY.png
It says there is a syntax error on line 35 of 000-default.conf file. I copied the rewrite rules from course. Are they ok? Is there any mistake in rewrite rules?This is my whole 000-default.conf file.
<VirtualHost *:80>
ErrorDocument 404 /
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request’s Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName http://www.example.comServerAdmin webmaster@localhost
DocumentRoot /var/www/html# Available loglevels: trace8, …, trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warnErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with “a2disconf”.
#Include conf-available/serve-cgi-bin.conf
</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># vim: syntax=apache ts=4 sw=4 sts=4 sr noet
July 16, 2020 at 4:37 am #42245Diego PérezModeratorHi!
The rules look ok, can you try to reboot kali? Then start apache server again.Let me know how it goes!
Diego - AuthorPosts
- You must be logged in to reply to this topic.