Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save fnordomat/db16a1357a55d7410d15c1a2a724b336 to your computer and use it in GitHub Desktop.

Select an option

Save fnordomat/db16a1357a55d7410d15c1a2a724b336 to your computer and use it in GitHub Desktop.
Automatic negotiation of a captive portal: connect to icomera wifi in CD trains without having to jump through hoops.
# I believe this is the necessary and sufficient step to get internet access on board the Czech long distance trains (e.g. EuroCity which runs from Prague to Kiel)
curl -vLA '' 'http://cdwifi.cz/portal/api/vehicle/gateway/user/authenticate'
# It says "500 internal server error" but that doesn't keep it from working.
# check with this request, answer should contain "authenticated":1
curl -vLA '' 'http://cdwifi.cz/portal/api/vehicle/gateway/user'
# Also nice: GPS data (but seems outdated)
curl -vLA '' 'http://cdwifi.cz/portal/internal/api/x6/position'
# Really nice: show connectivity including the LTE uplinks
curl -vLA '' http://www.info.cdwifi.cz/api/jsonp/connectivity
@JanC

JanC commented Dec 28, 2019

Copy link
Copy Markdown

Nice, thanks for sharing 👍

@fnordomat

Copy link
Copy Markdown
Author

You're welcome. I hope it was useful :-)

@krjan02

krjan02 commented Dec 30, 2019

Copy link
Copy Markdown

Im currently in a CD Train, trying to get GPS data :(

@fnordomat

fnordomat commented Dec 30, 2019

Copy link
Copy Markdown
Author

Let me know if you get it ;-)
IIRC I found the API link in one of the response HTMLs, maybe there's more interesting stuff in there

@fnordomat

Copy link
Copy Markdown
Author

and have a safe trip

@krjan02

krjan02 commented Dec 30, 2019

Copy link
Copy Markdown

Thanks :)
so what i found: http://cdwifi.cz/portal/api/vehicle/realtime

Response:

gpsLat":51.476318,"gpsLng":13.52959,"speed":151,"delay":null,"altitude":92.9,"temperature":null

it's a really nice thing to do when you are bored :D

@fnordomat

Copy link
Copy Markdown
Author

nice, thanks!

@krjan02

krjan02 commented Dec 30, 2019

Copy link
Copy Markdown

oh and there are newer trains like the EC 183, they dont have an "Portal", also WiFi only work in Czech.
GET Request to the Gateway will return an Lorum Impsum Agree Page. Just for anyone that is wondering ^^

@JanC

JanC commented Jun 2, 2020

Copy link
Copy Markdown

Also the data limit outside of CZ is (as often) based in the mac address. So to reset it, just change the mac address of your network interface and reconnect.

macOS:

sudo ifconfig en0 ether <new-mac-address>

@fnordomat

Copy link
Copy Markdown
Author

Good point.

@bzamecnik

Copy link
Copy Markdown

Nice figuring out of the other hidden services. If you need just a one-click confirmation from command line that work on both Mac and Linux, I've prepared as script: https://gist.github.com/bzamecnik/46bd84c530e61a706ddca8a19263e2c1. It can work around the problem when a custom DNS (such as 8.8.8.8) can't resolve their inner domain. Just install and type cdwifi. :)

@fnordomat

Copy link
Copy Markdown
Author

@bzamecnik Nice to see that my solution still works. I've linked to yours in the https://github.com/fnordomat/misc/blob/master/captive-be-gone/minisurvey.txt and hope to expand this even further, especially as travel picks up again :-)

@AElouai

AElouai commented Sep 14, 2020

Copy link
Copy Markdown

thanks

@JanC

JanC commented May 25, 2021

Copy link
Copy Markdown

Some more fun: Using the /connectivity/ endpoint, we can see the currently connected links. A command line shortcut to see those that are connected and their signal level:

curl -s  http://www.info.cdwifi.cz/api/jsonp/connectivity/ \
    | tr -d '(' | tr -d ')' | tr -d ';' |  \
    jq '.links[] | select(.link_state=="available")'

{
  "index": "104",
  "device_type": "modem",
  "device_subtype": "sierra-7710",
  "device_state": "up",
  "link_state": "available",
  "rssi": "-55",
  "technology": "lte",
  "operator_id": "26201",
  "apninfo": "railnet.telekom,-1,-1",
  "umts_info": {
    "net_status": "1",
    "lac": "FFFE",
    "cellid": "0231E502"
  }
}
{
  "index": "105",
  "device_type": "modem",
  "device_subtype": "sierra-7710",
  "device_state": "up",
  "link_state": "available",
  "rssi": "-81",
  "technology": "lte",
  "operator_id": "26202",
  "apninfo": "fv1.deutschebahn.com,-1,-1",
  "umts_info": {
    "net_status": "1",
    "lac": "FFFE",
    "cellid": "002AE302"
  }
}

or show only some fields using

curl -s  http://www.info.cdwifi.cz/api/jsonp/connectivity/ \
    | tr -d '(' | tr -d ')' | tr -d ';' |  \
    jq '.links[] | select(.link_state=="available") | {rssi, apninfo, technology}''

{
  "rssi": "-51",
  "apninfo": "railnet.telekom,-1,-1",
  "technology": "lte"
}
{
  "rssi": "-70",
  "apninfo": "fv1.deutschebahn.com,-1,-1",
  "technology": "lte"
}

@fnordomat

Copy link
Copy Markdown
Author

Nice!

@hi-ko

hi-ko commented Apr 6, 2025

Copy link
Copy Markdown

I was traveling to Praha this weekend and I don't know if it's intentional, but the confirmation page on http://www.cdwifi.cz/ only works with a czech locale (cs-CZ,cs). For this to work, you may have to delete the cockies

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