Skip to content

Instantly share code, notes, and snippets.

@SmokeNMirrors
Forked from udnaan/decode.js
Created December 4, 2018 04:13
Show Gist options
  • Save SmokeNMirrors/4ac762c75177abe30ea9f4f7d9afbfdc to your computer and use it in GitHub Desktop.
Save SmokeNMirrors/4ac762c75177abe30ea9f4f7d9afbfdc to your computer and use it in GitHub Desktop.
Decode devices from a rooted device for tuya smart life app
If you have a rooted phone and tuya's smart life app, the xml data can be found inside data/data/com.tuya.smartlife/shared_prefs
The file name is something akin to preferences_global_key<someid>.xml
TIP: Look for the file with the largest size. The actual data can be found in <map><string>. Something akin to a small script to parse it in node js
const fs = require('fs');
const path = require('path');
const xml2js = require('xml2js');
const data = fs.readFileSync(path.join(__dirname, process.argv[2]), {encoding: 'UTF-8'});
xml2js.parseString(data, (err, result) => {
const str = result.map.string[6]._;
console.log(str);
const s = JSON.parse(str);
const out = JSON.stringify(s.deviceRespBeen, null, 2);
console.log(out);
fs.writeFileSync('devices.json', out)
});
node decode.js preferences_global_key\<someid\>.xml
@SmokeNMirrors
Copy link
Author

Had to change the [6] to [0] on line 9 to get this to work. Not sure that's a result of Smart Life changes but using 3.6.1 to get the prefs xml.

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