Skip to content

Instantly share code, notes, and snippets.

@zoutepopcorn
Last active December 17, 2017 20:10
Show Gist options
  • Save zoutepopcorn/644e6d44f8b6c3b685b8399639474c66 to your computer and use it in GitHub Desktop.
Save zoutepopcorn/644e6d44f8b6c3b685b8399639474c66 to your computer and use it in GitHub Desktop.
Location

node index.js [mac]

syntax="proto3";
message Response {
message ResponseWifi {
message WifiLocation {
int64 latitude = 1;
int64 longitude = 2;
int32 accuracy = 3;
int32 zeroField4 = 4; // always 0 - don't ask why
int32 altitude = 5; // -500 if unknown
int32 altitudeAccuracy = 6; // Not set if altitude=-500
int32 unknown11 = 11; // 5..63 ?
int32 unknown12 = 12; // 30..4000 ?
}
string mac = 1;
WifiLocation location = 2;
int32 channel = 21;
}
repeated ResponseWifi wifis = 2;
}
const request = require('request');
const fs = require('fs');
const prot = require("protobufjs");
const URL = "https://gs-loc.apple.com/clls/wloc";
const MAC = process.argv[2] || "84:c9:b2:5e:ed:34";
const ALL = `en_UScom.apple.locationd 8.4.1.12H321
${MAC} d`;
const HEAD = {
'Accept': '*/*',
'Accept-Encoding': 'gzip, deflate',
'Content-Type': 'application/x-www-form-urlencoded',
'User-Agent': 'locationd/1861.0.23 CFNetwork/758.2.8 Darwin/15.0.0',
'Accept-Language': 'en-us',
};
const reqUrl = () => {
// Set options and post request
const options = {
url: URL,
method: 'POST',
encoding: null,
headers: HEAD,
form: ALL
}
// Start the request
request(options, (error, response, body) => {
if (!error && response.statusCode == 200) {
console.log("----------------");
const buffer = body.slice(10);
prot.load("apple.proto", (err, root) => {
const Res = root.lookupType("Response");
const msg = Res.decode(buffer).toJSON();
msg.wifis.forEach(item => console.log(item));
});
console.log("----------------");
}
})
}
reqUrl();
// Test to get wigle info
const request = require('request');
const test = () => {
return 'https://api.wigle.net/api/v2/profile/user';
}
const square = (lat, lng) => {
return `https://api.wigle.net/api/v2/network/search?onlymine=false&latrange1=${lat}&latrange2=${lat+0.1}&longrange1=${lng}&longrange2=${lng+0.1}&freenet=false&paynet=false`;
}
console.log(square(52.1, 5.1));
// test url if loged in
// https://wigle.net/account
// > show token
// user -> API Name:
// pass -> API Token:
const options = {
url: square(52.1, 5.1),
headers: {
'Accept': 'application/json'
},
auth: {
'user': '',
'pass': ''
}
};
callback = (error, response, body) => {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
request(options, callback);
@zoutepopcorn
Copy link
Author

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment