Search in sources :

Example 1 with Information

use of seemoo.fitbit.information.Information in project fitness-app by seemoo-lab.

the class Utilities method translate.

/**
 * Converts the live mode byte array into a readable information list.
 *
 * @param value The byte array to convert.
 * @return A readable information list.
 */
public static InformationList translate(byte[] value) {
    InformationList list = new InformationList("LiveMode");
    String data = Utilities.byteArrayToHexString(value);
    Calendar calendar = Calendar.getInstance();
    calendar.setTimeInMillis(Utilities.hexStringToInt(Utilities.rotateBytes(data.substring(0, 8))) * 1000L);
    list.add(new Information("time: " + calendar.getTime()));
    list.add(new Information("steps: " + Utilities.hexStringToInt(Utilities.rotateBytes(data.substring(8, 16)))));
    list.add(new Information("distance: " + Utilities.hexStringToInt(Utilities.rotateBytes(data.substring(16, 24))) / 1000 + " m"));
    list.add(new Information("calories: " + Utilities.hexStringToInt(Utilities.rotateBytes(data.substring(24, 28))) + " METs"));
    list.add(new Information("elevation: " + Utilities.hexStringToInt(Utilities.rotateBytes(data.substring(28, 32))) / 10 + " floors"));
    // list.add(new Information("heartRateConfidence: " + Utilities.hexStringToInt(Utilities.rotateBytes(data.substring(38, 40)))));
    return list;
}
Also used : Calendar(java.util.Calendar) InformationList(seemoo.fitbit.information.InformationList) Information(seemoo.fitbit.information.Information)

Example 2 with Information

use of seemoo.fitbit.information.Information in project fitness-app by seemoo-lab.

the class DumpInteraction method finish.

/**
 * {@inheritDoc}
 * Returns the collected data and gets a readable translation for unencrypted parts.
 *
 * @return The collected data.
 */
@Override
InformationList finish() {
    InformationList result = new InformationList(name);
    if (!transmissionActive && data.length() > 0) {
        Log.e(TAG, name + " successful.");
        dataList.addAll(dataCut(data));
        if (dumpType != 3) {
            result.addAll(readOut());
            result.add(new Information(""));
            result.add(new Information(ConstantValues.RAW_OUTPUT));
            result.addAll(dataList);
        } else {
            result.addAll(dataList);
        }
    } else {
        activity.runOnUiThread(new Runnable() {

            @Override
            public void run() {
                toast.setText(name + " failed.");
                toast.show();
            }
        });
        dataList = null;
        Log.e(TAG, name + " failed.");
    }
    commands.comDisableNotifications1();
    return result;
}
Also used : InformationList(seemoo.fitbit.information.InformationList) Information(seemoo.fitbit.information.Information)

Example 3 with Information

use of seemoo.fitbit.information.Information 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.
 */
private InformationList readOut() {
    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":
                model = "Megadump";
                break;
            case "30":
                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);
        }
        temp = dataList.get(0).toString().substring(serialPos + 10, serialPos + 12);
        switch(temp.substring(0, 2)) {
            // FIXME do this via ConstantValues
            case "01":
                id = "Zip";
                break;
            case "05":
                id = "One";
                break;
            case "07":
                id = "Flex";
                break;
            case "08":
                id = "Charge";
                break;
            case "12":
                id = "Charge HR";
                break;
            case "15":
                id = "Alta";
                break;
            case "10":
                id = "Surge";
                break;
            case "11":
                id = "Electron";
                break;
            case "1b":
                id = "Ionic";
                break;
            default:
                id = temp;
        }
        result.add(new Information("SiteProto: " + model + ", " + type));
        result.add(new Information("Encrypted: " + 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)));
        AuthValues.setSerialNumber(productCode);
        if (AuthValues.NONCE == null) {
            InternalStorage.loadAuthFiles(activity);
        }
        result.add(new Information("ID: " + id));
        if (!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"));
    } else {
        // Alarms
        ArrayList<Information> 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;
}
Also used : Alarm(seemoo.fitbit.information.Alarm) ArrayList(java.util.ArrayList) InformationList(seemoo.fitbit.information.InformationList) Information(seemoo.fitbit.information.Information)

Example 4 with Information

use of seemoo.fitbit.information.Information in project fitness-app by seemoo-lab.

the class DumpInteraction method dataCut.

/**
 * Decrypts the eSLIP encrypted input and cuts it into 20 byte parts. Returns the result as information list.
 *
 * @param input The input data as a string.
 * @return An information list with decrypted input.
 */
private InformationList dataCut(String input) {
    InformationList result = new InformationList("");
    String temp = "";
    int positionEncode = 0;
    while (positionEncode < input.length()) {
        // encoding of first two byte in line
        if (positionEncode + 40 < input.length()) {
            // line is 20 byte long
            if (input.substring(positionEncode, positionEncode + 4).equals("dbdc")) {
                temp = temp + "c0" + input.substring(positionEncode + 4, positionEncode + 40);
            } else if (input.substring(positionEncode, positionEncode + 4).equals("dbdd")) {
                temp = temp + "db" + input.substring(positionEncode + 4, positionEncode + 40);
            } else {
                temp = temp + input.substring(positionEncode, positionEncode + 40);
            }
            positionEncode = positionEncode + 40;
        } else if (positionEncode + 4 < input.length()) {
            // line is between two and 20 byte long
            if (input.substring(positionEncode, positionEncode + 4).equals("dbdc")) {
                temp = temp + "c0" + input.substring(positionEncode + 4, input.length());
            } else if (input.substring(positionEncode, positionEncode + 4).equals("dbdd")) {
                temp = temp + "db" + input.substring(positionEncode + 4, input.length());
            } else {
                temp = temp + input.substring(positionEncode, input.length());
            }
            break;
        } else {
            // line is shorter than two byte
            temp = temp + input.substring(positionEncode, input.length());
            break;
        }
    }
    int position = 0;
    while (position < temp.length()) {
        // cut in 20 byte parts
        if (position + 40 < temp.length()) {
            result.add(new Information(temp.substring(position, position + 40)));
            position = position + 40;
        } else {
            result.add(new Information(temp.substring(position, temp.length())));
            break;
        }
    }
    return result;
}
Also used : InformationList(seemoo.fitbit.information.InformationList) Information(seemoo.fitbit.information.Information)

Example 5 with Information

use of seemoo.fitbit.information.Information in project fitness-app by seemoo-lab.

the class WorkActivity method collectBasicInformation.

/**
 * Collects basic information about the selected device, stores them in 'information' and displays them to the user.
 */
public void collectBasicInformation() {
    if (!firstPress) {
        saveButton.setVisibility(View.VISIBLE);
    }
    InformationList list = new InformationList("basic");
    currentInformationList = "basic";
    list.add(new Information("MAC Address: " + device.getAddress()));
    list.add(new Information("Name: " + device.getName()));
    int type = device.getType();
    if (type == BluetoothDevice.DEVICE_TYPE_UNKNOWN) {
        list.add(new Information(getString(R.string.device_type0)));
    } else if (type == BluetoothDevice.DEVICE_TYPE_CLASSIC) {
        list.add(new Information(getString(R.string.device_type1)));
    } else if (type == BluetoothDevice.DEVICE_TYPE_LE) {
        list.add(new Information(getString(R.string.device_type2)));
    } else if (type == BluetoothDevice.DEVICE_TYPE_DUAL) {
        list.add(new Information(getString(R.string.device_type3)));
    }
    int bondState = device.getBondState();
    if (bondState == BluetoothDevice.BOND_NONE) {
        list.add(new Information(getString(R.string.bond_state0)));
    } else if (bondState == BluetoothDevice.BOND_BONDING) {
        list.add(new Information(getString(R.string.bond_state1)));
    } else if (bondState == BluetoothDevice.BOND_BONDED) {
        list.add(new Information(getString(R.string.bond_state2)));
    }
    InternalStorage.loadAuthFiles(activity);
    if (AuthValues.AUTHENTICATION_KEY == null) {
        list.add(new Information("Authentication credentials unavailable, user login with previously associated tracker required. Association is only supported by the official Fitbit app."));
    } else {
        list.add(new Information("Authentication Key & Nonce: " + AuthValues.AUTHENTICATION_KEY + ", " + AuthValues.NONCE));
    }
    if (AuthValues.ENCRYPTION_KEY == null) {
        list.add(new Information("Encryption key unavailable, requires authenticated memory readout on vulnerable tracker models."));
    } else {
        list.add(new Information("Encryption Key: " + AuthValues.ENCRYPTION_KEY));
    }
    information.put("basic", list);
    informationToDisplay.override(information.get("basic"), mListView);
}
Also used : InformationList(seemoo.fitbit.information.InformationList) Information(seemoo.fitbit.information.Information)

Aggregations

Information (seemoo.fitbit.information.Information)6 InformationList (seemoo.fitbit.information.InformationList)5 WebSettings (android.webkit.WebSettings)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 ArrayAdapter (android.widget.ArrayAdapter)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1 Timer (java.util.Timer)1 TimerTask (java.util.TimerTask)1 HttpsClient (seemoo.fitbit.https.HttpsClient)1 Alarm (seemoo.fitbit.information.Alarm)1 ButtonHandler (seemoo.fitbit.miscellaneous.ButtonHandler)1