Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

Commit

Permalink
Updated live logging codes to include the new sniffer obtained data
Browse files Browse the repository at this point in the history
  • Loading branch information
maxieds committed Sep 27, 2018
1 parent 19b08fe commit b333cee
Show file tree
Hide file tree
Showing 13 changed files with 89 additions and 57 deletions.
34 changes: 13 additions & 21 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def getDateTimestamp() {

android {

compileSdkVersion 25
compileSdkVersion 28
defaultConfig {
applicationId "com.maxieds.chameleonminilivedebugger"
minSdkVersion 21
targetSdkVersion 27
versionCode 53
versionName "0.5.3"
minSdkVersion 26
targetSdkVersion 28
versionCode 54
versionName "0.5.4"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
Expand All @@ -27,30 +27,25 @@ android {
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
crunchPngs false
//enableCrashlytics = true
//alwaysUpdateBuildId false
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
crunchPngs false
//enableCrashlytics = true
//alwaysUpdateBuildId true
}
}
buildToolsVersion '27.0.3'
buildToolsVersion '28.0.2'

flavorDimensions "mode"
def configBuildTimeStamp = getDateTimestamp()
applicationVariants.all { variant ->
variant.outputs.each { output ->
def directoryPath = "all-builds/"
def apkName = "ChameleonMiniLiveDebugger-${variant.name}-vc${variant.versionCode}-v${variant.versionName}-${configBuildTimeStamp}.apk"
//output.outputFile = new File(directoryPath + apkName)
}
}
productFlavors {
main {
free {
versionNameSuffix "-free"
dimension "mode"
buildConfigField "boolean", "PAID_APP_VERSION", "false"
Expand Down Expand Up @@ -86,23 +81,20 @@ android {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:support-v4:25.4.0'
implementation 'com.android.support:appcompat-v7:25.4.0'
implementation 'com.android.support:design:25.4.0'
implementation 'com.github.felHR85:UsbSerial:4.5'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.github.felHR85:UsbSerial:4.5.2'
implementation 'com.shawnlin:number-picker:2.4.4'
//classpath 'io.fabric.tools:gradle:1.+'
//compile('com.crashlytics.sdk.android:crashlytics:2.8.0@aar') { transitive = true; }
}

repositories {
jcenter()
google()
maven { url "https://maven.google.com" }
maven { url "https://jitpack.io" }
//maven { url "https://maven.fabric.io/public" }
}

}
}
Binary file added app/free/release/app-free-release.apk
Binary file not shown.
1 change: 1 addition & 0 deletions app/free/release/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":54,"versionName":"0.5.4-free","enabled":true,"outputFile":"app-free-release.apk","fullName":"freeRelease","baseName":"free-release"},"path":"app-free-release.apk","properties":{}}]
Binary file modified app/paid/release/app-paid-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/paid/release/output.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":53,"versionName":"0.5.3-paid","enabled":true,"outputFile":"app-paid-release.apk","fullName":"paidRelease","baseName":"paid-release"},"path":"app-paid-release.apk","properties":{}}]
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":54,"versionName":"0.5.4-paid","enabled":true,"outputFile":"app-paid-release.apk","fullName":"paidRelease","baseName":"paid-release"},"path":"app-paid-release.apk","properties":{}}]
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import android.support.v4.view.ViewPager;
import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.app.NotificationCompat;
import android.support.v4.app.NotificationCompat;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MenuItem;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.maxieds.chameleonminilivedebugger;

import android.content.Context;
import android.support.annotation.DrawableRes;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand Down Expand Up @@ -49,6 +50,7 @@ public class LogEntryUI extends LogEntryBase {
private int logType;
private String logLabel;
private byte[] entryData;
private int dataDirection;

/**
* Effective constructor for the class.
Expand Down Expand Up @@ -80,7 +82,7 @@ public static LogEntryUI newInstance(byte[] rawLogBytes, String logLabel) {
else
System.arraycopy(rawLogBytes, 4, payloadBytes, 0, payloadBytes.length);
LogEntryUI newLogDataEntry = new LogEntryUI();
return newLogDataEntry.configureLogEntry(LiveLoggerActivity.defaultContext, logLabel, diffTimeMs, logCode, payloadBytes);
return newLogDataEntry.configureLogEntry(LiveLoggerActivity.defaultContext, logLabel, diffTimeMs, LogUtils.getDataDirection(logCode), logCode, payloadBytes);
}

/**
Expand All @@ -93,13 +95,13 @@ public static LogEntryUI newInstance(byte[] rawLogBytes, String logLabel) {
* @return LogEntryUI the configured log entry
* @url http://rawgit.com/emsec/ChameleonMini/master/Doc/Doxygen/html/Page_Log.html
*/
public LogEntryUI configureLogEntry(Context context, String label, int diffTimeMs, int ltype, byte[] edata) {
public LogEntryUI configureLogEntry(Context context, String label, int diffTimeMs, int dataDir, int ltype, byte[] edata) {
numBytes = edata.length;
diffTimeMillis = diffTimeMs;
dataDirection = dataDir;
logType = ltype;
logLabel = label;
entryData = edata;
//LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = LiveLoggerActivity.defaultInflater;
mainEntryContainer = (LinearLayout) inflater.inflate(R.layout.log_entry_ui, null);
configureLayout(mainEntryContainer);
Expand Down Expand Up @@ -152,6 +154,7 @@ public void configureLayout(LinearLayout mainContainerRef) {
mainEntryContainer = mainContainerRef;
entrySelect = (CheckBox) mainContainerRef.findViewById(R.id.entrySelect);
inoutDirIndicator = (ImageView) mainContainerRef.findViewById(R.id.inputDirIndicatorImg);
inoutDirIndicator.setImageDrawable(LiveLoggerActivity.runningActivity.getResources().getDrawable(getDataDirectionMarker()));
apduParseStatus = (ImageView) mainContainerRef.findViewById(R.id.apduParseStatusImg);
tvLabel = (TextView) mainContainerRef.findViewById(R.id.text_label);
recordID = ++LiveLoggerActivity.RECORDID;
Expand Down Expand Up @@ -279,6 +282,15 @@ public String getPayloadDataString(boolean byteString) {
}
}

public int getDataDirectionMarker() {
if(dataDirection == LogUtils.DATADIR_INCOMING)
return R.drawable.incoming_arrow16;
else if(dataDirection == LogUtils.DATADIR_OUTGOING)
return R.drawable.outgoing_arrow16;
else
return R.drawable.xfer16;
}

/**
* Returns the layout container (LinearLayout object) associated with this log entry.
* @return (LinearLayout) View
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,38 +18,46 @@
*/
public class LogUtils {

public static final int DATADIR_INCOMING = 0;
public static final int DATADIR_OUTGOING = 1;
public static final int DATADIR_BIDIRECTIONAL = 2;

public enum LogCode {
/* Generic */
LOG_INFO_GENERIC(0x10, "Unspecific log entry."),
LOG_INFO_CONFIG_SET(0x11, "Configuration change."),
LOG_INFO_SETTING_SET(0x12, "Setting change."),
LOG_INFO_UID_SET(0x13, "UID change."),
LOG_INFO_RESET_APP(0x20, "Application reset."),
LOG_INFO_GENERIC(0x10, DATADIR_BIDIRECTIONAL, "Unspecific log entry."),
LOG_INFO_CONFIG_SET(0x11, DATADIR_BIDIRECTIONAL, "Configuration change."),
LOG_INFO_SETTING_SET(0x12, DATADIR_BIDIRECTIONAL, "Setting change."),
LOG_INFO_UID_SET(0x13, DATADIR_BIDIRECTIONAL, "UID change."),
LOG_INFO_RESET_APP(0x20, DATADIR_BIDIRECTIONAL, "Application reset."),
/* Codec */
LOG_INFO_CODEC_RX_DATA(0x40, "Currently active codec received data."),
LOG_INFO_CODEC_TX_DATA(0x41, "Currently active codec sent data."),
LOG_INFO_CODEC_RX_DATA_W_PARITY(0x42, "Currently active codec received data."),
LOG_INFO_CODEC_TX_DATA_W_PARITY(0x43, "Currently active codec sent data."),
LOG_INFO_CODEC_RX_DATA(0x40, DATADIR_OUTGOING, "Currently active codec received data."),
LOG_INFO_CODEC_TX_DATA(0x41, DATADIR_OUTGOING, "Currently active codec sent data."),
LOG_INFO_CODEC_RX_DATA_W_PARITY(0x42, DATADIR_OUTGOING, "Currently active codec received data."),
LOG_INFO_CODEC_TX_DATA_W_PARITY(0x43, DATADIR_OUTGOING, "Currently active codec sent data."),
LOG_INFO_CODEC_SNI_READER_DATA(0x44, DATADIR_INCOMING, "Sniffing codec receive data from reader."),
LOG_INFO_CODEC_SNI_READER_DATA_W_PARITY(0x44, DATADIR_INCOMING, "Sniffing codec receive data from reader"),
LOG_INFO_CODEC_SNI_CARD_DATA(0x46, DATADIR_INCOMING, "Sniffing codec receive data from card."),
LOG_INFO_CODEC_SNI_CARD_DATA_W_PARITY(0x47, DATADIR_INCOMING, "Sniffing codec receive data from card."),
/* App */
LOG_INFO_APP_CMD_READ(0x80, "Application processed read command."),
LOG_INFO_APP_CMD_WRITE(0x81, "Application processed write command."),
LOG_INFO_APP_CMD_INC(0x84, "Application processed increment command."),
LOG_INFO_APP_CMD_DEC(0x85, "Application processed decrement command."),
LOG_INFO_APP_CMD_TRANSFER(0x86, "Application processed transfer command."),
LOG_INFO_APP_CMD_RESTORE(0x87, "Application processed restore command."),
LOG_INFO_APP_CMD_AUTH(0x90, "Application processed authentication command."),
LOG_INFO_APP_CMD_HALT(0x91, "Application processed halt command."),
LOG_INFO_APP_CMD_UNKNOWN(0x92, "Application processed an unknown command."),
LOG_INFO_APP_AUTHING(0xA0, "Application is in `authing` state."),
LOG_INFO_APP_AUTHED(0xA1, "Application is in `auth` state."),
LOG_INFO_APP_CMD_READ(0x80, DATADIR_BIDIRECTIONAL, "Application processed read command."),
LOG_INFO_APP_CMD_WRITE(0x81, DATADIR_BIDIRECTIONAL, "Application processed write command."),
LOG_INFO_APP_CMD_INC(0x84, DATADIR_BIDIRECTIONAL, "Application processed increment command."),
LOG_INFO_APP_CMD_DEC(0x85, DATADIR_BIDIRECTIONAL, "Application processed decrement command."),
LOG_INFO_APP_CMD_TRANSFER(0x86, DATADIR_BIDIRECTIONAL, "Application processed transfer command."),
LOG_INFO_APP_CMD_RESTORE(0x87, DATADIR_BIDIRECTIONAL, "Application processed restore command."),
LOG_INFO_APP_CMD_AUTH(0x90, DATADIR_BIDIRECTIONAL, "Application processed authentication command."),
LOG_INFO_APP_CMD_HALT(0x91, DATADIR_BIDIRECTIONAL, "Application processed halt command."),
LOG_INFO_APP_CMD_UNKNOWN(0x92, DATADIR_BIDIRECTIONAL, "Application processed an unknown command."),
LOG_INFO_APP_AUTHING(0xA0, DATADIR_BIDIRECTIONAL, "Application is in `authing` state."),
LOG_INFO_APP_AUTHED(0xA1, DATADIR_BIDIRECTIONAL, "Application is in `auth` state."),
/* Log errors */
LOG_ERR_APP_AUTH_FAIL(0xC0, "Application authentication failed."),
LOG_ERR_APP_CHECKSUM_FAIL(0xC1, "Application had a checksum fail."),
LOG_ERR_APP_NOT_AUTHED(0xC2, "Application is not authenticated."),
LOG_ERR_APP_AUTH_FAIL(0xC0, DATADIR_BIDIRECTIONAL, "Application authentication failed."),
LOG_ERR_APP_CHECKSUM_FAIL(0xC1, DATADIR_BIDIRECTIONAL, "Application had a checksum fail."),
LOG_ERR_APP_NOT_AUTHED(0xC2, DATADIR_BIDIRECTIONAL, "Application is not authenticated."),
/* Other Chameleon-specific */
LOG_INFO_SYSTEM_BOOT(0xFF, "Chameleon boots"),
LOG_EMPTY(0x00, "Empty Log Entry. This is not followed by a length byte nor the two systick bytes nor any data."),
LOG_CODE_DNE(0xff, "This is a dummy log code entry for matching where the input code does not exist.");
LOG_INFO_SYSTEM_BOOT(0xFF, DATADIR_BIDIRECTIONAL, "Chameleon boots"),
LOG_EMPTY(0x00, DATADIR_BIDIRECTIONAL, "Empty Log Entry. This is not followed by a length byte nor the two systick bytes nor any data."),
LOG_CODE_DNE(0xff, DATADIR_BIDIRECTIONAL, "This is a dummy log code entry for matching where the input code does not exist.");

/**
* Stores a mapping of the log codes to their enum values.
Expand All @@ -67,15 +75,17 @@ public enum LogCode {
* Local data stored by the class.
*/
private int logCode;
private int logDataDirection;
private String logDesc;

/**
* Constructor.
* @param lcode
* @param ldesc
*/
private LogCode(int lcode, String ldesc) {
private LogCode(int lcode, int ldd, String ldesc) {
logCode = lcode;
logDataDirection = ldd;
logDesc = ldesc;
}

Expand All @@ -86,6 +96,7 @@ private LogCode(int lcode, String ldesc) {
public int toInteger() {
return logCode;
}
public int getDataDirection() { return logDataDirection; }
public String getDesc() { return logDesc; }

/**
Expand All @@ -108,6 +119,9 @@ public static LogCode lookupByLogCode(int lcode) {
*/
public static String getShortCodeName(int lcode) {
LogCode lc = lookupByLogCode(lcode);
if(lc == null) {
return "UNKNOWN_LOG_CODE";
}
String longName = lc.name();
longName = longName.replace("LOG_INFO_", "");
longName = longName.replace("LOG_INFO_CODEC_", "");
Expand All @@ -118,4 +132,17 @@ public static String getShortCodeName(int lcode) {

}

/**
* Returns the data transfer direction based on the logging code.
* Note that this bidirectional sniffing output from the Chameleon Rev. G
* boards is fairly recent as of (9-10/2018).
*/
public static int getDataDirection(int lcode) {
LogCode lc = LogCode.lookupByLogCode(lcode);
if(lc == null) {
return DATADIR_BIDIRECTIONAL;
}
return lc.getDataDirection();
}

}
Binary file added app/src/main/res/drawable/incoming_arrow16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/src/main/res/drawable/outgoing_arrow16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
<td><code>LOGSTORE</code> </td><td>Writes the current log from SRAM to FRAM and clears the SRAM log. <dl class="section warning"><dt>Warning</dt><dd>If the FRAM is full, currently no error message is shown. If calling <code>LOGMEM?</code> after executing this command returns any other value than the maximum SRAM log size, there was not sufficient space in the FRAM and nothing has been done. </dd></dl>
</td></tr>
</table>
<p>ChameleonMini provides eight 'slots' that can be configured to store different virtualized cards, or as active NFC reader, or as completely passive device for sniffing purposes. Each slot stores its configuration and, if applicable, card content. To select a particular slot, use the following command (or configure a button accordingly): </p><table class="doxtable">
<p>ChameleonMini provides eight \'slots\' that can be configured to store different virtualized cards, or as active NFC reader, or as completely passive device for sniffing purposes. Each slot stores its configuration and, if applicable, card content. To select a particular slot, use the following command (or configure a button accordingly): </p><table class="doxtable">
<tr>
<th>Command </th><th>Description </th></tr>
<tr>
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.android.tools.build:gradle:3.2.0'
}

}
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun May 06 15:04:08 EDT 2018
#Wed Sep 26 18:41:06 EDT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip

0 comments on commit b333cee

Please sign in to comment.