├── jest.config.js ├── src ├── index.js ├── config │ └── index.js └── services │ ├── uberPostData.js │ ├── uberService.js │ └── __tests__ │ └── uberService.test.js ├── .env.sample ├── babel.config.js ├── package.json ├── README.md └── .gitignore /jest.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | verbose: true, 3 | }; 4 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | const uber = require("./services/uberService"); 2 | 3 | console.log(uber) 4 | 5 | module.exports = uber 6 | -------------------------------------------------------------------------------- /.env.sample: -------------------------------------------------------------------------------- 1 | # enviroment vars sample, please rename to .env and set the fields below 2 | UBER_COOKIE_SID= 3 | UBER_COOKIE_CSID= 4 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | [ 4 | "@babel/preset-env", 5 | { 6 | targets: { 7 | node: "current" 8 | } 9 | } 10 | ] 11 | ] 12 | }; 13 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ubering", 3 | "version": "0.0.5", 4 | "description": "Uber browser api reverse engineered ", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/tamnil/ubering.git" 8 | }, 9 | "bugs": { 10 | "url": "https://github.com/tamnil/ubering/issues" 11 | }, 12 | "main": "src/index.js", 13 | "scripts": { 14 | "test": "jest", 15 | "test-watch": "jest --watch" 16 | }, 17 | "keywords": [ 18 | "ubering", 19 | "uber", 20 | "browser", 21 | "hack", 22 | "api" 23 | ], 24 | "author": "Tamnil Saito Junior", 25 | "license": "MIT", 26 | "dependencies": { 27 | "axios": "^0.19.0", 28 | "dotenv": "^8.2.0" 29 | }, 30 | "devDependencies": { 31 | "@babel/core": "^7.7.7", 32 | "@babel/preset-env": "^7.7.7", 33 | "babel-jest": "^24.9.0", 34 | "jest": "^24.9.0" 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/config/index.js: -------------------------------------------------------------------------------- 1 | require("dotenv").config(); 2 | 3 | const env = process.env, 4 | sid = env.UBER_COOKIE_SID, 5 | csid = env.UBER_COOKIE_CSID; 6 | /* 7 | * test if csid and csid are defined 8 | */ 9 | 10 | if (sid === undefined || csid === undefined) { 11 | console.log( 12 | "ERROR: UBERING", 13 | "csid or sid in note defined in enviroment variables or .env file" 14 | ); 15 | } 16 | 17 | const cookie = `sid=${sid};csid=${csid}`, 18 | uberUrl = "https://m.uber.com", 19 | toExport = { 20 | sid, 21 | csid, 22 | uberUrl, 23 | headers: { 24 | authority: "m.uber.com", 25 | origin: uberUrl, 26 | 27 | "user-agent": 28 | "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36", 29 | dnt: "1", 30 | "content-type": "application/json", 31 | accept: "*/*", 32 | "sec-fetch-site": "same-origin", 33 | "sec-fetch-mode": "cors", 34 | "accept-encoding": "gzip, deflate, br", 35 | "accept-language": "en-US,en;q=0.9,pt;q=0.8", 36 | "x-csrf-token": "x", 37 | cookie: cookie 38 | } 39 | }; 40 | 41 | module.exports = toExport; 42 | -------------------------------------------------------------------------------- /src/services/uberPostData.js: -------------------------------------------------------------------------------- 1 | // 2 | // post data to get rates 3 | // based on request in 02-01-2019 4 | // 5 | 6 | const config = require("../config"), 7 | url = { 8 | getFareEstimates: `${config.uberUrl}/api/getFareEstimates`, 9 | locationAutocomplete: `${config.uberUrl}/api/locationAutocomplete`, 10 | getLocationDetails: `${config.uberUrl}/api/getLocationDetails`, 11 | getStatus: `${config.uberUrl}/api/getStatus`, 12 | getAppData: `${config.uberUrl}/api/getAppData`, 13 | getNavigation: `${config.uberUrl}/api/getNavigation` 14 | }, 15 | locale = "en-us", 16 | defaultData = { 17 | cookies: { 18 | sid: config.sid, 19 | csid: config.csid 20 | } 21 | }; 22 | 23 | const getFareEstimates = (origin, dest) => ({ 24 | defaultData, 25 | url: url.getFareEstimates, 26 | 27 | data: { 28 | locale, 29 | pickupLocation: { 30 | latitude: origin[0], 31 | longitude: origin[1] 32 | }, 33 | destination: { 34 | latitude: dest[0], 35 | longitude: dest[1] 36 | } 37 | } 38 | }); 39 | 40 | const locationAutocomplete = location => ({ 41 | // defaultData, 42 | url: url.locationAutocomplete, 43 | data: { 44 | locale, 45 | query: location 46 | } 47 | }); 48 | 49 | const getLocationDetails = (id, provider = "google_places") => ({ 50 | // defaultData, 51 | url: url.getLocationDetails, 52 | data: { 53 | locale, 54 | id, 55 | provider 56 | } 57 | }); 58 | 59 | const getStatus = (uuid="", latitude = 0, longitude = 0) => ({ 60 | defaultData, 61 | url: url.getStatus, 62 | data: { 63 | uuid, 64 | latitude, 65 | longitude 66 | } 67 | }); 68 | const getAppData = () => ({ 69 | defaultData, 70 | url: url.getAppData, 71 | data: {} 72 | }); 73 | 74 | const getNavigation = (pickupLocation, destination) => ({ 75 | defaultData, 76 | url: url.getNavigation, 77 | data: { 78 | pickupLocation, 79 | destination 80 | } 81 | }); 82 | module.exports = { 83 | getFareEstimates, 84 | locationAutocomplete, 85 | getLocationDetails, 86 | getStatus, 87 | getAppData, 88 | getNavigation 89 | }; 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ubering ( Uber Hack ) - bowser and mobile api reverse engineered 2 | 3 | Uber's browser API endpoints HACK - reverse engineered Uber API endpoints and usefull commands 4 | 5 | - Uses browser credentials (No needs to register in the uber's developer portal!!!) 6 | 7 | Tamnil Saito Junior 8 | 9 | ### WARNING!!!: Misuse can leak your personal data and some bad behaviors in UBER's app 10 | 11 | #### Novices please keep out!!! 12 | 13 | This is a reverse engineered endpoint's hack and it's not based on oficial api!!! 14 | Can be deprecated or blocked by UBER without advice 15 | 16 | ## Description 17 | based on browser's API endpoint behavior to get info about uber locations and taxes. 18 | 19 | 20 | ### Available Functions: 21 | 22 | - getFareEstimates(origin, destination) 23 | - locationAutocomplete(location) 24 | - getLocationDetails(locationId,provider="google_maps") 25 | - getStatus( , [uuid,latitude=0,longitude=0]) 26 | - getAppData() 27 | - getNavigation(pickupLocation,destination) 28 | 29 | 30 | #### secondary functions 31 | 32 | - getUUID() 33 | 34 | 35 | 36 | ## Install 37 | - instal as dependency: "npm install ubering" or clone from https://github.com/tamnil/ubering 38 | - copy .env.sample to .env or set environment variables: 39 | 40 | 41 | ``` 42 | .env file: 43 | 44 | UBER_COOKIE_SID= 45 | UBER_COOKIE_CSID= 46 | 47 | *nix enviroment vars: 48 | 49 | export UBER_COOKIE_SID= 50 | export UBER_COOKIE_CSID= 51 | 52 | 53 | ``` 54 | 55 | windows : https://superuser.com/questions/949560/how-do-i-set-system-environment-variables-in-windows-10 56 | 57 | 58 | ### How to get these values ( CSID, SID ): 59 | log into uber (https://www.uber.com/) and open devTools 60 | you can get the sid and csid in application->cookie tab or typing "document.cookie" in console tab 61 | 62 | 63 | ### Tests 64 | - clone repository from github https://github.com/tamnil/ubering 65 | - install and set up "sid" and "csid" enviroment variables 66 | - run npm install 67 | - run "jest" or "npm test" 68 | 69 | 70 | ## Notes: 71 | 72 | You may have some CORS issues. 73 | 74 | ### some sketeches for dev propouses 75 | 76 | 77 | 78 | ## Copyright 79 | 80 | ### Again! this can lead to data leakages and other unwanted behaviors 81 | 82 | #### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 83 | -------------------------------------------------------------------------------- /src/services/uberService.js: -------------------------------------------------------------------------------- 1 | const axios = require("axios"); 2 | const postData = require("./uberPostData"); 3 | const config = require("../config"); 4 | 5 | const prepareAxiosRequest = prepare => 6 | axios( 7 | { 8 | method: "post", 9 | url: prepare.url, 10 | data: prepare.data, 11 | headers: config.headers 12 | }, 13 | prepare 14 | ).then(res => res.data); 15 | 16 | /** 17 | * getFareEstimates 18 | * 19 | * gets Data from uber for ride 20 | * 21 | * @name getFareEstimates 22 | * @function 23 | * @param [lat,lon] origin 24 | * @param [lat,lon] dest 25 | */ 26 | 27 | const getFareEstimates = (origin, dest) => 28 | prepareAxiosRequest(postData.getFareEstimates(origin, dest)); 29 | 30 | const locationAutocomplete = location => 31 | prepareAxiosRequest(postData.locationAutocomplete(location)); 32 | 33 | const getLocationDetails = location => 34 | prepareAxiosRequest(postData.getLocationDetails(location)); 35 | 36 | const getAppData = () => prepareAxiosRequest(postData.getAppData()); 37 | 38 | const getStatus = () => prepareAxiosRequest(postData.getStatus()); 39 | 40 | // pickuplocation, destination = {latitude,longitude} 41 | const getNavigation = (pickupLocation, destination) => 42 | prepareAxiosRequest(postData.getNavigation(pickupLocation, destination)); 43 | 44 | /* 45 | * secondary functions 46 | * 47 | */ 48 | 49 | const getUuid = async () => { 50 | const appData = await getAppData(); 51 | return appData.data.appData.client.uuid; 52 | }; 53 | 54 | const getLocations = async location => 55 | await locationAutocomplete(location).then(res => res.data.locations); 56 | const getFirstLocation = getLocations[0]; 57 | // const getFirstLocationId = getLocations[0]; 58 | 59 | 60 | // const getPriceByNames =() => { 61 | // const origin = 62 | // const fareEstimates = await getFareEstimates(origin,dest) 63 | // } 64 | 65 | const exportedModules = { 66 | getFareEstimates, 67 | getStatus, 68 | locationAutocomplete, 69 | getLocationDetails, 70 | getAppData, 71 | getNavigation, 72 | //secondary functions 73 | getUuid, 74 | getLocations, 75 | getFirstLocation, 76 | // getFirstLocationId 77 | }; 78 | 79 | /* 80 | * footnotes: 81 | https://m.uber.com/api/locationAutocomplete 82 | 83 | https://m.uber.com/api/getLocationDetails 84 | {"id":"xxxxxxxx5x3xxxxxxxx4xxx65xx","addressLine1":"Campinas","addressLine2":"State of São Paulo, Brazil","provider":"google_places","locale":"en-US"} 85 | 86 | 87 | https://m.uber.com/api/getNavigation 88 | 89 | query: "campinas" 90 | locale: "en-US" 91 | 92 | https://m.uber.com/api/getStatus 93 | 94 | uuid: "111d1111-1df1-11f1-b111-b111b111aeeb" 95 | latitude: 0 96 | longitude: 0 97 | */ 98 | 99 | module.exports = exportedModules; 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | # Created by https://www.gitignore.io/api/node,jest,react,webpack,babel 3 | # Edit at https://www.gitignore.io/?templates=node,jest,react,webpack,babel 4 | 5 | #!! ERROR: babel is undefined. Use list command to see defined gitignore types !!# 6 | 7 | #!! ERROR: jest is undefined. Use list command to see defined gitignore types !!# 8 | tags 9 | 10 | ### Node ### 11 | # Logs 12 | logs 13 | *.log 14 | npm-debug.log* 15 | yarn-debug.log* 16 | yarn-error.log* 17 | lerna-debug.log* 18 | 19 | # Diagnostic reports (https://nodejs.org/api/report.html) 20 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 21 | 22 | # Runtime data 23 | pids 24 | *.pid 25 | *.seed 26 | *.pid.lock 27 | 28 | # Directory for instrumented libs generated by jscoverage/JSCover 29 | lib-cov 30 | 31 | # Coverage directory used by tools like istanbul 32 | coverage 33 | *.lcov 34 | 35 | # nyc test coverage 36 | .nyc_output 37 | 38 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 39 | .grunt 40 | 41 | # Bower dependency directory (https://bower.io/) 42 | bower_components 43 | 44 | # node-waf configuration 45 | .lock-wscript 46 | 47 | # Compiled binary addons (https://nodejs.org/api/addons.html) 48 | build/Release 49 | 50 | # Dependency directories 51 | node_modules/ 52 | jspm_packages/ 53 | 54 | # TypeScript v1 declaration files 55 | typings/ 56 | 57 | # TypeScript cache 58 | *.tsbuildinfo 59 | 60 | # Optional npm cache directory 61 | .npm 62 | 63 | # Optional eslint cache 64 | .eslintcache 65 | 66 | # Optional REPL history 67 | .node_repl_history 68 | 69 | # Output of 'npm pack' 70 | *.tgz 71 | 72 | # Yarn Integrity file 73 | .yarn-integrity 74 | 75 | # dotenv environment variables file 76 | .env 77 | .env.test 78 | 79 | # parcel-bundler cache (https://parceljs.org/) 80 | .cache 81 | 82 | # next.js build output 83 | .next 84 | 85 | # nuxt.js build output 86 | .nuxt 87 | 88 | # rollup.js default build output 89 | dist/ 90 | 91 | # Uncomment the public line if your project uses Gatsby 92 | # https://nextjs.org/blog/next-9-1#public-directory-support 93 | # https://create-react-app.dev/docs/using-the-public-folder/#docsNav 94 | # public 95 | 96 | # Storybook build outputs 97 | .out 98 | .storybook-out 99 | 100 | # vuepress build output 101 | .vuepress/dist 102 | 103 | # Serverless directories 104 | .serverless/ 105 | 106 | # FuseBox cache 107 | .fusebox/ 108 | 109 | # DynamoDB Local files 110 | .dynamodb/ 111 | 112 | # Temporary folders 113 | tmp/ 114 | temp/ 115 | 116 | ### react ### 117 | .DS_* 118 | **/*.backup.* 119 | **/*.back.* 120 | 121 | node_modules 122 | 123 | *.sublime* 124 | 125 | psd 126 | thumb 127 | sketch 128 | 129 | #!! ERROR: webpack is undefined. Use list command to see defined gitignore types !!# 130 | 131 | # End of https://www.gitignore.io/api/node,jest,react,webpack,babel 132 | -------------------------------------------------------------------------------- /src/services/__tests__/uberService.test.js: -------------------------------------------------------------------------------- 1 | const app = require("../uberService"); 2 | 3 | const timeout = 5e4; 4 | jest.setTimeout(timeout); 5 | 6 | describe("Main endpoints", () => { 7 | describe("test getFareEstimates", () => { 8 | const origin = [-22.8745132, -47.0494196], 9 | dest = [-22.9088671, -47.0553481]; 10 | 11 | beforeAll(() => {}); 12 | it("should connect to uber", async () => { 13 | let a = await app.getFareEstimates(origin, dest); 14 | expect(a.status).toBe("success"); 15 | }); 16 | }); 17 | 18 | describe("test locationAutocomplete", () => { 19 | let myOrigin, locationsResponse, firstLocationElement; 20 | const myCity = "campinas"; 21 | 22 | beforeAll(async () => { 23 | myOrigin = await app.locationAutocomplete(myCity); 24 | locationsResponse = myOrigin.data.locations.locations; 25 | firstLocationElement = locationsResponse[0].location; 26 | }); 27 | it("should get location Campinas", () => { 28 | expect(typeof locationsResponse).toBe("object"); 29 | expect(firstLocationElement.addressLine1).toBe("Campinas"); 30 | expect(firstLocationElement.id).toBe("ChIJJWNL5x3GyJQRKsJ4IWo65Rc"); 31 | }); 32 | }); 33 | 34 | describe("test getLocationDetails", () => { 35 | const locationId = "ChIJJWNL5x3GyJQRKsJ4IWo65Rc"; 36 | let myLocationDetails; 37 | 38 | beforeAll(async () => { 39 | myLocationDetails = await app.getLocationDetails( 40 | locationId, 41 | "Campinas", 42 | "State of São Paulo, Brazil" 43 | ); 44 | }); 45 | it("should get location Details Campinas", () => {}); 46 | }); 47 | 48 | describe("test getAppdData ", () => { 49 | let appData; 50 | 51 | beforeAll(async () => { 52 | appData = await app.getAppData(); 53 | }); 54 | it("should get App Data", () => {}); 55 | }); 56 | 57 | describe("test getStatus ", () => { 58 | let status; 59 | 60 | beforeAll(async () => { 61 | status = await app.getStatus(); 62 | }); 63 | it("should get status", () => {}); 64 | }); 65 | }); 66 | describe("Secondary functions", () => { 67 | describe("test getUUID ", () => { 68 | let uuid; 69 | 70 | beforeAll(async () => { 71 | uuid = await app.getUuid(); 72 | }); 73 | it("uuid shoud have length= 36", () => { 74 | expect(uuid.length).toBe(36); 75 | }); 76 | }); 77 | describe("location id", () => { 78 | let location; 79 | 80 | beforeAll(async () => { 81 | location = await app.getLocations("paulinia"); 82 | }); 83 | 84 | it("get the location id", () => { 85 | console.log(location); 86 | }); 87 | }); 88 | }); 89 | describe("******** WARZONE !!! - development area", () => { 90 | describe("get Lat,lon from locationa name - first choice -select", () => { 91 | let locationOrigin, 92 | locationDestination, 93 | locationOriginDetails, 94 | locationDestinationDetails, 95 | locationOriginId, 96 | locationDestinationId, 97 | locationOriginCoordinates, 98 | locationDestinationCoordinates; 99 | 100 | beforeAll(async () => { 101 | locationOrigin = await app.locationAutocomplete("sao paulo"); 102 | locationDestination = await app.locationAutocomplete("campinas"); 103 | locationOriginId = locationOrigin.data.locations.locations[0].location.id; 104 | locationDestinationId = 105 | locationDestination.data.locations.locations[0].location.id; 106 | 107 | locationOriginDetails = await app.getLocationDetails(locationOriginId); 108 | locationDestinationDetails = await app.getLocationDetails( 109 | locationDestinationId 110 | ); 111 | locationOriginCoordinates = locationOriginDetails.data.coordinate; 112 | locationDestinationCoordinates = 113 | locationDestinationDetails.data.coordinate; 114 | 115 | console.log(locationOriginCoordinates, locationDestinationCoordinates); 116 | // locationdetails = await app.getLocationDetails(); 117 | }); 118 | it("", () => { 119 | // expect(uuid.length).toBe(36); 120 | }); 121 | }); 122 | }); 123 | // describe("") 124 | --------------------------------------------------------------------------------