Created
June 20, 2023 12:21
-
-
Save Nerahikada/3fd3dfcefbb20718ba48eeb8c39c564f to your computer and use it in GitHub Desktop.
Geolocation API Spoofer
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=navigator.geolocation,b=()=>Math.random()*2147483647,c=null,a&&(a.getCurrentPosition=(d,e)=>{confirm(`Do you want to allow ${location.hostname} to access your location?`)?d({coords:{latitude:b(),longitude:b(),altitude:c,accuracy:b(),altitudeAccuracy:c,heading:c,speed:c},timestamp:Date.now()}):e({code:1,message:"User denied geolocation prompt"})}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (navigator.geolocation) { | |
navigator.geolocation.__proto__.getCurrentPosition = (success: Function, error: Function) => { | |
if (confirm(`Do you want to allow ${location.hostname} to access your location?`)) { | |
success(new class{ | |
/** | |
* GeolocationPosition class | |
* @link https://developer.mozilla.org/docs/Web/API/GeolocationPosition | |
*/ | |
public readonly coords = new class{ | |
/** | |
* GeolocationCoordinates class | |
* @link https://developer.mozilla.org/ja/docs/Web/API/GeolocationCoordinates | |
*/ | |
public readonly latitude: number = Math.random() * 2147483647; | |
public readonly longitude: number = Math.random() * 2147483647; | |
public readonly altitude: number|null = null; | |
public readonly accuracy: number = Math.random() * 2147483647; | |
public readonly altitudeAccuracy: number|null = null; | |
public readonly heading: number|null = null; | |
public readonly speed: number|null = null; | |
}; | |
public readonly timestamp: number = Date.now(); | |
}); | |
}else{ | |
error(new class extends Error{ | |
/** | |
* GeolocationPositionError class | |
* @link https://developer.mozilla.org/docs/Web/API/GeolocationPositionError | |
*/ | |
public readonly code: 1|2|3 = 1; | |
public readonly message: string = "User denied geolocation prompt"; | |
}); | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment