92 points · by pm24601 · 8y ago · 113 comments
Been also digging into making a PDF parser for their very complicated schedule files, not that they follow it anyway :)
MasterSegment is the length of the string at the end of the encrypted data that contains the secret key
To decrypt - we do the following
1. Take masterSegment (88) length - from the right of the data - this has the private key
2. Everything from 0 to the end - master segment is the raw data - that needs to be decrypted
3. Decrypt the 88 characters using the public key - that will give you a pipe separated string of the private key (random guid from MDS) and a time stamp (to scramble it)
4. Now use the private key and decrypt the data stored from step 2.
5. Parse the decrypted data - and rejoice
6. KSUE -means key issue
7. __$$_jmd - the public key that we obtain
__$_s1 : variable name for the Security object in the Helper.js file - that file has the calls to actually decrypt the data. // cw: FORCE the bloody stations to show at the initial zoom level. If this is not done, there is
// a possibility that stations will not show in the initial map load.
// I crib this shamelessly from SO...because it is so useful!!
// http://stackoverflow.com/questions/3125065/how-do-i-limit-panning-in-google-maps-api-v3
/*
__$$_jmd - public key
masterSegment - length of data to be extracted from the encrypted response - 55 is just a fake
//FAKE VARIABLES to throw off people hahahahaha
__$_s - salt value
__$_v - iv vale
*/This code is hilarious.
> /MasterZoom is the sum of the zoom levels from the routes_list.json file. That is the index in the routesList.v.json -> arr array where we have the public key stored. IF THE ROUTES_LIST CHANGES, REMEMBER TO CHANGE THE INDEX TO BE CORRECT /
> /Salt Value - the element is at the 8th position. So we can essentially pick any number from 0-100 (length of the s array in the file), get the length of the element, and then go to that index the following funky looking code will evaluate to 8. Salt has a length of 8 /
> /Initialization Vector Value - the element is at the 32th position. So we can essentially pick any number from 0-100 (length of the IV array in the file), get the length of the element, and then go to that index the following funky looking code will evaluate to 32 - IV has a length of 32 /
And my favorite:
> masterSegment - length of data to be extracted from the encrypted response - 55 is just a fake //FAKE VARIABLES to throw off people hahahahaha
Open https://www.amtrak.com/services/maps.trainlocation.html with a headless Chrome instance and get all of the data from the global `resolver` JS variable (see: `resolver.routes`, `resolver.trains`, etc.)
$.get(_$_sal_5,{ }) .done(function(d){ var x12 = d.trim(); console.log(JSON.parse(__$_s1._$_dcrt(x12.substring(0,x12.length-masterSegment),__$_s1._$_dcrt(x12.substr(x12.length - masterSegment),__$$_jmd).split('|')[masterSegment-88])) )})
I'm sure someone else can take thus further, but, its a mess of javascript. I think its hand-rolled encryption too from a cursory look at the __$_s1._$_dcrt function
I no longer am in a situation where I need tracking, but a couple of years ago I had the need for tracking my daily commuter train. I had to resort to scraping the website to find the status. If it was late, I had a push notification sent to my phone (a combination of a free app engine deployment and pushbullet). I tried to get integration via Tasker to set my alarm back if the train was more than [x] minutes, but never got to that point.
I really hope that you make some progress on this, though I wish you didn't have to and Amtrak shared the data.
[0]: https://github.com/bianjiang/crypto-js-npm/blob/1762940b9eef... [1]: https://maps.amtrak.com/rttl/js/AS.js
Its sad I have to do that. Amtrak should have that system already (they sort of do- but only for trains that are 20 minutes late).
For comparison, here's Germany's:
http://www.apps-bahn.de/bin/livemap/query-livemap.exe/dn?L=v...
(might need to zoom in to see more trains)
Which has >50M people, 2/3 of the population of Germany. In that comparison, that region should have then 2/3 of the rail network of Germany. It has 1 medium-speed rail line.
> while the Amtrak map is just inter-city
The Capitol Corridor, for example, is comparable to a Regio train in Germany (but slower, shittier, etc.).
As for the NEC, it suffers from being a very early build. With the exception of the Penn Station approaches, the line is 4-tracked all the way through the NJ-CT corridor. Despite being 4-tracked, the capacity is still insufficient in places. Furthermore, the line in CT in particular is a fairly curvy line that prevents building up high-speed. So getting higher speed trains really requires building new track, a lot of it in topographically interesting locations and in high-priced real estate locations.
On top of that, there's quite a few tunnels and bridges whose condition is best described not as "past its expected lifespan" but rather as "this should have failed already." So improvements on the order of billions of dollars, basically. It doesn't help that Amtrak appears to have decided that money will never be forthcoming, so all of its plans get scope-creeped to massive pie-in-the-sky boondoggles rather than trying to find smaller chunks that can make immediate improvements for relatively cheap. That's why there's a $150 billion plan to get 3-hr Boston-NYC-DC super-express service involving virgin track the entire length of the corridor and brand new stations (requiring extensive tunneling in downtown cores!) in Philly and Baltimore, or why Amtrak insists on building an entire new station annex in NYC when asking for just two new tubes under the Hudson.
What the U.S. also has is 275 million other people who (1) won't benefit from such a rail network; and (2) won't vote to fund it; (3) will condition any support of Amtrak on useless long-distance routes through low-density regions that sap money away from the only corridor in the U.S. where rail makes sense. And it's a completely rational decision for those people.
The other major issue with mass transit is the longer you wait to build the infrastructure, the cost per foot of track continues to go up. Seattle has a long history with light rail cost overruns.
That said, the website for buying tickets was atrociously bad. We had a group of six and the website was full of bugs and broken for tickets with more than five people. You essentially have to do one ticket with 5 and one with 1.
We even went to the gate agent for help and they had similar problems.
No excuses.
We have more people stretched out over more land with more varying regions with more varying needs and costs with more conservative social, political and economic values. Nearly all of our trade involves trucking and cargo ships, with freight making up the raw material shipping that isn't time sensitive.
It makes no financial sense whatsoever to fund railroads. We have extensive interstate highways and most of our people have cars. Why pay for a railroad the size of Europe when you don't have to go all over Europe, and all your needs are met via the existing shipping mechanisms? What would be the point?
If you took our cars away, maybe it would make sense, maybe. But before we pay for railroads we might need to pay for our health care or education.
I agree that long distance passenger rail mostly doesn't make a lot of financial sense.
Even today, most passengers on Amtrak are NOT riding end-to-end. They are riding between Utah and Nebraska; Or between South Carolina and Vermont; Or Boston to Connecticut.
On the California Zephyr - a coach seat is sold 2-3x times for different segments of the same journey.
There are more people in Europe, there is more land in Europe, etc. Stop with the fake excuses.
Europeans enjoy all of it: cars, trains, and airplanes. The simple fact is that North America is lame and deficient in passenger rail transportation compared to Europe and East Asia, and the comparison keeps getting worse.
Anything like this for Canadian rail? Love to ride from coast to coast up north.
Specifically the part where https://amtk.carto.com/api/v1/map?stat_tag=API&config=%7B%22... is a URL-encoded request for the following encoded JSON:
https://amtk.carto.com/api/v1/map?stat_tag=API&config={
"version":"1.3.0",
"stat_tag":"API",
"layers": [{
"type":"cartodb",
"options":{
"sql": "SELECT * FROM national_route_shape_v16",
"cartocss": "#layer {line-color: #FF031D;line-width: 2;}",
"cartocss_version": "2.1.0"
}
}]
}
In case you don't see it: SELECT * FROM ...
It does seem to be going through some mangling and parsing however. Carto's website doesn't look like it's from 1994, so my guess is that Someone™ read a book on "rapid-turnaround web development" upside down a few years ago, and now the current devs have to live with some poor decisions (raw SQL as form input) for the sake of legacy compatibility.This being said, the error messages are quite fun:
> SELECT version();
{"errors":["Postgis Plugin: ERROR: column \"the_geom_webmercator\" does not exist\nLINE 1: ...ECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_...\n ^\nin executeQuery Full sql was: 'SELECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_webmercator\",1e-05),1e-05,true),5) AS geom FROM (SELECT version()) as cdbq WHERE \"the_geom_webmercator\" && ST_SetSRID('BOX3D(-20037508.3 20037508.25881302,-20037508.25881302 20037508.3)'::box3d, 3857)'\n"],"errors_with_context":[{"type":"layer","message":"Postgis Plugin: ERROR: column \"the_geom_webmercator\" does not exist\nLINE 1: ...ECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_...\n ^\nin executeQuery Full sql was: 'SELECT ST_AsTWKB(ST_Simplify(ST_RemoveRepeatedPoints(\"the_geom_webmercator\",1e-05),1e-05,true),5) AS geom FROM (SELECT version()) as cdbq WHERE \"the_geom_webmercator\" && ST_SetSRID('BOX3D(-20037508.3 20037508.25881302,-20037508.25881302 20037508.3)'::box3d, 3857)'\n","subtype":"query","layer":{"id":"layer0","index":0,"type":"mapnik"}}]}
The ">" prompt above is from this 4-second hacky script to make a shell: tput reset; while true; do read -p '> ' x; echo '{"version":"1.3.0","stat_tag":"API","layers":[{"type":"cartodb","options":{"sql":"'"$x"'","cartocss":"#layer {line-color: #FF031D;line-width: 2;}","cartocss_version":"2.1.0"}}]}' | curl "https://amtk.carto.com/api/v1/map?stat_tag=API&config=$(php -r 'print urlencode(fgets(STDIN));')"; echo; done- Empire Builder near Minneapolis: 10h late.
- Empire Builder near Kalispell: 6h late.
Passenger train service in America needs to be returned to the private sector, without any interference by Congress. [added] Or you can watch the government fuck-up and quickly cast blame on the private sector. Private passenger services would have different, satisfying contracts with the rail owners; this is what companies do in the private sector some people apparently hate so much. There was a time when privately operated railroads were reliable in this country.
Freight currently has deleterious right of way because this is what bureaucrats have agreed to. Imagine these bureaucrats did something similar on the highways you all love so much, making passenger vehicles wait on the side to let trucks move a little faster.
The private sector is the reason for these delays.
http://blog.amtrak.com/2015/02/message-amtrak-regarding-time...
I know Penn is a major bottleneck (we have Christie to thank for that after killing ARC), and there's the added problem of delays conflicting with Metro North/NJT schedules.
We need infrastructure investment in dense corridors if we're to get anywhere remotely near European or Asian standards.
[1] Deutsche Bahn is owned by the German government, but unlike Amtrak is operated as a private company.
And, when you talk about government investments into the two other modes of transportation, I presume you mean air and highways. You forgot waterways - also created/improved with government investment.
Or is Amtrak just one company, and there are other train companies offering different routes? It just seems like such a tiny number of routes (especially compared to Europe train routes)
Anyway, yes, there are no cross country passenger trains in many states, and even for the states that have them they exist as congressional pork, at this point.
It is much faster and cheaper to drive in the US (the train max speeds are slower than the highways), and slightly cheaper and vastly faster to fly.
Only in dense regions, like California and the northeast, are inter-urban trains a meaningful thing in the USA.
Freight trains, on the other hand, are a much bigger deal in the USA than in Europe.