use of seemoo.fitbit.miscellaneous.InfoListItem in project fitness-app by seemoo-lab.
the class DumpInteraction method readOut.
/**
* Reads out the information from a micro- or mega dump.
*
* @return The information or null if it is an alarm or memory dump.
*/
// TODO interpret step counts per minute
private InformationList readOut() {
Log.e(TAG, "readOut: interpeting dump data...");
InformationList result = new InformationList("");
String temp = "";
if (dumpType == 0 || dumpType == 1) {
// Microdump || Megadump
String model;
String type;
String id;
int noncePos = 12;
int serialPos = 20;
temp = dataList.get(0).toString().substring(0, 8);
switch(temp.substring(0, 2)) {
case "2c":
case "2a":
model = "Megadump";
break;
case "30":
case "31":
model = "Microdump";
break;
case "03":
// Ionic format is new, generic dump, different offsets
model = "Dump";
noncePos = 10;
serialPos = 18;
break;
default:
model = temp.substring(0, 2);
}
switch(temp.substring(2, 4)) {
case "02":
type = "Tracker";
break;
case "04":
type = "Smartwatch";
break;
default:
type = temp.substring(2, 4);
}
result.add(new Information("SiteProto: " + model + ", " + type));
FitbitDevice.setEncrypted(encrypted());
result.add(new Information("Encrypted: " + FitbitDevice.ENCRYPTED));
result.add(new Information("Nonce: " + Utilities.rotateBytes(dataList.get(0).toString().substring(noncePos, noncePos + 4))));
String productCode = dataList.get(0).toString().substring(serialPos, serialPos + 12);
result.add(new Information("Serial Number: " + Utilities.rotateBytes(productCode)));
FitbitDevice.setSerialNumber(productCode);
if (FitbitDevice.NONCE == null) {
InternalStorage.loadAuthFiles(mainFragment.getActivity());
}
result.add(new Information("ID: " + FitbitDevice.getDeviceType()));
if (!FitbitDevice.ENCRYPTED) {
result.add(new Information("Version: " + Utilities.rotateBytes(dataList.get(0).toString().substring(16, 20))));
}
temp = dataList.get(dataList.size() - 2).toString() + dataList.get(dataList.size() - 1).toString();
result.add(new Information("Length: " + Utilities.hexStringToInt(Utilities.rotateBytes(temp.substring(temp.length() - 6, temp.length()))) + " byte"));
// add plaintext dump info
if (FitbitDevice.ENCRYPTED && null != FitbitDevice.ENCRYPTION_KEY) {
Log.e(TAG, "Encrypted dump found, trying to decrypt...");
String plaintextDump = Crypto.decryptTrackerDump(Utilities.hexStringToByteArray(dataList.getData()), mainFragment.getActivity());
result = plainDumpProcessing(result, plaintextDump);
} else if (!FitbitDevice.ENCRYPTED) {
Log.e(TAG, "Plaintext dump found, processing...");
String plaintextDump = dataList.getData();
result = plainDumpProcessing(result, plaintextDump);
}
} else {
// Alarms
ArrayList<InfoListItem> input = new ArrayList<>();
input.addAll(dataList.getList());
for (int i = 0; i < 11; i++) {
temp = temp + input.get(i);
}
setAlarmIndex(temp);
result.add(new Information("Alarms:"));
for (int i = 0; i < 8; i++) {
result.add(new Alarm(temp.substring(28 + i * 48, 28 + (i + 1) * 48)));
}
result.add(new Information(""));
result.add(new Information(ConstantValues.ADDITIONAL_INFO));
result.add(new Information("Number of Alarms: " + Utilities.hexStringToInt(Utilities.rotateBytes(input.get(0).toString().substring(20, 24)))));
result.add(new Information("CRC_CCITT: " + Utilities.rotateBytes(temp.substring(412, 416))));
result.add(new Information("Length: " + Utilities.hexStringToInt(Utilities.rotateBytes(temp.substring(428, 434))) + " byte"));
}
return result;
}
use of seemoo.fitbit.miscellaneous.InfoListItem in project fitness-app by seemoo-lab.
the class InformationList method getData.
/**
* Concatenates all information of this list and returns it as string.
*
* @return The concatenated string.
*/
public String getData() {
String result = "";
for (int i = 0; i < list.size(); i++) {
InfoListItem item = list.get(i);
if (item.getItemType() == InfoListItem.TEXT_VIEW) {
Information infoItem = (Information) item;
result = result + infoItem.toString();
}
}
return result;
}
use of seemoo.fitbit.miscellaneous.InfoListItem in project fitness-app by seemoo-lab.
the class InformationList method getBeautyData.
/**
* Concatenates all information of this list in a beauty way and returns it as string.
*
* @return The beautiful concatenated string.
*/
public String getBeautyData() {
String result = "";
for (int i = 0; i < list.size(); i++) {
InfoListItem item = list.get(i);
if (item.getItemType() == InfoListItem.TEXT_VIEW) {
Information infoItem = (Information) item;
result = result + infoItem.toString() + "\n";
}
}
return result;
}
Aggregations