Skip to content

Commit

Permalink
Merge pull request #50 from xianglin1998/master
Browse files Browse the repository at this point in the history
SimpleConsoleView test work finally
  • Loading branch information
xianglin1998 authored Jul 3, 2020
2 parents 9a0eef2 + 6b43799 commit 3e6304c
Show file tree
Hide file tree
Showing 40 changed files with 969 additions and 160 deletions.
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[submodule "pm3rdv4rrg/src/main/cpp/proxmark3"]
path = pm3rdv4rrg/src/main/cpp/proxmark3
url = https://github.com/xianglin1998/proxmark3.git
[submodule "pm3rdv4rrg/src/main/cpp/bzip2"]
path = pm3rdv4rrg/src/main/cpp/bzip2
url = http://sourceware.org/git/bzip2.git
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,19 @@ Download and flash [Compiled FW 12 August](https://www.dropbox.com/s/416lsrqpr2l
- CMAKE: 3.10
- NDK: 20.0.5594570

## How to build?
The RFIDTools have some gitsubmodule

Get the source from GitHub:

git clone https://github.com/xianglin1998/RFIDtools RFIDtools
cd RFIDtools
git submodule init
git submodule update


After clone and init submodule, you can use your AndroidStudio open this project.

## App core implementation

Comunication: LocalSocket & LocalServerSocket(Android)
Expand Down
6 changes: 3 additions & 3 deletions app_main/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
minSdkVersion 24
targetSdkVersion 28
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
versionCode 24
versionName "1.4.6 Termux"
versionCode 25
versionName "1.4.7 Termux and SimpleView"
}
buildTypes {
release {
Expand Down Expand Up @@ -66,8 +66,8 @@ dependencies {
implementation project(':chameleon')
implementation project(':communication')

testImplementation 'junit:junit:4.12'
implementation project(path: ':pm3flasher')
implementation project(':pm3rdv4rrg')
implementation project(path: ':xmodem')

// The dep from TERMUX(A FullTerminal implements.)
Expand Down
3 changes: 2 additions & 1 deletion app_main/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@
<activity android:name=".activities.tools.KeyFileListActivity" />
<activity android:name=".activities.main.PM3FlasherMainActivity" />
<activity android:name=".activities.tools.Proxmark3FirmwareActivity" />
<activity android:name=".activities.tools.Proxmark3NewTerminalInitActivity" />
<activity android:name=".activities.proxmark3.rdv4_rrg.Proxmark3NewTerminalInitActivity" />
<activity android:name=".activities.proxmark3.rdv4_rrg.Proxmark3Rdv4RRGRedTeamConsoleActivity" />

</application>

Expand Down
3 changes: 2 additions & 1 deletion app_main/src/main/assets/cmd.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
{"name": "Mifare 1k Dump", "cmd": "hf mf dump"},
{"name": "Read iclass", "cmd": "hf iclass reader"},
{"name": "Dump iclass legacy", "cmd": "hf iclass dump k afa785a7dab33378"},
{"name": "Hardware Test", "cmd": "hw tune"}
{"name": "Hardware Test", "cmd": "hw tune"},
{"name": "Hardware Version", "cmd": "hw version"},
],
[
{"name" : "High Frequency"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import cn.rrg.rdv.R;
import cn.rrg.rdv.activities.main.PM3FlasherMainActivity;
import cn.rrg.rdv.activities.tools.DeviceConnectActivity;
import cn.rrg.rdv.activities.tools.Proxmark3NewTerminalInitActivity;
import cn.rrg.rdv.activities.proxmark3.rdv4_rrg.Proxmark3NewTerminalInitActivity;
import cn.rrg.rdv.callback.ConnectFailedCtxCallback;
import cn.rrg.rdv.models.AbstractDeviceModel;
import cn.rrg.rdv.models.Proxmark3Rdv4SppModel;
Expand Down Expand Up @@ -53,7 +53,7 @@ public Class getTarget() {

@Override
public String getConnectingMsg() {
return getString(R.string.tips_view_use_termux);
return getString(R.string.tips_plz_wait);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package cn.rrg.rdv.activities.main;

import android.app.AlertDialog;
import android.content.Intent;
import android.os.Bundle;
import android.view.MenuItem;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,19 @@
import androidx.appcompat.app.AppCompatDelegate;

import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;

import java.util.ArrayList;

import cn.dxl.common.interfaces.OnTouchListener;
import cn.dxl.common.util.DisplayUtil;
import cn.dxl.common.util.HexUtil;
import cn.dxl.common.util.LanguageUtil;
import cn.dxl.common.util.LogUtils;
import cn.dxl.common.util.StatusBarUtil;
import cn.dxl.common.widget.ToastUtil;
import cn.dxl.common.util.VibratorUtils;
import cn.dxl.mifare.NfcTagListenUtils;
import cn.dxl.mifare.StdMifareIntent;
import cn.rrg.rdv.R;
import cn.rrg.rdv.application.Properties;
import cn.rrg.rdv.util.Commons;

/**
Expand Down Expand Up @@ -95,20 +91,16 @@ protected void onStart() {
protected void onPause() {
Log.d(LOG_TAG, "Act is pause");
super.onPause();
/*
* 在这里解注册各大前台事件!
* */
mStdMfUtil.disableForegroundDispatch(this);
}

@Override
protected void attachBaseContext(Context newBase) {
String language = Commons.getLanguage();
if (language.equals("auto")) {
//如果value = auto,则设置为跟随系统!
super.attachBaseContext(newBase);
} else {
//否则国际化!
LogUtils.d("New app language: " + language);
super.attachBaseContext(LanguageUtil.setAppLanguage(newBase, language));
}
}
Expand All @@ -125,16 +117,12 @@ protected void onResume() {

@Override
protected void onNewIntent(Intent intent) {
//有新的意图时会启动
Bundle data = intent.getExtras();
if (data != null) {
Tag tag = data.getParcelable(NfcAdapter.EXTRA_TAG);
if (tag != null) {
//存入全局操作域!
NfcTagListenUtils.setTag(tag);
//显示 UID!
ToastUtil.show(this, getString(R.string.tips_uid) + HexUtil.toHexString(tag.getId()), true);
//震动一下!
VibratorUtils.runOneAsDelay(context, 1000);
NfcTagListenUtils.notifyOnNewTag(tag);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
package cn.rrg.rdv.activities.proxmark3.rdv4_rrg;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;

import androidx.annotation.Nullable;

import java.io.File;

import cn.dxl.common.util.FileUtils;
import cn.rrg.console.define.ICommandTools;
import cn.rrg.console.define.ICommandType;
import cn.rrg.freo.IORedirector;
import cn.rrg.rdv.R;
import cn.rrg.rdv.activities.tools.BaseConsoleActivity;
import cn.rrg.rdv.implement.EntryICommandType;
import cn.rrg.rdv.util.Paths;

public abstract class Proxmark3ConsoleActivity
extends BaseConsoleActivity
implements View.OnClickListener,
CompoundButton.OnCheckedChangeListener {

//滞留一个视图实例,可用如GUI,子控件实现!
protected View guiView = null;

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
new Thread(new Runnable() {
@Override
public void run() {
//重定向!
IORedirector.setStdEO(Paths.PM3_FORWARD_O, IORedirector.STD_OUT);
IORedirector.setStdEO(Paths.PM3_FORWARD_E, IORedirector.STD_ERR);
IORedirector.setStdIN(Paths.COMMON_FORWARD_I);
}
}).start();

//父类先初初始化!
super.onCreate(savedInstanceState);

//默认关闭错误消息输出区域(用不上...)
ckBoxOpenOutputError.setChecked(false);
//覆盖父类的停止按钮点击实例
btnStop.setOnClickListener(this);
}

@Override
public void onClick(View v) {
if (v.getId() == R.id.btnStop) {//判断当前是否有客户端可终止的任务在执行,是的话则终止!
new Thread(new Runnable() {
@Override
public void run() {
//TODO 此处进行IO,模拟键盘输入!
stopPM3Client4KeyBorad();
}
}).start();
}
}

//通过键盘输入结束任务!
protected void stopPM3Client4KeyBorad() {
FileUtils.writeString(new File(Paths.COMMON_FORWARD_I), "\n", true);
}

@Override
protected void onDestroy() {
//非常有必要进行相关的结束操作!
stopPM3Client4KeyBorad();
mCMD.stopExecute();
super.onDestroy();
}

/*
* 重写视图实例寻找,方便进行控制!
* */
@Override
public <T extends View> T findViewById(int id) {
T view = super.findViewById(id);
return view != null ? view : guiView != null ? guiView.findViewById(id) : null;
}

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
//don't need process!!!
}

@Override
protected View getCommandGUI() {
return guiView;
}

@Override
protected File initOutTarget() {
return new File(Paths.PM3_FORWARD_O);
}

@Override
protected File initErrTarget() {
return new File(Paths.PM3_FORWARD_E);
}

@Override
protected int startTest(ICommandTools cmd) {
mDefaultCMD = "help";
if (edtInputCmd.getText().toString().length() > 0) {
mDefaultCMD = edtInputCmd.getText().toString();
}
//此处做出多行执行优化!
int ret = -2;
//优化,如果是多行命令的操作!
if (mDefaultCMD.contains("\n")) {
//包含换行,则当作多行处理!
String[] cmds = mDefaultCMD.split("\n");
Log.d(LOG_TAG, "警告,当前执行的是多行处理操作!");
for (String c : cmds) {
Log.d(LOG_TAG, "当前执行的命令: " + c);
mCMD.startExecute(c);
}
return ret;
} else {
//直接执行命令并且在执行命令完成后进行回调!
ret = cmd.startExecute(mDefaultCMD);
}
return ret;
}

@Override
protected void onNewOutLine(String line) {
}

@Override
protected void onNewErrLine(String line) {
}

@Override
protected ICommandType initType() {
return new EntryICommandType();
}

@Override
protected void onTestEnd() {
}

@Override
protected boolean isTesting() {
return super.isTesting();
}

@Override
protected void stopTest() {
//super.stopTest();
//TODO 无必要停止PM3的底层线程!
}
}
Loading

0 comments on commit 3e6304c

Please sign in to comment.