Skip to content

Commit c2b2a45

Browse files
committed
AT Command Injection Started, Code Cleanup/Updates, Java 1.7 Language Updates
Extension of the Samsung MultiRil to attempt hooking of the OemHookStrings method, presently I am not 100% certain this will work but the basic framework and extensions have been made to modify the current implementation to deal with the Strings request data and responses. This still requires work and as such is currently disabled until further testing has been completed as it will cause the socket to disconnect. Huge code cleanup and updates to a number of areas with optimisations across a large number of packages, some unused imports removed and code comments added to a variety of methods. Addressed a number of possible NPE causes through different parts of the application which will ultimately provide better stability and an increased user experience, although in saying that these items were not causing any issues that had been reported but prevention is better then a cure right?!?! :) Use of Java 1.7 language rules have further allowed updates to take advantage of the highler langauge level with removal of explicit types within arrays, lists, maps etc plus other changes. Unnecessary compatibility library removed which has resulted in a reduction in size of the APK. Reversed the previous change to insert the Cell ID and Lac in Hex format to allow further time to ensure all methods that utilise these variables to be updated, the original change was made too quickly and resulted in a number of issues so I have returned to the standard integer format until I have more time to ensure this change is implemented correctly.
1 parent 90a7402 commit c2b2a45

24 files changed

+798
-308
lines changed

app/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ android {
3333

3434
dependencies {
3535
compile files('libs/opencsv-2.3.jar')
36-
compile 'com.android.support:appcompat-v7:19.1.+'
37-
compile 'com.google.android.gms:play-services:4.3.23'
36+
compile 'com.google.android.gms:play-services:4.4.52'
3837
compile 'com.android.support:support-v4:19.+'
3938
}

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="com.SecUpwN.AIMSICD"
4-
android:versionCode="15"
5-
android:versionName="0.1.15" >
4+
android:versionCode="16"
5+
android:versionName="0.1.16" >
66

77
<uses-feature
88
android:glEsVersion="0x00020000"

app/src/main/java/com/SecUpwN/AIMSICD/AIMSICD.java

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.SecUpwN.AIMSICD.activities.MapViewer;
5252
import com.SecUpwN.AIMSICD.activities.PrefActivity;
5353
import com.SecUpwN.AIMSICD.fragments.AboutFragment;
54+
import com.SecUpwN.AIMSICD.fragments.AtCommandFragment;
5455
import com.SecUpwN.AIMSICD.fragments.CellInfoFragment;
5556
import com.SecUpwN.AIMSICD.fragments.DbViewerFragment;
5657
import com.SecUpwN.AIMSICD.fragments.DeviceFragment;
@@ -61,7 +62,6 @@
6162
import org.apache.http.HttpResponse;
6263
import org.apache.http.HttpStatus;
6364
import org.apache.http.StatusLine;
64-
import org.apache.http.client.ClientProtocolException;
6565
import org.apache.http.client.HttpClient;
6666
import org.apache.http.client.methods.HttpGet;
6767
import org.apache.http.impl.client.DefaultHttpClient;
@@ -81,9 +81,6 @@ public class AIMSICD extends FragmentActivity {
8181

8282
private final String TAG = "AIMSICD";
8383

84-
private MyFragmentPagerAdapter mMyFragmentPagerAdapter;
85-
private ViewPager mViewPager;
86-
8784
private final Context mContext = this;
8885
private boolean mBound;
8986
private SharedPreferences prefs;
@@ -110,9 +107,10 @@ public void onCreate(Bundle savedInstanceState) {
110107
startService(intent);
111108
bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
112109

113-
mMyFragmentPagerAdapter = new MyFragmentPagerAdapter(getSupportFragmentManager());
114-
mViewPager = (ViewPager)findViewById(R.id.viewPager);
115-
mViewPager.setAdapter(mMyFragmentPagerAdapter);
110+
MyFragmentPagerAdapter myFragmentPagerAdapter = new MyFragmentPagerAdapter(
111+
getSupportFragmentManager());
112+
ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
113+
viewPager.setAdapter(myFragmentPagerAdapter);
116114

117115
prefs = mContext.getSharedPreferences(
118116
AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
@@ -209,31 +207,45 @@ public boolean onPrepareOptionsMenu(Menu menu) {
209207
MenuItem mTrackFemtocell = menu.findItem(R.id.track_femtocell);
210208

211209
if (mBound && mAimsicdService.isTrackingCell()) {
212-
mTrackCell.setTitle(R.string.untrack_cell);
213-
mTrackCell.setIcon(R.drawable.track_cell);
210+
if (mTrackCell != null) {
211+
mTrackCell.setTitle(R.string.untrack_cell);
212+
mTrackCell.setIcon(R.drawable.track_cell);
213+
}
214214
} else {
215-
mTrackCell.setTitle(R.string.track_cell);
216-
mTrackCell.setIcon(R.drawable.untrack_cell);
215+
if (mTrackCell != null) {
216+
mTrackCell.setTitle(R.string.track_cell);
217+
mTrackCell.setIcon(R.drawable.untrack_cell);
218+
}
217219
}
218220

219221
if (mBound && mAimsicdService.isTrackingLocation()) {
220-
mTrackLocation.setTitle(R.string.untrack_location);
221-
mTrackLocation.setIcon(R.drawable.ic_action_location_found);
222+
if (mTrackLocation != null) {
223+
mTrackLocation.setTitle(R.string.untrack_location);
224+
mTrackLocation.setIcon(R.drawable.ic_action_location_found);
225+
}
222226
} else {
223-
mTrackLocation.setTitle(R.string.track_location);
224-
mTrackLocation.setIcon(R.drawable.ic_action_location_off);
227+
if (mTrackLocation != null) {
228+
mTrackLocation.setTitle(R.string.track_location);
229+
mTrackLocation.setIcon(R.drawable.ic_action_location_off);
230+
}
225231
}
226232

227233
if (mBound && mAimsicdService.getPhoneID() == TelephonyManager.PHONE_TYPE_CDMA) {
228234
if (mBound && mAimsicdService.isTrackingFemtocell()) {
229-
mTrackFemtocell.setTitle(R.string.untrack_femtocell);
230-
mTrackFemtocell.setIcon(R.drawable.ic_action_network_cell);
235+
if (mTrackFemtocell != null) {
236+
mTrackFemtocell.setTitle(R.string.untrack_femtocell);
237+
mTrackFemtocell.setIcon(R.drawable.ic_action_network_cell);
238+
}
231239
} else {
232-
mTrackFemtocell.setTitle(R.string.track_femtocell);
233-
mTrackFemtocell.setIcon(R.drawable.ic_action_network_cell_not_tracked);
240+
if (mTrackFemtocell != null) {
241+
mTrackFemtocell.setTitle(R.string.track_femtocell);
242+
mTrackFemtocell.setIcon(R.drawable.ic_action_network_cell_not_tracked);
243+
}
234244
}
235245
} else {
236-
mTrackFemtocell.setVisible(false);
246+
if (mTrackFemtocell != null) {
247+
mTrackFemtocell.setVisible(false);
248+
}
237249
}
238250

239251
return super.onPrepareOptionsMenu(menu);
@@ -391,12 +403,12 @@ private Boolean isNetAvailable(Context context) {
391403
NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
392404
NetworkInfo mobileInfo =
393405
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
394-
if (wifiInfo.isConnected() || mobileInfo.isConnected()) {
395-
return true;
406+
if (wifiInfo != null && mobileInfo != null) {
407+
return wifiInfo.isConnected() || mobileInfo.isConnected();
396408
}
397409
}
398410
catch(Exception e){
399-
e.printStackTrace();
411+
Log.e(TAG, "isNetAvailable " + e);
400412
}
401413
return false;
402414
}
@@ -463,8 +475,6 @@ protected String doInBackground(String... uri) {
463475
response.getEntity().getContent().close();
464476
throw new IOException(statusLine.getReasonPhrase());
465477
}
466-
} catch (ClientProtocolException e) {
467-
//TODO Handle problems..
468478
} catch (IOException e) {
469479
//TODO Handle problems..
470480
}
@@ -506,17 +516,19 @@ protected void onPostExecute(String result) {
506516

507517

508518
class MyFragmentPagerAdapter extends FragmentPagerAdapter {
509-
private List<Fragment> fragments;
510-
private List<String> titles;
519+
private final List<Fragment> fragments;
520+
private final List<String> titles;
511521

512522
public MyFragmentPagerAdapter(FragmentManager fm) {
513523
super(fm);
514-
this.fragments = new ArrayList<Fragment>();
515-
titles = new ArrayList<String>();
524+
this.fragments = new ArrayList<>();
525+
titles = new ArrayList<>();
516526
fragments.add(new DeviceFragment());
517527
titles.add(getString(R.string.device_info));
518528
fragments.add(new CellInfoFragment());
519529
titles.add(getString(R.string.cell_info_title));
530+
fragments.add(new AtCommandFragment());
531+
titles.add(getString(R.string.at_command_title));
520532
fragments.add(new DbViewerFragment());
521533
titles.add(getString(R.string.db_viewer));
522534
fragments.add(new AboutFragment());

app/src/main/java/com/SecUpwN/AIMSICD/activities/MapViewer.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,11 @@ public class MapViewer extends FragmentActivity implements OnSharedPreferenceCha
7777
private final String TAG = "AIMSICD_MapViewer";
7878

7979
private GoogleMap mMap;
80-
private UiSettings mUiSettings;
80+
8181
private AIMSICDDbAdapter mDbHelper;
8282
private Context mContext;
8383
private LatLng loc = null;
8484
private SharedPreferences prefs;
85-
private String mapTypePref;
8685

8786
/**
8887
* Called when the activity is first created.
@@ -106,7 +105,7 @@ public void onCreate(Bundle savedInstanceState) {
106105
mDbHelper = new AIMSICDDbAdapter(this);
107106
loadEntries();
108107
mContext = this;
109-
mapTypePref = getResources().getString(R.string.pref_map_type_key);
108+
String mapTypePref = getResources().getString(R.string.pref_map_type_key);
110109
prefs = mContext.getSharedPreferences(
111110
AimsicdService.SHARED_PREFERENCES_BASENAME, 0);
112111
if (prefs.contains(mapTypePref)) {
@@ -157,14 +156,14 @@ private void setUpMapIfNeeded() {
157156
// Check if we were successful in obtaining the map.
158157
if (mMap != null) {
159158
// The Map is verified. It is now safe to manipulate the map.
160-
mUiSettings = mMap.getUiSettings();
161-
mUiSettings.setZoomControlsEnabled(true);
162-
mUiSettings.setCompassEnabled(true);
163-
mUiSettings.setMyLocationButtonEnabled(true);
164-
mUiSettings.setScrollGesturesEnabled(true);
165-
mUiSettings.setZoomGesturesEnabled(true);
166-
mUiSettings.setTiltGesturesEnabled(true);
167-
mUiSettings.setRotateGesturesEnabled(true);
159+
UiSettings uiSettings = mMap.getUiSettings();
160+
uiSettings.setZoomControlsEnabled(true);
161+
uiSettings.setCompassEnabled(true);
162+
uiSettings.setMyLocationButtonEnabled(true);
163+
uiSettings.setScrollGesturesEnabled(true);
164+
uiSettings.setZoomGesturesEnabled(true);
165+
uiSettings.setTiltGesturesEnabled(true);
166+
uiSettings.setRotateGesturesEnabled(true);
168167
mMap.setMyLocationEnabled(true);
169168
} else {
170169
Helpers.sendMsg(this, "Unable to create map!");
@@ -441,8 +440,8 @@ private Boolean isNetAvailable(Context context) {
441440
NetworkInfo wifiInfo = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);
442441
NetworkInfo mobileInfo =
443442
connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE);
444-
if (wifiInfo.isConnected() || mobileInfo.isConnected()) {
445-
return true;
443+
if (wifiInfo != null && mobileInfo != null) {
444+
return wifiInfo.isConnected() || mobileInfo.isConnected();
446445
}
447446
}
448447
catch(Exception e){

app/src/main/java/com/SecUpwN/AIMSICD/adapters/AIMSICDDbAdapter.java

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.SecUpwN.AIMSICD.adapters;
22

33
import com.SecUpwN.AIMSICD.R;
4-
import com.SecUpwN.AIMSICD.rilexecutor.HexDump;
54

65
import android.app.AlertDialog;
76
import android.content.ContentValues;
@@ -19,7 +18,6 @@
1918
import java.io.FileReader;
2019
import java.io.FileWriter;
2120
import java.io.InputStream;
22-
import java.util.Date;
2321
import java.util.List;
2422

2523
import au.com.bytecode.opencsv.CSVReader;
@@ -31,7 +29,7 @@ public class AIMSICDDbAdapter {
3129

3230
private final DbHelper mDbHelper;
3331
private SQLiteDatabase mDb;
34-
private Context mContext;
32+
private final Context mContext;
3533
private static final int DATABASE_VERSION = 4;
3634
private static final String COLUMN_ID = "_id";
3735
private final String LOCATION_TABLE = "locationinfo";
@@ -55,42 +53,6 @@ public void close() {
5553
mDbHelper.close();
5654
}
5755

58-
/**
59-
* Location Tracking Database
60-
*/
61-
private final String LOC_DATABASE_CREATE = "create table " +
62-
LOCATION_TABLE + " (" + COLUMN_ID +
63-
" integer primary key autoincrement, Lac INTEGER, CellID INTEGER, " +
64-
"Net VARCHAR, Lat VARCHAR, Lng VARCHAR, Signal INTEGER, Connection VARCHAR, " +
65-
"Timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp);";
66-
67-
/**
68-
* Cell Information Tracking Database
69-
*/
70-
private final String CELL_DATABASE_CREATE = "create table " +
71-
CELL_TABLE + " (" + COLUMN_ID +
72-
" integer primary key autoincrement, Lac INTEGER, CellID INTEGER, " +
73-
"Net VARCHAR, Lat VARCHAR, Lng VARCHAR, Signal INTEGER, Connection VARCHAR, " +
74-
"Country VARCHAR, Operator VARCHAR, OperatorName VARCHAR, " +
75-
"Timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp);";
76-
77-
/**
78-
* OpenCellID Cell Information Database
79-
*/
80-
private final String OPENCELLID_DATABASE_CREATE = "create table " +
81-
OPENCELLID_TABLE + " (" + COLUMN_ID +
82-
" integer primary key autoincrement, Lat VARCHAR, Lng VARCHAR, Mcc INTEGER, " +
83-
"Mnc INTEGER, Lac INTEGER, CellID INTEGER, AvgSigStr INTEGER, Samples INTEGER, " +
84-
"Timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp);";
85-
86-
/**
87-
* Default MCC Location Database
88-
*/
89-
private final String DEFAULT_MCC_DATABASE_CREATE = "create table " +
90-
DEFAULT_MCC_TABLE + " (" + COLUMN_ID +
91-
" integer primary key autoincrement, Country VARCHAR, Mcc INTEGER, "
92-
+ "Lat VARCHAR, Lng VARCHAR);";
93-
9456
/**
9557
* Inserts Cell Details into Database
9658
*
@@ -104,8 +66,8 @@ public long insertCell( int lac, int cellID,
10466
if (cellID != -1) {
10567
//Populate Content Values for Insert or Update
10668
ContentValues cellValues = new ContentValues();
107-
cellValues.put("Lac", HexDump.toHexString(lac));
108-
cellValues.put("CellID", HexDump.toHexString(cellID));
69+
cellValues.put("Lac", lac);
70+
cellValues.put("CellID", cellID);
10971
cellValues.put("Net", netType);
11072
cellValues.put("Lat", latitude);
11173
cellValues.put("Lng", longitude);
@@ -166,8 +128,8 @@ public long insertLocation(int lac, int cellID,
166128
if (latitude != 0.0 && longitude != 0.0) {
167129
//Populate Content Values for Insert or Update
168130
ContentValues locationValues = new ContentValues();
169-
locationValues.put("Lac", HexDump.toHexString(lac));
170-
locationValues.put("CellID", HexDump.toHexString(cellID));
131+
locationValues.put("Lac", lac);
132+
locationValues.put("CellID", cellID);
171133
locationValues.put("Net", netType);
172134
locationValues.put("Lat", latitude);
173135
locationValues.put("Lng", longitude);
@@ -224,7 +186,7 @@ public Cursor getDefaultMccLocationData() {
224186
/**
225187
* Checks to see if Location already exists in database
226188
*/
227-
public boolean locationExists(int cellID) {
189+
boolean locationExists(int cellID) {
228190
Cursor cursor = mDb.rawQuery("SELECT * FROM " + LOCATION_TABLE + " WHERE CellID = " +
229191
cellID, null);
230192

@@ -234,7 +196,7 @@ public boolean locationExists(int cellID) {
234196
/**
235197
* Checks to see if Cell already exists in database
236198
*/
237-
public boolean cellExists(int cellID) {
199+
boolean cellExists(int cellID) {
238200
Cursor cursor = mDb.rawQuery("SELECT * FROM " + CELL_TABLE + " WHERE CellID = " +
239201
cellID, null);
240202

@@ -244,7 +206,7 @@ public boolean cellExists(int cellID) {
244206
/**
245207
* Checks to see if Cell already exists in OpenCellID database
246208
*/
247-
public boolean openCellExists(int cellID) {
209+
boolean openCellExists(int cellID) {
248210
Cursor cursor = mDb.rawQuery("SELECT * FROM " + OPENCELLID_TABLE + " WHERE CellID = " +
249211
cellID, null);
250212

@@ -381,10 +343,50 @@ public class DbHelper extends SQLiteOpenHelper {
381343

382344
@Override
383345
public void onCreate(SQLiteDatabase database) {
346+
/*
347+
* Location Tracking Database
348+
*/
349+
String LOC_DATABASE_CREATE = "create table " +
350+
LOCATION_TABLE + " (" + COLUMN_ID +
351+
" integer primary key autoincrement, Lac INTEGER, CellID INTEGER, " +
352+
"Net VARCHAR, Lat VARCHAR, Lng VARCHAR, Signal INTEGER, Connection VARCHAR, " +
353+
"Timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp);";
384354
database.execSQL(LOC_DATABASE_CREATE);
355+
356+
/*
357+
* Cell Information Tracking Database
358+
*/
359+
String CELL_DATABASE_CREATE = "create table " +
360+
CELL_TABLE + " (" + COLUMN_ID +
361+
" integer primary key autoincrement, Lac INTEGER, CellID INTEGER, " +
362+
"Net VARCHAR, Lat VARCHAR, Lng VARCHAR, Signal INTEGER, Connection VARCHAR, " +
363+
"Country VARCHAR, Operator VARCHAR, OperatorName VARCHAR, " +
364+
"Timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp);";
385365
database.execSQL(CELL_DATABASE_CREATE);
366+
367+
/*
368+
* OpenCellID Cell Information Database
369+
*/
370+
String OPENCELLID_DATABASE_CREATE = "create table " +
371+
OPENCELLID_TABLE + " (" + COLUMN_ID +
372+
" integer primary key autoincrement, Lat VARCHAR, Lng VARCHAR, Mcc INTEGER, " +
373+
"Mnc INTEGER, Lac INTEGER, CellID INTEGER, AvgSigStr INTEGER, Samples INTEGER, "
374+
+
375+
"Timestamp TIMESTAMP NOT NULL DEFAULT current_timestamp);";
386376
database.execSQL(OPENCELLID_DATABASE_CREATE);
377+
378+
/*
379+
* Default MCC Location Database
380+
*/
381+
String DEFAULT_MCC_DATABASE_CREATE = "create table " +
382+
DEFAULT_MCC_TABLE + " (" + COLUMN_ID +
383+
" integer primary key autoincrement, Country VARCHAR, Mcc INTEGER, "
384+
+ "Lat VARCHAR, Lng VARCHAR);";
387385
database.execSQL(DEFAULT_MCC_DATABASE_CREATE);
386+
387+
/*
388+
* Repopulate the default MCC location table
389+
*/
388390
populateDefaultMCC(database);
389391
}
390392

0 commit comments

Comments
 (0)