Skip to content

Instantly share code, notes, and snippets.

@lgarron
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgarron/5230cc1eebcc19385ed0 to your computer and use it in GitHub Desktop.
Save lgarron/5230cc1eebcc19385ed0 to your computer and use it in GitHub Desktop.
Chrome Captive Portal Testing

Add the following line to /etc/hosts (remember to undo this):

127.0.0.1 www.gstatic.com

Run a simple server on port 80. Here's a command you can run from bash:

cat <<EOF | sudo python -
import SocketServer
import SimpleHTTPServer
class CustomHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
    def do_GET(self):
        self.send_response(200)
        self.send_header('Content-type','text/html')
        self.end_headers()
        self.wfile.write('Captive Portal Page')
SocketServer.ThreadingTCPServer(('localhost', 80), CustomHandler).serve_forever()
EOF

Launch Chrome and navigate to an SSL page that is normally broken (adapt CHROME_PATH for your OS):

CHROME_PATH="/Applications/Google Chrome.app/Contents/MacOS/Google Chrome"
"$CHROME_PATH" --user-data-dir="/tmp/captive-portal" "https://expired.badssl.com/"

(When you're done, restore your /etc/hosts file.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment