Skip to content

Commit

Permalink
Merge pull request #7 from xLaMbChOpSx/master
Browse files Browse the repository at this point in the history
Reduce target sdk version & code updates
  • Loading branch information
SecUpwN committed Mar 31, 2014
2 parents 715a858 + 4fa0d40 commit 8def9eb
Show file tree
Hide file tree
Showing 9 changed files with 251 additions and 501 deletions.
4 changes: 2 additions & 2 deletions AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.SecUpwN.AIMSICD"
android:versionName="0.2.2"
android:versionName="0.1.1"
android:versionCode="3"
android:sharedUserId="android.uid.phone">

<uses-sdk
android:minSdkVersion="14"
android:minSdkVersion="9"
android:targetSdkVersion="19"/>

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Expand Down
7 changes: 7 additions & 0 deletions res/layout/riloemhook_layout.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
android:text="@string/radio_api5"
/>

<RadioButton
android:id="@+id/radio_api6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/radio_api6"
/>

<RadioButton
android:id="@+id/radio_api4"
android:layout_width="wrap_content"
Expand Down
3 changes: 2 additions & 1 deletion res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
<string name="radio_api2">API 2 (datalen=1)</string>
<string name="radio_api3">API 3 (datalen=6)</string>
<string name="radio_api4">API 4 Type command :</string>
<string name="radio_api5">API 5 Ciphering Indicator</string>
<string name="radio_api5">Ciphering Indicator - RilRAW</string>
<string name="radio_api6">Ciphering Indicator - ServiceMode</string>
<string name="radio_run">RUN</string>
<string name="ril_oem_response">Module response:</string>
</resources>
26 changes: 11 additions & 15 deletions src/com/SecUpwN/AIMSICD/AIMSICD.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,28 +50,28 @@ public void onCreate(Bundle savedInstanceState) {
outputView.append("SIM serial: " + Device.getSimSerial(false) + "\n\n");
}

int netID = Device.getNetID(true);
outputView.append("Device type: " + Device.getPhoneType(false) + "\n");
outputView.append("Device IMEI: " + Device.getIMEI(false) + "\n");
outputView.append("Device version: " + Device.getIMEIv(false) + "\n");
outputView.append("Device num: " + Device.getPhoneNumber(false) + "\n\n");
outputView.append("Network name: " + Device.getNetworkName(false) + "\n");
outputView.append("Network code: " + Device.getSmmcMcc(false) + "\n");
outputView.append("Network type: " + Device.getsNetworkType(false) + "\n");
outputView.append("Network type: " + Device.getNetworkTypeName() + "\n");
outputView.append("Network LAC: " + Device.getsLAC(false) + "\n");
outputView.append("Network CellID: " + Device.getsCellId(false) + "\n\n");

outputView.append("Data activity: " + Device.getsDataActivity(false) + "\n");
outputView.append("Data status: " + Device.getsDataState(false) + "\n");
outputView.append("Data activity: " + Device.getActivityDesc(netID) + "\n");
outputView.append("Data status: " + Device.getStateDesc(netID) + "\n");

Device.kmlheader();
outputView.append("--------------------------------\n");
outputView.append("[LAC,CID]|DAct|DStat|Net|Sig|Lat|Lng\n");
Log.i(TAG, "**** AIMSICD ****");
Log.i(TAG, "Device type : " + Device.getPhoneType(false));
Log.i(TAG, "Device imei : " + Device.getIMEI(false));
Log.i(TAG, "Device version: " + Device.getIMEIv(false));
Log.i(TAG, "Device num : " + Device.getPhoneNumber(false));
Log.i(TAG, "Network type : " + Device.getsNetworkType(false));
Log.i(TAG, "Network type : " + Device.getNetworkTypeName());
Log.i(TAG, "Network CellID: " + Device.getsCellId(false));
Log.i(TAG, "Network LAC : " + Device.getsLAC(false));
Log.i(TAG, "Network code : " + Device.getSmmcMcc(false));
Expand All @@ -93,16 +93,15 @@ public boolean onPrepareOptionsMenu(Menu menu) {
menu.add(1, 1, 0, "Track Signal");
}
if (Device.isTrackingLocation()) {
menu.add(1, 2, 0, "Remove Loc.");
menu.add(1, 2, 0, "Untrack Location");
} else {
menu.add(1, 2, 0, "Add Location");
menu.add(1, 2, 0, "Track Location");
}
menu.add(0, 4, 4, "Show Map");

menu.add(0, 6, 6, "Quit");
menu.add(0, 7, 7, "Dump Session KML");
menu.add(0, 8, 8, "Export Database Tables");
menu.add(0, 9, 9, "AT OEM RIL Hook Test");
menu.add(0, 7, 7, "Export Database Tables");
menu.add(0, 8, 8, "AT OEM RIL Hook Test");
menu.setGroupCheckable(1, true, false);
return super.onCreateOptionsMenu(menu);
}
Expand Down Expand Up @@ -130,12 +129,9 @@ public boolean onOptionsItemSelected(MenuItem item) {
finish();
return true;
case 7:
Device.dumpinfokml(mContext);
return true;
case 8:
Device.exportDB();
return true;
case 9:
case 8:
Intent intent = new Intent(this, ATRilHook.class);
startActivity(intent);
return true;
Expand Down Expand Up @@ -163,7 +159,7 @@ protected final void about() {
webview.bringToFront();
} else {
webview = new WebView(this);
webview.loadUrl("http://github.com/SecUpwN/Android-IMSI-Catcher-Detector");
webview.loadUrl("http://secupwn.github.io/Android-IMSI-Catcher-Detector/");
setContentView(webview);
}
isAbout = true;
Expand Down
137 changes: 78 additions & 59 deletions src/com/SecUpwN/AIMSICD/ATRilHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import android.view.View;
import android.view.View.OnKeyListener;
import android.widget.*;
import com.SecUpwN.AIMSICD.cmdprocessor.Helpers;
import com.android.internal.telephony.Phone;
import com.android.internal.telephony.PhoneFactory;

Expand Down Expand Up @@ -64,10 +65,6 @@ public void onCreate(Bundle icicle) {
mPhone = PhoneFactory.getDefaultPhone();
mOemCommands = OemCommands.getInstance(sContext);

/*
* makeDefaultPhones(); getDefaultPhone();
*/

mRespText = (EditText) findViewById(R.id.edit_cmdstr);
mRespText.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
Expand Down Expand Up @@ -109,15 +106,20 @@ public void execRIL(View view) {
// Get the response field
mRespText = (EditText) findViewById(R.id.edit_response);
byte[] oemhook = null;
Message msg;
switch (idButtonChecked) {
case R.id.radio_api1:
oemhook = new byte[1];
oemhook[0] = (byte) 0xAA;
sendRequest(oemhook, EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE);
mRespText.setText("");
break;
case R.id.radio_api2:
oemhook = new byte[2];
oemhook[0] = (byte) 0xBB;
oemhook[1] = (byte) 0x55;
sendRequest(oemhook, EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE);
mRespText.setText("");
break;
case R.id.radio_api3:
// Send OEM notification (just echo the data bytes)
Expand All @@ -129,11 +131,22 @@ public void execRIL(View view) {
oemhook[4] = (byte) 0x78;
oemhook[5] = (byte) 0x9A;
oemhook[6] = (byte) 0xBC;
sendRequest(oemhook, EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE);
mRespText.setText("");
break;
case R.id.radio_api4:
// Send OEM command string
String[] oemhookstring = {"UNIAT",
((EditText) findViewById(R.id.edit_cmdstr)).getText().toString() + "\r" };
msg = mHandler.obtainMessage(EVENT_RIL_OEM_HOOK_CMDSTR_COMPLETE);
mPhone.invokeOemRilRequestStrings(oemhookstring, msg);
mRespText = (EditText) findViewById(R.id.edit_response);
mRespText.setText("---Wait response---");
break;
case R.id.radio_api5:

break;

case R.id.radio_api6:
// Ciphering Indicator
mCurrentSvcMode = OemCommands.OEM_SM_ENTER_MODE_MESSAGE;
mCurrentModeType = OemCommands.OEM_SM_TYPE_SUB_CIPHERING_PROTECTION_ENTER;
Expand All @@ -146,41 +159,12 @@ public void execRIL(View view) {
break;
}

if (idButtonChecked == R.id.radio_api5) {
byte[] data = mOemCommands.getEnterServiceModeData(mCurrentSvcMode, mCurrentModeType,
OemCommands.OEM_SM_ACTION);
sendRequest(data, ID_SERVICE_MODE_REQUEST);
} else if (idButtonChecked != R.id.radio_api4) {
Message msg = mHandler.obtainMessage(EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE);
mPhone.invokeOemRilRequestRaw(oemhook, msg);
mRespText.setText("");
} else {
// Copy string from EditText and add carriage return
String[] oemhookstring = { ((EditText) findViewById(R.id.edit_cmdstr)).getText().toString() + '\r' };

// Create message
Message msg = mHandler.obtainMessage(EVENT_RIL_OEM_HOOK_CMDSTR_COMPLETE);
// Send request
mPhone.invokeOemRilRequestStrings(oemhookstring, msg);
mRespText = (EditText) findViewById(R.id.edit_response);
mRespText.setText("---Wait response---");
}

/*
* if (idButtonChecked != R.id.radio_api4) { Message msg =
* mHandler.obtainMessage(EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE); getOemRilRequestRaw(oemhook, msg);
* mRespText.setText(""); } else { // Copy string from EditText and add carriage return String[] oemhookstring =
* { ((EditText) findViewById(R.id.edit_cmdstr)).getText().toString() + '\r' };
*
* // Create message Message msg = mHandler.obtainMessage(EVENT_RIL_OEM_HOOK_CMDSTR_COMPLETE); // Send request
* getOemRilRequestStrings(oemhookstring, msg); mRespText = (EditText) findViewById(R.id.edit_response);
* mRespText.setText("---Wait response---"); }
*/
}

private void logRilOemHookResponse(AsyncResult ar) {
log("received oem hook response");
String str = new String("");
String str = "";
mRespText = (EditText) findViewById(R.id.edit_response);

if (ar.exception != null) {
log("Exception:" + ar.exception);
Expand All @@ -206,6 +190,8 @@ private void logRilOemHookResponse(AsyncResult ar) {
str += "received NULL oem hook response";
}

mRespText.setText(str);

// Display message box
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(str);
Expand All @@ -216,23 +202,18 @@ private void logRilOemHookResponse(AsyncResult ar) {

private void logRilOemHookResponseString(AsyncResult ar) {
log("received oem hook string response");
String str = new String("");
mRespText = (EditText) findViewById(R.id.edit_response);

if (ar.exception != null) {
log("Exception:" + ar.exception);
str += "Exception:" + ar.exception + "\n\n";
Log.e(LOG_TAG, "", ar.exception);
return;
}

if (ar.result != null) {
String[] oemStrResponse = (String[]) ar.result;
int sizeStr = oemStrResponse.length;
log("oemResponseString[0] [" + oemStrResponse[0] + "]");
mRespText.setText("" + oemStrResponse[0]);
} else {
log("received NULL oem hook response");
mRespText.setText("No response or error received");
if (ar.result == null) {
Log.v(LOG_TAG, "No need to refresh.");
return;
}
String[] aos = (String[]) ar.result;

mListView.setAdapter(new ArrayAdapter<String>(ATRilHook.this, R.layout.list_item, aos));
}

private void log(String msg) {
Expand Down Expand Up @@ -322,9 +303,50 @@ public void handleMessage(Message msg) {
Log.v(LOG_TAG, "Service Mode End");
break;
case EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE:
log("EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE");
result = (AsyncResult) msg.obj;
logRilOemHookResponse(result);
if (result.exception != null) {
Log.e(LOG_TAG, "", result.exception);
return;
}
if (result.result == null) {
Log.v(LOG_TAG, "No need to refresh.");
return;
}
byte[] resp = (byte[]) result.result;

if (resp.length == 0) {
Log.v(LOG_TAG, "Length = 0");
return;
}

int resplines = resp.length / CHARS_PER_LINE;

if (mDisplay == null || mDisplay.length != resplines) {
Log.v(LOG_TAG, "New array = " + resplines);
mDisplay = new String[resplines];
}

for (int i = 0; i < resplines; i++) {
StringBuilder strb = new StringBuilder(CHARS_PER_LINE);
for (int j = 2; i < CHARS_PER_LINE; j++) {
int pos = i * CHARS_PER_LINE + j;
if (pos >= resp.length) {
Log.e(LOG_TAG, "Unexpected EOF");
break;
}
if (resp[pos] == 0) {
break;
}
strb.append((char) resp[pos]);
}
mDisplay[i] = strb.toString();
}

mListView.setAdapter(new ArrayAdapter<String>(ATRilHook.this, R.layout.list_item, mDisplay));

//log("EVENT_RIL_OEM_HOOK_CMDRAW_COMPLETE");
//result = (AsyncResult) msg.obj;
//logRilOemHookResponse(result);
break;
case EVENT_RIL_OEM_HOOK_CMDSTR_COMPLETE:
log("EVENT_RIL_OEM_HOOK_CMDSTR_COMPLETE");
Expand Down Expand Up @@ -361,8 +383,7 @@ public static void makeDefaultPhones() throws IllegalArgumentException {

get.invoke(null, params);

Toast toast = Toast.makeText(sContext, "makeDefaultPhones Completed!", Toast.LENGTH_SHORT);
toast.show();
Helpers.msgShort(sContext, "makeDefaultPhones Completed!");

} catch (IllegalArgumentException iAE) {
throw iAE;
Expand Down Expand Up @@ -452,8 +473,7 @@ public static Object getDefaultPhone() throws IllegalArgumentException {
Method get = PhoneFactory.getMethod("getDefaultPhone", (Class[]) null);
ret = get.invoke(null, (Object[]) null);

Toast toast = Toast.makeText(sContext, "getDefaultPhone Completed!", Toast.LENGTH_SHORT);
toast.show();
Helpers.msgShort(sContext, "getDefaultPhone Completed!");

} catch (IllegalArgumentException iAE) {
throw iAE;
Expand Down Expand Up @@ -487,8 +507,7 @@ public void getOemRilRequestRaw(byte[] oemhook, Message msg) throws IllegalArgum

// Process the response
get.invoke(PhoneFactory, params);
Toast toast = Toast.makeText(sContext, "invoke OemRilRequestRaw Completed!", Toast.LENGTH_SHORT);
toast.show();
Helpers.msgShort(sContext, "invoke OemRilRequestRaw Completed!");

} catch (IllegalArgumentException iAE) {
throw iAE;
Expand Down Expand Up @@ -520,8 +539,8 @@ public void getOemRilRequestStrings(String[] oemhook, Message msg) throws Illega

// Process the response
get.invoke(PhoneFactory, params);
Toast toast = Toast.makeText(sContext, "invoke OemRilRequestStrings Completed!", Toast.LENGTH_SHORT);
toast.show();
Helpers.msgShort(sContext, "invoke OemRilRequestStrings Completed!");

} catch (IllegalArgumentException iAE) {
throw iAE;
} catch (Exception e) {
Expand Down
Loading

0 comments on commit 8def9eb

Please sign in to comment.