mirror of
https://github.com/xweiba/location-spoofer.git
synced 2026-09-21 22:30:46 +08:00
fix(i18n): 完善国际化并迁移 WLOC 脚本
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
# Third-Party Notices
|
||||
|
||||
The generated proxy scripts bundle:
|
||||
|
||||
- `pako` 2.1.0, Copyright (C) 2014-2017 Vitaly Puzrin and contributors, MIT License.
|
||||
- `esbuild` is used only as a development/build dependency and is distributed under the MIT License.
|
||||
Vendored
+19
@@ -0,0 +1,19 @@
|
||||
import { build } from "esbuild";
|
||||
import { mkdir } from "node:fs/promises";
|
||||
|
||||
await mkdir(new URL("./dist/v1/", import.meta.url), { recursive: true });
|
||||
|
||||
for (const [entry, outfile] of [
|
||||
["src/response-entry.js", "dist/v1/wloc.js"],
|
||||
["src/settings-entry.js", "dist/v1/wloc-settings.js"]
|
||||
]) {
|
||||
await build({
|
||||
entryPoints: [entry],
|
||||
outfile,
|
||||
bundle: true,
|
||||
format: "iife",
|
||||
target: ["es2017"],
|
||||
minify: true,
|
||||
legalComments: "eof"
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
(()=>{var y="1.0.0";var m=["wifi","cellTower","arpc","marker","synthetic","bare","motionSimulation"],c="locationSpoofer.settings.v1";function u(){return typeof $task!="undefined"?"quantumultX":typeof $loon!="undefined"?"loon":typeof $rocket!="undefined"?"shadowrocket":typeof Egern!="undefined"?"egern":typeof $environment!="undefined"&&$environment["stash-version"]?"stash":typeof $environment!="undefined"&&$environment["surge-version"]?"surge":"unknown"}function h(e){let t=u()==="quantumultX"?$prefs.valueForKey(e):$persistentStore.read(e);if(!t)return null;try{return JSON.parse(t)}catch(n){return null}}function l(e,t){let n=t==null?"":JSON.stringify(t);return u()==="quantumultX"?$prefs.setValueForKey(n,e):$persistentStore.write(n,e)}function i(e){let t={status:200,headers:{"Content-Type":"application/json; charset=utf-8"},body:JSON.stringify(e)};u()==="quantumultX"?$done(Object.assign({},t,{status:"HTTP/1.1 200 OK"})):u()==="stash"?$done(t):$done({response:t})}function g(e){let t=e.split("?")[1]||"",n={};return t.split("&").forEach(s=>{if(!s)return;let o=s.indexOf("="),f=o<0?s:s.slice(0,o),d=o<0?"":s.slice(o+1),a=f,p=d;try{a=decodeURIComponent(f.replace(/\+/g," "))}catch($){}try{p=decodeURIComponent(d.replace(/\+/g," "))}catch($){}Object.prototype.hasOwnProperty.call(n,a)||(n[a]=p)}),n}function O(e){let t=e.split("?")[0],n=t.indexOf("://");if(n<0)return t;let s=t.indexOf("/",n+3);return s<0?"/":t.slice(s)}var b=typeof $request=="undefined"?"":$request.url||"",E=O(b),r=g(b);if(E==="/wloc-settings/version")i({success:!0,moduleVersion:y,protocolVersion:1,capabilities:m});else if(r.action==="query"){let e=h(c);i(e&&e.enabled?{success:!0,longitude:e.longitude,latitude:e.latitude,accuracy:e.accuracy,motionSimulationEnabled:e.motionSimulationEnabled===!0}:{success:!1,error:"\u65E0\u5DF2\u4FDD\u5B58\u7684\u5750\u6807"})}else if(r.action==="clear")l(c,null),i({success:!0});else{let e=Number(r.lon!=null?r.lon:r.longitude),t=Number(r.lat!=null?r.lat:r.latitude),n=Number(r.acc!=null?r.acc:r.accuracy!=null?r.accuracy:25);if(!Number.isFinite(e)||!Number.isFinite(t))i({success:!1,error:"\u7F3A\u5C11 lon/lat \u53C2\u6570"});else{let s={enabled:!0,longitude:e,latitude:t,accuracy:n,motionSimulationEnabled:r.motion==="1"},o=l(c,s);i(o?{success:!0,longitude:e,latitude:t,accuracy:n,motionSimulationEnabled:s.motionSimulationEnabled}:{success:!1,error:"\u4FDD\u5B58\u914D\u7F6E\u5931\u8D25"})}}})();
|
||||
+6
File diff suppressed because one or more lines are too long
+11
@@ -0,0 +1,11 @@
|
||||
#!name=Apple WLOC 定位修改
|
||||
#!desc=Location Spoofer 第三方代理模块
|
||||
#!author=xweiba
|
||||
#!homepage=https://github.com/xweiba/location-spoofer
|
||||
|
||||
[rewrite_local]
|
||||
^https?:\/\/(?:gs-loc(?:-cn)?\.apple\.com|gsp-ssl\.ls\.apple\.com|bluedot\.is\.autonavi\.com(?:\.gds\.alibabadns\.com)?)\/clls\/wloc url script-response-body https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js?v=1.0.7
|
||||
^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) url script-echo-response https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js?v=1.0.7
|
||||
|
||||
[mitm]
|
||||
hostname = gs-loc.apple.com, gs-loc-cn.apple.com, gsp-ssl.ls.apple.com, bluedot.is.autonavi.com, bluedot.is.autonavi.com.gds.alibabadns.com
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
#!name=Apple WLOC 定位修改
|
||||
#!desc=Location Spoofer 第三方代理模块
|
||||
#!author=xweiba
|
||||
#!homepage=https://github.com/xweiba/location-spoofer
|
||||
|
||||
[Argument]
|
||||
longitude = input, "113.94114", tag=经度(在线选点优先)
|
||||
latitude = input, "22.544577", tag=纬度(在线选点优先)
|
||||
accuracy = input, "25", tag=精度(米)
|
||||
randomRadius = input, "0", tag=扰动半径(米,0为关闭)
|
||||
logLevel = select, "info", "off", "error", "warn", "debug", "all", tag=日志级别
|
||||
|
||||
[Script]
|
||||
http-response ^https?:\/\/(?:gs-loc(?:-cn)?\.apple\.com|gsp-ssl\.ls\.apple\.com|bluedot\.is\.autonavi\.com(?:\.gds\.alibabadns\.com)?)\/clls\/wloc script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js?v=1.0.7, requires-body=true, binary-body-mode=true, timeout=30, tag=Apple WLOC, argument=[{longitude},{latitude},{accuracy},{randomRadius},{logLevel}]
|
||||
http-request ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version) script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js?v=1.0.7, timeout=10, tag=WLOC Settings
|
||||
|
||||
[MITM]
|
||||
hostname = gs-loc.apple.com, gs-loc-cn.apple.com, gsp-ssl.ls.apple.com, bluedot.is.autonavi.com, bluedot.is.autonavi.com.gds.alibabadns.com
|
||||
@@ -0,0 +1,13 @@
|
||||
#!name=Apple WLOC 定位修改
|
||||
#!desc=修改 Apple 网络定位返回坐标 (Shadowrocket 小火箭) | 快捷指令(推荐): 设置地理位置 https://www.icloud.com/shortcuts/a82717d8fdad4e6280866fcf911173f7 清理恢复位置 https://www.icloud.com/shortcuts/f42632d406504f24a2cd163af4fe012f | 选点页面: https://wloc-pages.pages.dev/
|
||||
#!author=Yu9191 Rewrite
|
||||
#!homepage=https://github.com/xweiba/location-spoofer
|
||||
#!icon=https://raw.githubusercontent.com/xweiba/location-spoofer/main/Resources/Assets.xcassets/AppIcon.appiconset/AppIcon.png
|
||||
#!category=Tools
|
||||
|
||||
[Script]
|
||||
Apple WLOC = type=http-response,pattern=^https?:\/\/(?:gs-loc(?:-cn)?\.apple\.com|gsp-ssl\.ls\.apple\.com|bluedot\.is\.autonavi\.com(?:\.gds\.alibabadns\.com)?)\/clls\/wloc,requires-body=1,binary-body-mode=1,max-size=0,timeout=30,script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js?v=1.0.7,argument=longitude=113.94114&latitude=22.544577&accuracy=25&randomRadius=0&logLevel=info
|
||||
WLOC Settings = type=http-request,pattern=^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version),requires-body=0,max-size=0,timeout=10,script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js?v=1.0.7
|
||||
|
||||
[MITM]
|
||||
hostname = %APPEND% gs-loc.apple.com, gs-loc-cn.apple.com, gsp-ssl.ls.apple.com, bluedot.is.autonavi.com, bluedot.is.autonavi.com.gds.alibabadns.com
|
||||
@@ -0,0 +1,14 @@
|
||||
#!name=Apple WLOC 定位修改
|
||||
#!desc=Location Spoofer 第三方代理模块
|
||||
#!author=xweiba
|
||||
#!homepage=https://github.com/xweiba/location-spoofer
|
||||
#!category=Tools
|
||||
#!arguments=经度:113.94114, 纬度:22.544577, 精度:25, 扰动半径:0, 日志级别:info
|
||||
#!arguments-desc=经度/纬度: 默认坐标(在线选点储存后优先)\n精度: GPS精度(米)\n扰动半径: 每次响应在目标点周围随机偏移的最大距离(米),0为关闭\n日志级别: off/error/warn/info/debug/all\n\n使用方法: 打开选点页面 -> 选位置 -> 储存到设备
|
||||
|
||||
[Script]
|
||||
Apple WLOC = type=http-response, pattern="^https?:\/\/(?:gs-loc(?:-cn)?\.apple\.com|gsp-ssl\.ls\.apple\.com|bluedot\.is\.autonavi\.com(?:\.gds\.alibabadns\.com)?)\/clls\/wloc", requires-body=1, binary-body-mode=1, max-size=0, timeout=30, script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js?v=1.0.7, argument=longitude={{{经度}}}&latitude={{{纬度}}}&accuracy={{{精度}}}&randomRadius={{{扰动半径}}}&logLevel={{{日志级别}}}
|
||||
WLOC Settings = type=http-request, pattern="^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version)", requires-body=0, max-size=0, timeout=10, script-path=https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js?v=1.0.7
|
||||
|
||||
[MITM]
|
||||
hostname = %APPEND% gs-loc.apple.com, gs-loc-cn.apple.com, gsp-ssl.ls.apple.com, bluedot.is.autonavi.com, bluedot.is.autonavi.com.gds.alibabadns.com
|
||||
@@ -0,0 +1,35 @@
|
||||
name: Apple WLOC 定位修改
|
||||
desc: Location Spoofer 第三方代理模块
|
||||
author: xweiba
|
||||
homepage: https://github.com/xweiba/location-spoofer
|
||||
category: Tools
|
||||
|
||||
http:
|
||||
mitm:
|
||||
- "gs-loc.apple.com"
|
||||
- "gs-loc-cn.apple.com"
|
||||
- "gsp-ssl.ls.apple.com"
|
||||
- "bluedot.is.autonavi.com"
|
||||
- "bluedot.is.autonavi.com.gds.alibabadns.com"
|
||||
script:
|
||||
- match: ^https?:\/\/(?:gs-loc(?:-cn)?\.apple\.com|gsp-ssl\.ls\.apple\.com|bluedot\.is\.autonavi\.com(?:\.gds\.alibabadns\.com)?)\/clls\/wloc
|
||||
name: WLOC.Location
|
||||
type: response
|
||||
require-body: true
|
||||
binary-mode: true
|
||||
max-size: 0
|
||||
timeout: 30
|
||||
argument: longitude=113.94114&latitude=22.544577&accuracy=25&randomRadius=0&logLevel=info
|
||||
- match: ^https?:\/\/gs-loc(-cn)?\.apple\.com\/wloc-settings\/(save|version)
|
||||
name: WLOC.Settings
|
||||
type: request
|
||||
require-body: false
|
||||
timeout: 10
|
||||
|
||||
script-providers:
|
||||
WLOC.Location:
|
||||
url: https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc.js?v=1.0.7
|
||||
interval: 86400
|
||||
WLOC.Settings:
|
||||
url: https://raw.githubusercontent.com/xweiba/location-spoofer/main/ThirdParty/WlocScripts/dist/v1/wloc-settings.js?v=1.0.7
|
||||
interval: 86400
|
||||
+508
@@ -0,0 +1,508 @@
|
||||
{
|
||||
"name": "@location-spoofer/wloc-scripts",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@location-spoofer/wloc-scripts",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"pako": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "0.25.8"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/aix-ppc64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/aix-ppc64/-/aix-ppc64-0.25.8.tgz",
|
||||
"integrity": "sha512-urAvrUedIqEiFR3FYSLTWQgLu5tb+m0qZw0NBEasUeo6wuqatkMDaRT+1uABiGXEu5vqgPd7FGE1BhsAIy9QVA==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"aix"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm/-/android-arm-0.25.8.tgz",
|
||||
"integrity": "sha512-RONsAvGCz5oWyePVnLdZY/HHwA++nxYWIX1atInlaW6SEkwq6XkP3+cb825EUcRs5Vss/lGh/2YxAb5xqc07Uw==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/android-arm64/-/android-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-OD3p7LYzWpLhZEyATcTSJ67qB5D+20vbtr6vHlHWSQYhKtzUYrETuWThmzFpZtFsBIxRvhO07+UgVA9m0i/O1w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/android-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/android-x64/-/android-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-yJAVPklM5+4+9dTeKwHOaA+LQkmrKFX96BM0A/2zQrbS6ENCmxc4OVoBs5dPkCCak2roAD+jKCdnmOqKszPkjA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"android"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-arm64/-/darwin-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-Jw0mxgIaYX6R8ODrdkLLPwBqHTtYHJSmzzd+QeytSugzQ0Vg4c5rDky5VgkoowbZQahCbsv1rT1KW72MPIkevw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/darwin-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/darwin-x64/-/darwin-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-Vh2gLxxHnuoQ+GjPNvDSDRpoBCUzY4Pu0kBqMBDlK4fuWbKgGtmDIeEC081xi26PPjn+1tct+Bh8FjyLlw1Zlg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-YPJ7hDQ9DnNe5vxOm6jaie9QsTwcKedPvizTVlqWG9GBSq+BuyWEDazlGaDTC5NGU4QJd666V0yqCBL2oWKPfA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/freebsd-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/freebsd-x64/-/freebsd-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-MmaEXxQRdXNFsRN/KcIimLnSJrk2r5H8v+WVafRWz5xdSVmWLoITZQXcgehI2ZE6gioE6HirAEToM/RvFBeuhw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"freebsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm/-/linux-arm-0.25.8.tgz",
|
||||
"integrity": "sha512-FuzEP9BixzZohl1kLf76KEVOsxtIBFwCaLupVuk4eFVnOZfU+Wsn+x5Ryam7nILV2pkq2TqQM9EZPsOBuMC+kg==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-arm64/-/linux-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-WIgg00ARWv/uYLU7lsuDK00d/hHSfES5BzdWAdAig1ioV5kaFNrtK8EqGcUBJhYqotlUByUKz5Qo6u8tt7iD/w==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ia32": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ia32/-/linux-ia32-0.25.8.tgz",
|
||||
"integrity": "sha512-A1D9YzRX1i+1AJZuFFUMP1E9fMaYY+GnSQil9Tlw05utlE86EKTUA7RjwHDkEitmLYiFsRd9HwKBPEftNdBfjg==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-loong64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-loong64/-/linux-loong64-0.25.8.tgz",
|
||||
"integrity": "sha512-O7k1J/dwHkY1RMVvglFHl1HzutGEFFZ3kNiDMSOyUrB7WcoHGf96Sh+64nTRT26l3GMbCW01Ekh/ThKM5iI7hQ==",
|
||||
"cpu": [
|
||||
"loong64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-mips64el": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-mips64el/-/linux-mips64el-0.25.8.tgz",
|
||||
"integrity": "sha512-uv+dqfRazte3BzfMp8PAQXmdGHQt2oC/y2ovwpTteqrMx2lwaksiFZ/bdkXJC19ttTvNXBuWH53zy/aTj1FgGw==",
|
||||
"cpu": [
|
||||
"mips64el"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-ppc64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-ppc64/-/linux-ppc64-0.25.8.tgz",
|
||||
"integrity": "sha512-GyG0KcMi1GBavP5JgAkkstMGyMholMDybAf8wF5A70CALlDM2p/f7YFE7H92eDeH/VBtFJA5MT4nRPDGg4JuzQ==",
|
||||
"cpu": [
|
||||
"ppc64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-riscv64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-riscv64/-/linux-riscv64-0.25.8.tgz",
|
||||
"integrity": "sha512-rAqDYFv3yzMrq7GIcen3XP7TUEG/4LK86LUPMIz6RT8A6pRIDn0sDcvjudVZBiiTcZCY9y2SgYX2lgK3AF+1eg==",
|
||||
"cpu": [
|
||||
"riscv64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-s390x": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-s390x/-/linux-s390x-0.25.8.tgz",
|
||||
"integrity": "sha512-Xutvh6VjlbcHpsIIbwY8GVRbwoviWT19tFhgdA7DlenLGC/mbc3lBoVb7jxj9Z+eyGqvcnSyIltYUrkKzWqSvg==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/linux-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/linux-x64/-/linux-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-ASFQhgY4ElXh3nDcOMTkQero4b1lgubskNlhIfJrsH5OKZXDpUAKBlNS0Kx81jwOBp+HCeZqmoJuihTv57/jvQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-d1KfruIeohqAi6SA+gENMuObDbEjn22olAR7egqnkCD9DGBG0wsEARotkLgXDu6c4ncgWTZJtN5vcgxzWRMzcw==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/netbsd-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/netbsd-x64/-/netbsd-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-nVDCkrvx2ua+XQNyfrujIG38+YGyuy2Ru9kKVNyh5jAys6n+l44tTtToqHjino2My8VAY6Lw9H7RI73XFi66Cg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"netbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-j8HgrDuSJFAujkivSMSfPQSAa5Fxbvk4rgNAS5i3K+r8s1X0p1uOO2Hl2xNsGFppOeHOLAVgYwDVlmxhq5h+SQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openbsd-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/openbsd-x64/-/openbsd-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-1h8MUAwa0VhNCDp6Af0HToI2TJFAn1uqT9Al6DJVzdIBAd21m/G0Yfc77KDM3uF3T/YaOgQq3qTJHPbTOInaIQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openbsd"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/openharmony-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/openharmony-arm64/-/openharmony-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-r2nVa5SIK9tSWd0kJd9HCffnDHKchTGikb//9c7HX+r+wHYCpQrSgxhlY6KWV1nFo1l4KFbsMlHk+L6fekLsUg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"openharmony"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/sunos-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/sunos-x64/-/sunos-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-zUlaP2S12YhQ2UzUfcCuMDHQFJyKABkAjvO5YSndMiIkMimPmxA+BYSBikWgsRpvyxuRnow4nS5NPnf9fpv41w==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"sunos"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-arm64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/win32-arm64/-/win32-arm64-0.25.8.tgz",
|
||||
"integrity": "sha512-YEGFFWESlPva8hGL+zvj2z/SaK+pH0SwOM0Nc/d+rVnW7GSTFlLBGzZkuSU9kFIGIo8q9X3ucpZhu8PDN5A2sQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-ia32": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/win32-ia32/-/win32-ia32-0.25.8.tgz",
|
||||
"integrity": "sha512-hiGgGC6KZ5LZz58OL/+qVVoZiuZlUYlYHNAmczOm7bs2oE1XriPFi5ZHHrS8ACpV5EjySrnoCKmcbQMN+ojnHg==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/@esbuild/win32-x64": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/@esbuild/win32-x64/-/win32-x64-0.25.8.tgz",
|
||||
"integrity": "sha512-cn3Yr7+OaaZq1c+2pe+8yxC8E144SReCQjN6/2ynubzYjvyqZjTXfQJpAcQpsdJq3My7XADANiYGHoFC69pLQw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
}
|
||||
},
|
||||
"node_modules/esbuild": {
|
||||
"version": "0.25.8",
|
||||
"resolved": "https://registry.npmmirror.com/esbuild/-/esbuild-0.25.8.tgz",
|
||||
"integrity": "sha512-vVC0USHGtMi8+R4Kz8rt6JhEWLxsv9Rnu/lGYbPR8u47B+DCBksq9JarW0zOO7bs37hyOK1l2/oqtbciutL5+Q==",
|
||||
"dev": true,
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"esbuild": "bin/esbuild"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@esbuild/aix-ppc64": "0.25.8",
|
||||
"@esbuild/android-arm": "0.25.8",
|
||||
"@esbuild/android-arm64": "0.25.8",
|
||||
"@esbuild/android-x64": "0.25.8",
|
||||
"@esbuild/darwin-arm64": "0.25.8",
|
||||
"@esbuild/darwin-x64": "0.25.8",
|
||||
"@esbuild/freebsd-arm64": "0.25.8",
|
||||
"@esbuild/freebsd-x64": "0.25.8",
|
||||
"@esbuild/linux-arm": "0.25.8",
|
||||
"@esbuild/linux-arm64": "0.25.8",
|
||||
"@esbuild/linux-ia32": "0.25.8",
|
||||
"@esbuild/linux-loong64": "0.25.8",
|
||||
"@esbuild/linux-mips64el": "0.25.8",
|
||||
"@esbuild/linux-ppc64": "0.25.8",
|
||||
"@esbuild/linux-riscv64": "0.25.8",
|
||||
"@esbuild/linux-s390x": "0.25.8",
|
||||
"@esbuild/linux-x64": "0.25.8",
|
||||
"@esbuild/netbsd-arm64": "0.25.8",
|
||||
"@esbuild/netbsd-x64": "0.25.8",
|
||||
"@esbuild/openbsd-arm64": "0.25.8",
|
||||
"@esbuild/openbsd-x64": "0.25.8",
|
||||
"@esbuild/openharmony-arm64": "0.25.8",
|
||||
"@esbuild/sunos-x64": "0.25.8",
|
||||
"@esbuild/win32-arm64": "0.25.8",
|
||||
"@esbuild/win32-ia32": "0.25.8",
|
||||
"@esbuild/win32-x64": "0.25.8"
|
||||
}
|
||||
},
|
||||
"node_modules/pako": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/pako/-/pako-2.1.0.tgz",
|
||||
"integrity": "sha512-w+eufiZ1WuJYgPXbV/PO3NCMEc3xqylkKHzp8bxp1uW4qaSNQUkwmLLEc3kKsfz8lpV1F8Ht3U1Cm+9Srog2ug==",
|
||||
"license": "(MIT AND Zlib)"
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+16
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "@location-spoofer/wloc-scripts",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "node build.mjs",
|
||||
"test": "node --test"
|
||||
},
|
||||
"dependencies": {
|
||||
"pako": "2.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"esbuild": "0.25.8"
|
||||
}
|
||||
}
|
||||
Vendored
+263
@@ -0,0 +1,263 @@
|
||||
export const MOTION_ACTIVITY_TYPE = 63;
|
||||
export const MOTION_ACTIVITY_CONFIDENCE = 467;
|
||||
export const WLOC_MARKER = Uint8Array.from([0, 0, 0, 1, 0, 0]);
|
||||
const UINT32_RANGE = 0x100000000;
|
||||
|
||||
const concat = (...parts) => {
|
||||
const length = parts.reduce((sum, part) => sum + part.length, 0);
|
||||
const out = new Uint8Array(length);
|
||||
let offset = 0;
|
||||
for (const part of parts) {
|
||||
out.set(part, offset);
|
||||
offset += part.length;
|
||||
}
|
||||
return out;
|
||||
};
|
||||
|
||||
const equal = (left, right) =>
|
||||
left.length === right.length && left.every((value, index) => value === right[index]);
|
||||
|
||||
function readVarint(data, offset) {
|
||||
let value = 0;
|
||||
let multiplier = 1;
|
||||
for (let index = 0; index < 10 && offset + index < data.length; index += 1) {
|
||||
const byte = data[offset + index];
|
||||
const chunk = byte & 0x7f;
|
||||
if (value !== null && chunk <= Math.floor((Number.MAX_SAFE_INTEGER - value) / multiplier)) {
|
||||
value += chunk * multiplier;
|
||||
} else {
|
||||
value = null;
|
||||
}
|
||||
if ((byte & 0x80) === 0) return { value, next: offset + index + 1 };
|
||||
multiplier *= 0x80;
|
||||
}
|
||||
throw new Error("invalid varint");
|
||||
}
|
||||
|
||||
function writeVarint(input) {
|
||||
const value = Math.trunc(Number(input));
|
||||
if (!Number.isSafeInteger(value)) throw new Error("varint value is not a safe integer");
|
||||
let low = value >>> 0;
|
||||
let high = Math.floor(value / UINT32_RANGE) >>> 0;
|
||||
const bytes = [];
|
||||
do {
|
||||
const byte = low & 0x7f;
|
||||
low = ((low >>> 7) | ((high & 0x7f) << 25)) >>> 0;
|
||||
high >>>= 7;
|
||||
const hasMore = high !== 0 || low !== 0;
|
||||
bytes.push(byte | (hasMore ? 0x80 : 0));
|
||||
} while (high !== 0 || low !== 0);
|
||||
return Uint8Array.from(bytes);
|
||||
}
|
||||
|
||||
const writeTag = (number, wireType) => writeVarint((number << 3) | wireType);
|
||||
|
||||
function writeLengthDelimited(number, value) {
|
||||
return concat(writeTag(number, 2), writeVarint(value.length), value);
|
||||
}
|
||||
|
||||
export function parseFields(data) {
|
||||
const fields = [];
|
||||
let offset = 0;
|
||||
while (offset < data.length) {
|
||||
const start = offset;
|
||||
const tag = readVarint(data, offset);
|
||||
offset = tag.next;
|
||||
if (!Number.isSafeInteger(tag.value)) throw new Error("protobuf tag is too large");
|
||||
const number = Math.floor(tag.value / 8);
|
||||
const wireType = tag.value & 7;
|
||||
if (number === 0) throw new Error("invalid protobuf field 0");
|
||||
let value;
|
||||
if (wireType === 0) {
|
||||
const item = readVarint(data, offset);
|
||||
value = data.slice(offset, item.next);
|
||||
offset = item.next;
|
||||
} else if (wireType === 1) {
|
||||
if (offset + 8 > data.length) throw new Error("truncated fixed64");
|
||||
value = data.slice(offset, offset + 8);
|
||||
offset += 8;
|
||||
} else if (wireType === 2) {
|
||||
const length = readVarint(data, offset);
|
||||
offset = length.next;
|
||||
const size = length.value;
|
||||
if (!Number.isSafeInteger(size) || offset + size > data.length) {
|
||||
throw new Error("truncated length-delimited field");
|
||||
}
|
||||
value = data.slice(offset, offset + size);
|
||||
offset += size;
|
||||
} else if (wireType === 5) {
|
||||
if (offset + 4 > data.length) throw new Error("truncated fixed32");
|
||||
value = data.slice(offset, offset + 4);
|
||||
offset += 4;
|
||||
} else {
|
||||
throw new Error(`unsupported wire type ${wireType}`);
|
||||
}
|
||||
fields.push({ number, wireType, value, raw: data.slice(start, offset) });
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
|
||||
function patchLocation(data, config, stats) {
|
||||
const fields = parseFields(data);
|
||||
if (!fields.some((field) => field.number === 1 && field.wireType === 0) ||
|
||||
!fields.some((field) => field.number === 2 && field.wireType === 0)) {
|
||||
return data;
|
||||
}
|
||||
let hasMotionType = false;
|
||||
let hasMotionConfidence = false;
|
||||
const parts = fields.map((field) => {
|
||||
if (field.wireType !== 0) return field.raw;
|
||||
if (field.number === 1) return concat(writeTag(1, 0), writeVarint(Math.round(config.latitude * 1e8)));
|
||||
if (field.number === 2) return concat(writeTag(2, 0), writeVarint(Math.round(config.longitude * 1e8)));
|
||||
if (field.number === 3) return concat(writeTag(3, 0), writeVarint(config.accuracy));
|
||||
if (config.motionSimulationEnabled && field.number === 11) {
|
||||
hasMotionType = true;
|
||||
return concat(writeTag(11, 0), writeVarint(MOTION_ACTIVITY_TYPE));
|
||||
}
|
||||
if (config.motionSimulationEnabled && field.number === 12) {
|
||||
hasMotionConfidence = true;
|
||||
return concat(writeTag(12, 0), writeVarint(MOTION_ACTIVITY_CONFIDENCE));
|
||||
}
|
||||
return field.raw;
|
||||
});
|
||||
if (config.motionSimulationEnabled && !hasMotionType) {
|
||||
parts.push(concat(writeTag(11, 0), writeVarint(MOTION_ACTIVITY_TYPE)));
|
||||
}
|
||||
if (config.motionSimulationEnabled && !hasMotionConfidence) {
|
||||
parts.push(concat(writeTag(12, 0), writeVarint(MOTION_ACTIVITY_CONFIDENCE)));
|
||||
}
|
||||
const out = concat(...parts);
|
||||
if (!equal(out, data)) stats.locations += 1;
|
||||
return out;
|
||||
}
|
||||
|
||||
function patchWifi(data, config, stats) {
|
||||
const fields = parseFields(data);
|
||||
const hasMac = fields.some((field) =>
|
||||
field.number === 1 && field.wireType === 2 &&
|
||||
/^[0-9a-fA-F]{1,2}(:[0-9a-fA-F]{1,2}){5}$/.test(
|
||||
Array.from(field.value, (byte) => String.fromCharCode(byte)).join("")
|
||||
)
|
||||
);
|
||||
if (!hasMac) return data;
|
||||
let changed = false;
|
||||
const parts = fields.map((field) => {
|
||||
if (field.number !== 2 || field.wireType !== 2) return field.raw;
|
||||
const value = patchLocation(field.value, config, stats);
|
||||
changed ||= !equal(value, field.value);
|
||||
return writeLengthDelimited(2, value);
|
||||
});
|
||||
if (changed) stats.wifi += 1;
|
||||
return concat(...parts);
|
||||
}
|
||||
|
||||
function patchCell(data, config, stats) {
|
||||
let changed = false;
|
||||
const parts = parseFields(data).map((field) => {
|
||||
if (field.number !== 5 || field.wireType !== 2) return field.raw;
|
||||
const value = patchLocation(field.value, config, stats);
|
||||
changed ||= !equal(value, field.value);
|
||||
return writeLengthDelimited(5, value);
|
||||
});
|
||||
if (changed) stats.cell += 1;
|
||||
return concat(...parts);
|
||||
}
|
||||
|
||||
export function patchPayload(data, config, stats = { wifi: 0, cell: 0, locations: 0 }) {
|
||||
const parts = parseFields(data).map((field) => {
|
||||
if (field.number === 2 && field.wireType === 2) {
|
||||
return writeLengthDelimited(2, patchWifi(field.value, config, stats));
|
||||
}
|
||||
if ((field.number === 22 || field.number === 24) && field.wireType === 2) {
|
||||
return writeLengthDelimited(field.number, patchCell(field.value, config, stats));
|
||||
}
|
||||
return field.raw;
|
||||
});
|
||||
return { data: concat(...parts), stats };
|
||||
}
|
||||
|
||||
const uint16 = (data, offset) => (data[offset] << 8) | data[offset + 1];
|
||||
const uint32 = (data, offset) =>
|
||||
((data[offset] * 0x1000000) + (data[offset + 1] << 16) +
|
||||
(data[offset + 2] << 8) + data[offset + 3]) >>> 0;
|
||||
const writeUint16 = (value) => Uint8Array.from([(value >>> 8) & 0xff, value & 0xff]);
|
||||
const writeUint32 = (value) => Uint8Array.from([
|
||||
(value >>> 24) & 0xff, (value >>> 16) & 0xff, (value >>> 8) & 0xff, value & 0xff
|
||||
]);
|
||||
|
||||
function findBytes(data, marker) {
|
||||
outer: for (let offset = 0; offset <= data.length - marker.length; offset += 1) {
|
||||
for (let index = 0; index < marker.length; index += 1) {
|
||||
if (data[offset + index] !== marker[index]) continue outer;
|
||||
}
|
||||
return offset;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
function patchARPC(body, config) {
|
||||
if (body.length < 2) throw new Error("short ARPC");
|
||||
let offset = 2;
|
||||
for (let index = 0; index < 3; index += 1) {
|
||||
if (offset + 2 > body.length) throw new Error("truncated ARPC string");
|
||||
offset += 2 + uint16(body, offset);
|
||||
}
|
||||
const lengthOffset = offset + 4;
|
||||
const payloadOffset = lengthOffset + 4;
|
||||
if (payloadOffset > body.length) throw new Error("truncated ARPC header");
|
||||
const length = uint32(body, lengthOffset);
|
||||
if (!length || payloadOffset + length > body.length) throw new Error("invalid ARPC length");
|
||||
const patched = patchPayload(body.slice(payloadOffset, payloadOffset + length), config);
|
||||
if (equal(patched.data, body.slice(payloadOffset, payloadOffset + length))) throw new Error("unchanged ARPC");
|
||||
return { data: concat(body.slice(0, lengthOffset), writeUint32(patched.data.length),
|
||||
patched.data, body.slice(payloadOffset + length)), stats: patched.stats };
|
||||
}
|
||||
|
||||
function patchMarker(body, config) {
|
||||
const markerOffset = findBytes(body, WLOC_MARKER);
|
||||
if (markerOffset < 0) throw new Error("marker not found");
|
||||
const lengthOffset = markerOffset + WLOC_MARKER.length;
|
||||
const payloadOffset = lengthOffset + 2;
|
||||
const length = uint16(body, lengthOffset);
|
||||
if (!length || payloadOffset + length > body.length) throw new Error("invalid marker length");
|
||||
const patched = patchPayload(body.slice(payloadOffset, payloadOffset + length), config);
|
||||
if (patched.data.length > 65535 || equal(patched.data, body.slice(payloadOffset, payloadOffset + length))) {
|
||||
throw new Error("unchanged marker");
|
||||
}
|
||||
return { data: concat(body.slice(0, lengthOffset), writeUint16(patched.data.length),
|
||||
patched.data, body.slice(payloadOffset + length)), stats: patched.stats };
|
||||
}
|
||||
|
||||
function patchSynthetic(body, offset, config) {
|
||||
if (offset + 10 > body.length) throw new Error("short frame");
|
||||
const length = uint16(body, offset + 8);
|
||||
if (!length || offset + 10 + length > body.length) throw new Error("invalid frame");
|
||||
const patched = patchPayload(body.slice(offset + 10, offset + 10 + length), config);
|
||||
if (patched.data.length > 65535 || equal(patched.data, body.slice(offset + 10, offset + 10 + length))) {
|
||||
throw new Error("unchanged frame");
|
||||
}
|
||||
return { data: concat(body.slice(0, offset + 8), writeUint16(patched.data.length),
|
||||
patched.data, body.slice(offset + 10 + length)), stats: patched.stats };
|
||||
}
|
||||
|
||||
export function patchWlocBody(body, config) {
|
||||
for (const patcher of [patchARPC, patchMarker]) {
|
||||
try { return patcher(body, config); } catch {}
|
||||
}
|
||||
const offsets = [...new Set([0, 2, 4, 6, 8, 10, 12, 14, 16,
|
||||
...Array.from({ length: Math.min(96, Math.max(0, body.length - 10)) + 1 }, (_, index) => index)])];
|
||||
for (const offset of offsets) {
|
||||
try { return patchSynthetic(body, offset, config); } catch {}
|
||||
}
|
||||
for (let offset = 0; offset <= Math.min(256, body.length); offset += 1) {
|
||||
try {
|
||||
const patched = patchPayload(body.slice(offset), config);
|
||||
if (!equal(patched.data, body.slice(offset))) {
|
||||
return { data: concat(body.slice(0, offset), patched.data), stats: patched.stats };
|
||||
}
|
||||
} catch {}
|
||||
}
|
||||
throw new Error("no patchable wloc payload found");
|
||||
}
|
||||
|
||||
export const internals = { concat, writeVarint, writeTag, writeLengthDelimited, equal };
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
import { ungzip } from "pako";
|
||||
import { patchWlocBody } from "./core.js";
|
||||
import {
|
||||
STORAGE_KEY, finishBinary, finishPassthrough, readPersistent, responseBytes
|
||||
} from "./runtime.js";
|
||||
|
||||
try {
|
||||
const settings = readPersistent(STORAGE_KEY);
|
||||
const input = responseBytes();
|
||||
if (!settings || !settings.enabled || !input.length) {
|
||||
finishPassthrough();
|
||||
} else {
|
||||
const isGzip = input.length >= 2 && input[0] === 0x1f && input[1] === 0x8b;
|
||||
const body = isGzip ? ungzip(input) : input;
|
||||
const patched = patchWlocBody(body, {
|
||||
latitude: Number(settings.latitude),
|
||||
longitude: Number(settings.longitude),
|
||||
accuracy: Number(settings.accuracy != null ? settings.accuracy : 25),
|
||||
motionSimulationEnabled: settings.motionSimulationEnabled === true
|
||||
});
|
||||
finishBinary(patched.data);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`[Location Spoofer] ${error && error.message ? error.message : error}`);
|
||||
finishPassthrough();
|
||||
}
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
export const MODULE_VERSION = "1.0.0";
|
||||
export const PROTOCOL_VERSION = 1;
|
||||
export const CAPABILITIES = [
|
||||
"wifi", "cellTower", "arpc", "marker", "synthetic", "bare", "motionSimulation"
|
||||
];
|
||||
export const STORAGE_KEY = "locationSpoofer.settings.v1";
|
||||
|
||||
export function environment() {
|
||||
if (typeof $task !== "undefined") return "quantumultX";
|
||||
if (typeof $loon !== "undefined") return "loon";
|
||||
if (typeof $rocket !== "undefined") return "shadowrocket";
|
||||
if (typeof Egern !== "undefined") return "egern";
|
||||
if (typeof $environment !== "undefined" && $environment["stash-version"]) return "stash";
|
||||
if (typeof $environment !== "undefined" && $environment["surge-version"]) return "surge";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
export function readPersistent(key) {
|
||||
const raw = environment() === "quantumultX"
|
||||
? $prefs.valueForKey(key)
|
||||
: $persistentStore.read(key);
|
||||
if (!raw) return null;
|
||||
try { return JSON.parse(raw); } catch { return null; }
|
||||
}
|
||||
|
||||
export function writePersistent(key, value) {
|
||||
const raw = value == null ? "" : JSON.stringify(value);
|
||||
return environment() === "quantumultX"
|
||||
? $prefs.setValueForKey(raw, key)
|
||||
: $persistentStore.write(raw, key);
|
||||
}
|
||||
|
||||
export function responseBytes() {
|
||||
const response = typeof $response === "undefined" ? null : $response;
|
||||
const value = response && response.bodyBytes != null ? response.bodyBytes : response && response.body;
|
||||
if (value instanceof ArrayBuffer) return new Uint8Array(value);
|
||||
if (ArrayBuffer.isView(value)) return new Uint8Array(value.buffer, value.byteOffset, value.byteLength);
|
||||
if (typeof value === "string") {
|
||||
return Uint8Array.from(value, (character) => character.charCodeAt(0) & 0xff);
|
||||
}
|
||||
return new Uint8Array();
|
||||
}
|
||||
|
||||
function cleanHeaders(headers, length) {
|
||||
const out = Object.assign({}, headers || {});
|
||||
for (const name of ["Content-Encoding", "content-encoding", "Transfer-Encoding", "transfer-encoding"]) {
|
||||
delete out[name];
|
||||
}
|
||||
out["Content-Length"] = String(length);
|
||||
return out;
|
||||
}
|
||||
|
||||
export function finishBinary(bytes) {
|
||||
const response = typeof $response === "undefined" ? {} : $response;
|
||||
const headers = cleanHeaders(response.headers, bytes.length);
|
||||
const env = environment();
|
||||
if (env === "quantumultX") {
|
||||
delete headers["Content-Length"];
|
||||
$done({ status: "HTTP/1.1 200 OK", headers, bodyBytes: bytes.buffer });
|
||||
} else if (env === "stash") {
|
||||
$done(Object.assign({}, response, { status: 200, headers, body: bytes }));
|
||||
} else {
|
||||
$done({ response: Object.assign({}, response, { status: 200, headers, body: bytes }) });
|
||||
}
|
||||
}
|
||||
|
||||
export function finishPassthrough() {
|
||||
$done({});
|
||||
}
|
||||
|
||||
export function finishJSON(value) {
|
||||
const response = {
|
||||
status: 200,
|
||||
headers: { "Content-Type": "application/json; charset=utf-8" },
|
||||
body: JSON.stringify(value)
|
||||
};
|
||||
if (environment() === "quantumultX") {
|
||||
$done(Object.assign({}, response, { status: "HTTP/1.1 200 OK" }));
|
||||
} else if (environment() === "stash") {
|
||||
$done(response);
|
||||
} else {
|
||||
$done({ response });
|
||||
}
|
||||
}
|
||||
|
||||
export function queryParameters(url) {
|
||||
const query = url.split("?")[1] || "";
|
||||
const values = {};
|
||||
query.split("&").forEach((item) => {
|
||||
if (!item) return;
|
||||
const separator = item.indexOf("=");
|
||||
const rawKey = separator < 0 ? item : item.slice(0, separator);
|
||||
const rawValue = separator < 0 ? "" : item.slice(separator + 1);
|
||||
let key = rawKey;
|
||||
let value = rawValue;
|
||||
try { key = decodeURIComponent(rawKey.replace(/\+/g, " ")); } catch {}
|
||||
try { value = decodeURIComponent(rawValue.replace(/\+/g, " ")); } catch {}
|
||||
if (!Object.prototype.hasOwnProperty.call(values, key)) values[key] = value;
|
||||
});
|
||||
return values;
|
||||
}
|
||||
|
||||
export function requestPath(url) {
|
||||
const withoutQuery = url.split("?")[0];
|
||||
const scheme = withoutQuery.indexOf("://");
|
||||
if (scheme < 0) return withoutQuery;
|
||||
const path = withoutQuery.indexOf("/", scheme + 3);
|
||||
return path < 0 ? "/" : withoutQuery.slice(path);
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
import {
|
||||
CAPABILITIES, MODULE_VERSION, PROTOCOL_VERSION, STORAGE_KEY,
|
||||
finishJSON, queryParameters, readPersistent, requestPath, writePersistent
|
||||
} from "./runtime.js";
|
||||
|
||||
const url = typeof $request === "undefined" ? "" : ($request.url || "");
|
||||
const path = requestPath(url);
|
||||
const parameters = queryParameters(url);
|
||||
|
||||
if (path === "/wloc-settings/version") {
|
||||
finishJSON({
|
||||
success: true,
|
||||
moduleVersion: MODULE_VERSION,
|
||||
protocolVersion: PROTOCOL_VERSION,
|
||||
capabilities: CAPABILITIES
|
||||
});
|
||||
} else if (parameters.action === "query") {
|
||||
const settings = readPersistent(STORAGE_KEY);
|
||||
finishJSON(settings && settings.enabled
|
||||
? { success: true, longitude: settings.longitude, latitude: settings.latitude,
|
||||
accuracy: settings.accuracy, motionSimulationEnabled: settings.motionSimulationEnabled === true }
|
||||
: { success: false, error: "无已保存的坐标" });
|
||||
} else if (parameters.action === "clear") {
|
||||
writePersistent(STORAGE_KEY, null);
|
||||
finishJSON({ success: true });
|
||||
} else {
|
||||
const longitude = Number(parameters.lon != null ? parameters.lon : parameters.longitude);
|
||||
const latitude = Number(parameters.lat != null ? parameters.lat : parameters.latitude);
|
||||
const accuracy = Number(parameters.acc != null
|
||||
? parameters.acc
|
||||
: (parameters.accuracy != null ? parameters.accuracy : 25));
|
||||
if (!Number.isFinite(longitude) || !Number.isFinite(latitude)) {
|
||||
finishJSON({ success: false, error: "缺少 lon/lat 参数" });
|
||||
} else {
|
||||
const settings = {
|
||||
enabled: true,
|
||||
longitude,
|
||||
latitude,
|
||||
accuracy,
|
||||
motionSimulationEnabled: parameters.motion === "1"
|
||||
};
|
||||
const success = writePersistent(STORAGE_KEY, settings);
|
||||
finishJSON(success
|
||||
? { success: true, longitude, latitude, accuracy,
|
||||
motionSimulationEnabled: settings.motionSimulationEnabled }
|
||||
: { success: false, error: "保存配置失败" });
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import vm from "node:vm";
|
||||
|
||||
const bundles = [
|
||||
new URL("../dist/v1/wloc.js", import.meta.url),
|
||||
new URL("../dist/v1/wloc-settings.js", import.meta.url)
|
||||
];
|
||||
|
||||
test("generated bundles avoid newer JavaScriptCore runtime requirements", async () => {
|
||||
for (const bundle of bundles) {
|
||||
const source = await readFile(bundle, "utf8");
|
||||
for (const unsupported of [
|
||||
/\bBigInt\b/,
|
||||
/\bglobalThis\b/,
|
||||
/\bURLSearchParams\b/,
|
||||
/\bObject\.fromEntries\b/,
|
||||
/\?\./,
|
||||
/\?\?/
|
||||
]) {
|
||||
assert.equal(unsupported.test(source), false, `${bundle.pathname} contains ${unsupported}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
test("settings bundle runs without modern URL and text globals", async () => {
|
||||
const source = await readFile(bundles[1], "utf8");
|
||||
let result;
|
||||
const storage = new Map();
|
||||
vm.runInNewContext(source, {
|
||||
$rocket: {},
|
||||
$request: {
|
||||
url: "https://gs-loc.apple.com/wloc-settings/save?lon=121.1&lat=31.2&acc=25"
|
||||
},
|
||||
$persistentStore: {
|
||||
read: (key) => storage.get(key) || null,
|
||||
write: (value, key) => {
|
||||
storage.set(key, value);
|
||||
return true;
|
||||
}
|
||||
},
|
||||
$done: (value) => { result = value; },
|
||||
JSON,
|
||||
Number,
|
||||
Object,
|
||||
String,
|
||||
decodeURIComponent
|
||||
});
|
||||
|
||||
assert.equal(JSON.parse(result.response.body).success, true);
|
||||
});
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
import {
|
||||
MOTION_ACTIVITY_CONFIDENCE, MOTION_ACTIVITY_TYPE, internals, parseFields, patchWlocBody
|
||||
} from "../src/core.js";
|
||||
|
||||
const { concat, writeVarint, writeTag, writeLengthDelimited } = internals;
|
||||
|
||||
function location(withMotion = false) {
|
||||
const fields = [
|
||||
concat(writeTag(1, 0), writeVarint(100)),
|
||||
concat(writeTag(2, 0), writeVarint(200)),
|
||||
concat(writeTag(3, 0), writeVarint(25))
|
||||
];
|
||||
if (withMotion) {
|
||||
fields.push(concat(writeTag(11, 0), writeVarint(7)));
|
||||
fields.push(concat(writeTag(12, 0), writeVarint(88)));
|
||||
}
|
||||
return concat(...fields);
|
||||
}
|
||||
|
||||
function wifiPayload(value = location()) {
|
||||
const device = concat(
|
||||
writeLengthDelimited(1, new TextEncoder().encode("aa:bb:cc:dd:ee:ff")),
|
||||
writeLengthDelimited(2, value)
|
||||
);
|
||||
return writeLengthDelimited(2, device);
|
||||
}
|
||||
|
||||
function frame(payload) {
|
||||
return concat(Uint8Array.from([0, 1, 0, 0, 0, 1, 0, 0]),
|
||||
Uint8Array.from([payload.length >> 8, payload.length & 0xff]), payload);
|
||||
}
|
||||
|
||||
const config = {
|
||||
latitude: 31.230416,
|
||||
longitude: 121.473701,
|
||||
accuracy: 50,
|
||||
motionSimulationEnabled: false
|
||||
};
|
||||
|
||||
test("patches synthetic Wi-Fi response", () => {
|
||||
const result = patchWlocBody(frame(wifiPayload()), config);
|
||||
assert.equal(result.stats.wifi, 1);
|
||||
assert.equal(result.stats.locations, 1);
|
||||
});
|
||||
|
||||
test("preserves motion fields while disabled", () => {
|
||||
const result = patchWlocBody(frame(wifiPayload(location(true))), config);
|
||||
const payload = result.data.slice(10);
|
||||
assert.ok(payload.includes(7));
|
||||
assert.ok(payload.includes(88));
|
||||
});
|
||||
|
||||
test("replaces motion fields while enabled", () => {
|
||||
const result = patchWlocBody(frame(wifiPayload(location(true))), {
|
||||
...config, motionSimulationEnabled: true
|
||||
});
|
||||
const root = parseFields(result.data.slice(10));
|
||||
const device = parseFields(root[0].value);
|
||||
const fields = parseFields(device.find((field) => field.number === 2).value);
|
||||
const motionType = fields.find((field) => field.number === 11);
|
||||
const motionConfidence = fields.find((field) => field.number === 12);
|
||||
assert.deepEqual(motionType.value, writeVarint(MOTION_ACTIVITY_TYPE));
|
||||
assert.deepEqual(motionConfidence.value, writeVarint(MOTION_ACTIVITY_CONFIDENCE));
|
||||
});
|
||||
|
||||
test("patches CellTower fields 22 and 24", () => {
|
||||
for (const number of [22, 24]) {
|
||||
const cell = writeLengthDelimited(5, location());
|
||||
const result = patchWlocBody(frame(writeLengthDelimited(number, cell)), config);
|
||||
assert.equal(result.stats.cell, 1);
|
||||
}
|
||||
});
|
||||
|
||||
test("encodes signed int64 coordinates without BigInt", () => {
|
||||
assert.deepEqual(
|
||||
Array.from(writeVarint(-18_000_000_000)),
|
||||
[128, 152, 247, 248, 188, 255, 255, 255, 255, 1]
|
||||
);
|
||||
assert.deepEqual(
|
||||
Array.from(writeVarint(18_000_000_000)),
|
||||
[128, 232, 136, 135, 67]
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user