Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Uncovering of an obfuscated public governmental...

U-Zyn Chua
March 18, 2016

Uncovering of an obfuscated public governmental API [FOSS Asia 2016]

About my quest to uncover an API from a government app.

The visualization is at https://uzyn.github.io/taxisg

U-Zyn Chua

March 18, 2016
Tweet

More Decks by U-Zyn Chua

Other Decks in Technology

Transcript

  1. $ cat taxi_location_service.sgc ldZ.TF bAP(\ R _('mZ2 \,%N`F aP)(F \d1.dZ

    k.2%K ^&-+F _$(9ZZ _ZF' aSZ,]d [82VZZ _SZ&M( l?P- _g' ( gB/>1F It's binary!
  2. $ hexdump taxi_location_service.sgc 0000000 0d 60 0f 1e 24 4d

    46 00 0d 5b 60 64 29 4e 3c 00 0000010 0d 5f 62 32 25 54 46 00 0d 6c 64 5a 2e 1a 0a 00 0000020 0d 62 41 50 28 5c 0a 00 0d 52 0c 32 2b 2d 64 00 0000030 0d 68 19 50 2f 0d 64 00 0d 6c 67 3c 2d 5f 50 00 0000040 0d 5e 25 3c 25 2e 46 00 0d 62 69 5a 27 41 5a 00 0000050 0d 5c 67 28 26 5a 5a 00 0d 65 39 46 32 25 32 00 0000060 0d 5e 59 1e 2c 2f 5a 00 0d 63 50 14 2a 34 1e 00 0000070 0d 6c 41 32 2d 29 14 00 0d 67 4a 3c 2c 4f 32 00 0000080 0d 6a 57 14 29 64 5a 00 0d 69 55 1e 2f 1a 5a 00 0000090 0d 5f 16 28 27 6d 0a 00 0d 6c 60 5a 2d 5a 64 00 00000a0 0d 5f 22 5a 27 60 46 00 0d 5c 2c 14 25 4e 0a 00 00000b0 0d 5f 0f 32 2b 29 46 00 0d 69 2e 14 2c 51 3c 00 00000c0 0d 5e 61 1e 25 6b 46 00 0d 5e 19 46 26 0f 28 00 00000d0 0d 61 11 50 29 11 0a 00 0d 58 3b 28 28 50 5a 00 00000e0 0d 61 63 28 29 16 64 00 0d 58 59 46 35 1f 64 00 00000f0 0d 5c 13 64 31 2e 0a 00 0d 5d 2e 32 25 4b 14 00 0000100 0d 6b 11 0a 2b 60 3c 00 0d 54 3a 14 31 2b 46 00 0000110 0d 5e 1f 1e 26 2d 0a 00 0d 62 1a 5a 29 28 5a 00 0000120 0d 6c 63 3c 2d 60 5a 00 0d 60 2b 14 28 39 5a 00 0000130 0d 5f 24 14 28 0b 50 00 0d 5f 5a 46 27 0c 50 00 0000140 0d 56 45 5a 34 62 3c 00 0d 6c 3c 50 2d 14 1e 00 0000150 0d 69 53 5a 2c 5d 64 00 0d 61 0b 28 29 0e 46 00
  3. $ hexdump taxi_location_service.sgc 0000000 0d 60 0f 1e 24 4d

    46 00 0d 5b 60 64 29 4e 3c 00 0000010 0d 5f 62 32 25 54 46 00 0d 6c 64 5a 2e 1a 0a 00 0000020 0d 62 41 50 28 5c 0a 00 0d 52 0c 32 2b 2d 64 00 0000030 0d 68 19 50 2f 0d 64 00 0d 6c 67 3c 2d 5f 50 00 0000040 0d 5e 25 3c 25 2e 46 00 0d 62 69 5a 27 41 5a 00 0000050 0d 5c 67 28 26 5a 5a 00 0d 65 39 46 32 25 32 00 0000060 0d 5e 59 1e 2c 2f 5a 00 0d 63 50 14 2a 34 1e 00 0000070 0d 6c 41 32 2d 29 14 00 0d 67 4a 3c 2c 4f 32 00 0000080 0d 6a 57 14 29 64 5a 00 0d 69 55 1e 2f 1a 5a 00 0000090 0d 5f 16 28 27 6d 0a 00 0d 6c 60 5a 2d 5a 64 00 00000a0 0d 5f 22 5a 27 60 46 00 0d 5c 2c 14 25 4e 0a 00 00000b0 0d 5f 0f 32 2b 29 46 00 0d 69 2e 14 2c 51 3c 00 00000c0 0d 5e 61 1e 25 6b 46 00 0d 5e 19 46 26 0f 28 00 00000d0 0d 61 11 50 29 11 0a 00 0d 58 3b 28 28 50 5a 00 00000e0 0d 61 63 28 29 16 64 00 0d 58 59 46 35 1f 64 00 00000f0 0d 5c 13 64 31 2e 0a 00 0d 5d 2e 32 25 4b 14 00 0000100 0d 6b 11 0a 2b 60 3c 00 0d 54 3a 14 31 2b 46 00 0000110 0d 5e 1f 1e 26 2d 0a 00 0d 62 1a 5a 29 28 5a 00 0000120 0d 6c 63 3c 2d 60 5a 00 0d 60 2b 14 28 39 5a 00 0000130 0d 5f 24 14 28 0b 50 00 0d 5f 5a 46 27 0c 50 00 0000140 0d 56 45 5a 34 62 3c 00 0d 6c 3c 50 2d 14 1e 00 0000150 0d 69 53 5a 2c 5d 64 00 0d 61 0b 28 29 0e 46 00 Ignore these. Just location number
  4. 0000000 0d 60 0f 1e 24 4d 46 00 0d

    5b 60 64 29 4e 3c 00 0000010 0d 5f 62 32 25 54 46 00 0d 6c 64 5a 2e 1a 0a 00 0000020 0d 62 41 50 28 5c 0a 00 0d 52 0c 32 2b 2d 64 00 0000030 0d 68 19 50 2f 0d 64 00 0d 6c 67 3c 2d 5f 50 00 0000040 0d 5e 25 3c 25 2e 46 00 0d 62 69 5a 27 41 5a 00 0000050 0d 5c 67 28 26 5a 5a 00 0d 65 39 46 32 25 32 00 0000060 0d 5e 59 1e 2c 2f 5a 00 0d 63 50 14 2a 34 1e 00 0000070 0d 6c 41 32 2d 29 14 00 0d 67 4a 3c 2c 4f 32 00 0000080 0d 6a 57 14 29 64 5a 00 0d 69 55 1e 2f 1a 5a 00 0000090 0d 5f 16 28 27 6d 0a 00 0d 6c 60 5a 2d 5a 64 00 00000a0 0d 5f 22 5a 27 60 46 00 0d 5c 2c 14 25 4e 0a 00 00000b0 0d 5f 0f 32 2b 29 46 00 0d 69 2e 14 2c 51 3c 00 00000c0 0d 5e 61 1e 25 6b 46 00 0d 5e 19 46 26 0f 28 00 00000d0 0d 61 11 50 29 11 0a 00 0d 58 3b 28 28 50 5a 00 00000e0 0d 61 63 28 29 16 64 00 0d 58 59 46 35 1f 64 00 00000f0 0d 5c 13 64 31 2e 0a 00 0d 5d 2e 32 25 4b 14 00 0000100 0d 6b 11 0a 2b 60 3c 00 0d 54 3a 14 31 2b 46 00 0000110 0d 5e 1f 1e 26 2d 0a 00 0d 62 1a 5a 29 28 5a 00 0000120 0d 6c 63 3c 2d 60 5a 00 0d 60 2b 14 28 39 5a 00 0000130 0d 5f 24 14 28 0b 50 00 0d 5f 5a 46 27 0c 50 00 0000140 0d 56 45 5a 34 62 3c 00 0d 6c 3c 50 2d 14 1e 00 0000150 0d 69 53 5a 2c 5d 64 00 0d 61 0b 28 29 0e 46 00 Every 8 bytes is a position (latitude longitude) of a taxi
  5. 0d 60 0f 1e 24 4d 46 00 Latitude 24

    4d 46 00 To decimal: 36 77 70 ignore Minus 10: 26 67 60 Add 1. and combine them: 1.266760
  6. 0d 60 0f 1e 24 4d 46 00 Longitude 0d

    60 0f 1e To decimal: 13 96 15 30 Minus 10: 03 86 05 20 Prefix with 1 and add decimal after the first byte 103.860520
  7. Singapore taxi surcharge 6am – 9:30am 25% (rush hours)
 6pm

    – midnight 25% (rush hours)
 midnight – 6am 50% (graveyard hours incentive)
  8. Observations 6am - 9am Morning lowest points
 9am - 2pm

    Rising steadily and stay high 5pm-6pm Lowest points of day
 midnight Peak
 midnight - 6am Declining, but among the highest points
  9. Fun random hotspot observations • Airport is always packed •

    Singapore Zoo (Night Safari) closes at midnight • Graveyard hours (midnight to 5am) popular hotspots:
 - Geylang
 - Jalan Besar • Utac Plant 2, AMK Street 63 is always packed. Why!??! • Play around with it, maybe you can discover something interesting.
  10. Serverless • AWS Lambda • Direct parsing of LTA's obfuscated

    API is also available: • Served via Amazon API Gateway • Added CORS header and returns JSON • Taxi stands
 GET https://di5wn01bz2.execute-api.us-west-2.amazonaws.com/alpha/stands • Taxi locations
 GET https://di5wn01bz2.execute-api.us-west-2.amazonaws.com/alpha/taxis • Data collector is triggered every 30 seconds. • Lambda only supports time-based event every minute, so I had to use another server that fires and event every 30 seconds in order to trigger Lambda to collect data every 30 seconds.
  11. Visualization • Viewer is a single-page app. • Connects directly

    to DynamoDB with read-only access. • All parsing and analysis is done client-side at the browser.