Code Monkey home page Code Monkey logo

android-captive-portal's Introduction

AndroidCaptivePortal

WebServer forked from: JustWeEngine

Disclaimer

I'm not responsible for anything you do with this app.
I'm not responsible of any damage you receive using this app.

What is this? Why?

I built this app to simplify the creation of basic "EvilTwin" captive portal on Android.

The app is composed by a webserver (JustWeEngine) and a Dns server wrote from scratch. Once a new device is connected, a DNS server resolves all the dns request with the Webserver IP.

You can do the same attack with a pc, a raspberry pi or an esp8266.. but I decided to build one on android, because smartphones are easier to bring everywhere and I wanted something easy to use.

Requirements

I suggest to use an old phone, with a sim card with 0 euro on it: even if someone bypass the captive portal in some way... you spend 0.

I used a Nexus 5, with android 6 and rooted: the rooting is needed to add 2 iptables rules, to redirect all the incoming traffic from ports 80 and 53 to (Web Server) 8080 and (Dns Server)8053.

The 2 servers runs on the same android service controlled by an unique activity.

Adb Tools are required.

How To use it (right now):

The following steps have to be executed once, after each boot of the device, and are valid until the next reboot.

  • Enable debugging on the device
  • Connect the device with USB and on a terminal launchs "adb shell"
  • Execute the following commands:
    • su
    • iptables -t nat -A PREROUTING -p udp --dport 53 -j REDIRECT --to-port 8053
    • iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

These steps are always valid:

  • Setup tethering on the device with the exact same name of the original Access point or appending strings like "-Guest" to the name.
  • Enable tethering on the device
  • Servers Ip are hardcoded with 192.168.43.1 (default ip on tethering of my device).
  • Launch the app, press the floating button to start Web and Dns Server.
  • To stop the application click again the floating button.

Under the hood

All DNS requests answer to 192.168.43.1.
All unknown path redirects to webroot/index.html : right now, this is relative to the asset folder of the android app.
The asset folder contains a sample login form that you should adapt to your needs

Known path:

  • any_address/login.cgi: it should be invoked by a form in an html page, with GET methoed(see sample page). It answers back Connected.
  • any_address/logs: show saved logs of the application. The logs are saved in a file inside the application/data directory. Actually the logs trace all the login.cgi attempt.

Roadmap

  • iptables rules should be automatically added by the application: delete & add automatically at every launch.
  • configurable Server IP or automatic detection (now is hardcoded 192.168.43.1).
  • add a new known command/path to clean log file
  • add statistics page: number of connected people, number of tries and so on, on the device main screen.
  • load file from external memory (eg. sdcard)
  • lower android version requirements
  • configurable root folders from app
  • password protect some pages (logs/clean/stats)
  • enforce redirecting with iptables rules

Nice to have

  • page cloning: be able to capture the page of another captive portal and automatically change the tag values.

I'm open to collaboration.
Have fun!

android-captive-portal's People

Contributors

crazycoder1999 avatar lfkdsk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.