@@ -45,16 +45,18 @@ public class MainActivity extends AppCompatActivity implements Handler.Callback
4545 AutoCompleteTextView autoCompleteTextView ;
4646 EditText libPath ;
4747 CheckBox autoLaunchBox ;
48+ CheckBox ptraceBox ;
49+ CheckBox ldpreloadBox ;
50+ TextView archText ;
4851 TextView console ;
4952 Button githubButton ;
50- Button tutorialButton ;
53+ Button uninjectButton ;
5154 Button injectButton ;
52- TextView archText ;
5355
5456 ArrayAdapter <String > adapterItems ;
5557
56- public String packageName ;
57- public String finalLibPath ;
58+ public String packageName = "" ;
59+ public String finalLibPath = "" ;
5860 public String launchActivity ;
5961 public boolean shouldAutoLaunch = true ;
6062
@@ -84,11 +86,13 @@ protected void onCreate(Bundle savedInstanceState) {
8486 autoCompleteTextView = findViewById (R .id .auto_complete_txt );
8587 libPath = findViewById (R .id .path_to_lib );
8688 githubButton = findViewById (R .id .github_button );
87- tutorialButton = findViewById (R .id .tutorial_button );
89+ uninjectButton = findViewById (R .id .tutorial_button );
8890 injectButton = findViewById (R .id .inject_button );
8991 autoLaunchBox = findViewById (R .id .auto_launch_toggle );
92+ ptraceBox = findViewById (R .id .mode_ptrace );
93+ ldpreloadBox = findViewById (R .id .mode_ldpreload );
94+ archText = findViewById (R .id .architecture );
9095 console = findViewById (R .id .console );
91- archText = findViewById (R .id .arch );
9296
9397 //Set installed packages
9498 adapterItems = new ArrayAdapter <String >(this , R .layout .list_item , getInstalledApps ());
@@ -99,47 +103,77 @@ public void onItemClick(AdapterView<?> parent, View view, int position, long id)
99103 String item = parent .getItemAtPosition (position ).toString ();
100104 packageName = item ;
101105 console .append ("Package Name: " + item + "\n " );
106+ String arch = "Unknown" ;
107+
108+ try {
109+ String libraryDir = getPackageManager ().getApplicationInfo (packageName , 0 ).nativeLibraryDir ;
110+ arch = libraryDir .substring (libraryDir .lastIndexOf ("/" ) + 1 );
111+ } catch (PackageManager .NameNotFoundException exception ) {
112+ exception .printStackTrace ();
113+ }
114+
115+ archText .setText ("Architecture: " + arch );
102116 }
103117 });
104118
105119 libPath .setText ("/data/local/tmp/libnative.so" ); //Set default path
106- archText . setText ( Build .CPU_ABI .toString ());
120+ console . append ( "Device Architecture: " + Build .CPU_ABI .toString () + " \n " );
107121
108122 injectButton .setOnClickListener (new View .OnClickListener () {
109123 @ Override
110124 public void onClick (View v ) {
125+ checkLibPath ();
111126 if (hasRootAccess ) {
112- MSGConnection mSGConnection = messageConnection ;
113- if (mSGConnection == null ) {
114- console .append ("Binding root services\n " );
115-
116- shouldAutoLaunch = autoLaunchBox .isChecked ();
117- launchActivity = getLaunchActivity (packageName );
118- checkLibPath ();
119-
120- console .append ("---------------------------------------\n " );
121- console .append ("Trying to Inject with following settings: \n " );
122- console .append ("shouldAutoLaunch: " + shouldAutoLaunch + "\n " );
123- console .append ("packageName: " + packageName + "\n " );
124- console .append ("launchActivity: " + launchActivity + "\n " );
125- console .append ("finalLibPath: " + finalLibPath + "\n " );
126- console .append ("---------------------------------------\n " );
127- RootService .bind (new Intent (thisInstance , RootService .class ), new MSGConnection ());
127+ if (packageName .equals ("" ) || finalLibPath .equals ("" )) {
128+ console .append ("Please fill out all the fields\n " );
128129 } else {
129- RootService .unbind (mSGConnection );
130+ if (ptraceBox .isChecked ()) {
131+ MSGConnection mSGConnection = messageConnection ;
132+ if (mSGConnection == null ) {
133+ console .append ("Binding root services\n " );
134+
135+ shouldAutoLaunch = autoLaunchBox .isChecked ();
136+ launchActivity = getLaunchActivity (packageName );
137+
138+ console .append ("---------------------------------------\n " );
139+ console .append ("Trying to Inject with following settings: \n " );
140+ console .append ("shouldAutoLaunch: " + shouldAutoLaunch + "\n " );
141+ console .append ("packageName: " + packageName + "\n " );
142+ console .append ("launchActivity: " + launchActivity + "\n " );
143+ console .append ("finalLibPath: " + finalLibPath + "\n " );
144+ console .append ("---------------------------------------\n " );
145+ RootService .bind (new Intent (thisInstance , RootService .class ), new MSGConnection ());
146+ } else {
147+ RootService .unbind (mSGConnection );
148+ }
149+ } else if (ldpreloadBox .isChecked ()) {
150+ if (packageName .equals ("" ) || finalLibPath .equals ("" )) {
151+ console .append ("Please fill out all the fields\n " );
152+ } else {
153+ String command = "setprop wrap." + packageName + " LD_PRELOAD=" + finalLibPath ;
154+ Shell .cmd (command ).exec ();
155+ Toast .makeText (thisInstance , "Injected! The game might take longer to load" , Toast .LENGTH_LONG ).show ();
156+ }
157+ } else {
158+ console .append ("You need to select an Injection mode \n " );
159+ }
130160 }
131161 } else {
132162 console .append ("Bind root service failed: root access not granted\n " );
133163 }
134164 }
135165 });
136166
137- tutorialButton .setOnClickListener (new View .OnClickListener () {
167+ uninjectButton .setOnClickListener (new View .OnClickListener () {
138168 @ Override
139169 public void onClick (View v ) {
140- Toast .makeText (thisInstance , "No tutorial yet :(" , Toast .LENGTH_LONG ).show ();
141- //Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://github.com/reveny"));
142- //startActivity(browserIntent);
170+ if (packageName .isEmpty ()) {
171+ console .append ("Cannot uninject without a package name\n " );
172+ } else {
173+ String command = "resetprop --delete wrap." + packageName ;
174+ Shell .cmd (command ).exec ();
175+ Toast .makeText (thisInstance , "Uninjected!" , Toast .LENGTH_LONG ).show ();
176+ }
143177 }
144178 });
145179
0 commit comments