Exemplo n.º 1
0
 public static String identFromRecognition() {
   Enumeration<Object> e = Devices.listDevices(true);
   if (!e.hasMoreElements()) {
     MyLogger.getLogger().error("No device is registered in Flashtool.");
     MyLogger.getLogger().error("You can only flash devices.");
     return "";
   }
   boolean found = false;
   Properties founditems = new Properties();
   founditems.clear();
   Properties buildprop = new Properties();
   buildprop.clear();
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     String prop = current.getBuildProp();
     if (!buildprop.containsKey(prop)) {
       String readprop = DeviceProperties.getProperty(prop);
       buildprop.setProperty(prop, readprop);
     }
     Iterator<String> i = current.getRecognitionList().iterator();
     String localdev = buildprop.getProperty(prop);
     while (i.hasNext()) {
       String pattern = i.next().toUpperCase();
       if (localdev.toUpperCase().equals(pattern)) {
         founditems.put(current.getId(), current.getName());
       }
     }
   }
   if (founditems.size() == 1) {
     return (String) founditems.keys().nextElement();
   } else return "";
 }
Exemplo n.º 2
0
 public static String getVariantName(String dev) {
   Enumeration<Object> e = Devices.listDevices(true);
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     if (current.getVariantList().contains(dev)) return current.getName() + " (" + dev + ")";
   }
   return dev;
 }
Exemplo n.º 3
0
 public static void doRoot() {
   Devices.waitForReboot(false);
   if (Devices.getCurrent().getVersion().contains("2.3")) {
     if (!Devices.getCurrent().hasRoot()) doRootzergRush();
     else MyLogger.getLogger().error("Your device is already rooted");
   } else if (!Devices.getCurrent().hasRoot()) doRootpsneuter();
   else MyLogger.getLogger().error("Your device is already rooted");
   exit();
 }
Exemplo n.º 4
0
  public static void registerPlugin(String type, String classname, String workdir) {
    try {

      Class<?> pluginClass = Class.forName(classname);
      Constructor<?> constr = pluginClass.getConstructor();
      PluginInterface pluginObject = (PluginInterface) constr.newInstance();
      pluginObject.setWorkdir(workdir);
      boolean aenabled = false;
      String aversion = Devices.getCurrent().getVersion();
      Enumeration<String> e1 = pluginObject.getCompatibleAndroidVersions();
      while (e1.hasMoreElements()) {
        String pversion = e1.nextElement();
        if (aversion.startsWith(pversion) || pversion.equals("any")) aenabled = true;
      }

      boolean kenabled = false;
      String kversion = Devices.getCurrent().getKernelVersion();
      Enumeration<String> e2 = pluginObject.getCompatibleKernelVersions();
      while (e2.hasMoreElements()) {
        String pversion = e2.nextElement();
        if (kversion.equals(pversion) || pversion.equals("any")) kenabled = true;
      }

      boolean denabled = false;
      if (type.equals("generic")) {
        String currdevid = Devices.getCurrent().getId();
        Enumeration<String> e3 = pluginObject.getCompatibleDevices();
        while (e3.hasMoreElements()) {
          String pversion = e3.nextElement();
          if (currdevid.equals(pversion) || pversion.equals("any")) denabled = true;
        }
      } else denabled = true;

      boolean hasroot = false;
      if (pluginObject.isRootNeeded()) hasroot = Devices.getCurrent().hasRoot();

      if (type.equals("device") && aenabled && kenabled && denabled && hasroot) {
        plugins.put(pluginObject.getName(), pluginObject);
      } else if (aenabled && kenabled && denabled && hasroot)
        plugins.put(pluginObject.getName(), pluginObject);
      Enumeration e = plugins.keys();
      while (e.hasMoreElements()) {
        String pname = (String) e.nextElement();
      }
    } catch (Exception e) {
      MyLogger.getLogger().error(e.getMessage());
    }
  }
Exemplo n.º 5
0
 public static void doBLUnlock() {
   try {
     Devices.waitForReboot(false);
     PluginInterface po = (PluginInterface) plugins.get("Bootloader Unlock");
     po.run();
   } catch (Exception e) {
     MyLogger.getLogger().error("The BootLoader Unlock plugin is not loaded");
   }
 }
Exemplo n.º 6
0
 protected IStatus run(IProgressMonitor monitor) {
   try {
     AdbUtility.push(bbpath, GlobalConfig.getProperty("deviceworkdir"));
     FTShell shell = new FTShell("busyhelper");
     shell.run(false);
     shell = new FTShell("instbusybox");
     shell.setProperty("BUSYBOXINSTALLPATH", Devices.getCurrent().getBusyBoxInstallPath());
     shell.runRoot();
     MyLogger.getLogger()
         .info(
             "Installed version of busybox : "
                 + Devices.getCurrent().getInstalledBusyboxVersion(true));
     MyLogger.getLogger().info("Finished");
     return Status.OK_STATUS;
   } catch (Exception e) {
     e.printStackTrace();
     MyLogger.getLogger().error(e.getMessage());
     return Status.CANCEL_STATUS;
   }
 }
Exemplo n.º 7
0
 public static void doRootpsneuter() {
   try {
     AdbUtility.push(
         Devices.getCurrent().getBusybox(false),
         GlobalConfig.getProperty("deviceworkdir") + "/busybox");
     Shell shell = new Shell("busyhelper");
     shell.run(true);
     AdbUtility.push(
         "." + fsep + "custom" + fsep + "root" + fsep + "psneuter.tar.uue",
         GlobalConfig.getProperty("deviceworkdir"));
     shell = new Shell("rootit");
     MyLogger.getLogger().info("Running part1 of Root Exploit, please wait");
     shell.run(false);
     Devices.waitForReboot(true);
     MyLogger.getLogger().info("Running part2 of Root Exploit");
     shell = new Shell("rootit2");
     shell.run(false);
     MyLogger.getLogger().info("Finished!.");
     MyLogger.getLogger().info("Root should be available after reboot!");
   } catch (Exception e) {
     MyLogger.getLogger().error(e.getMessage());
   }
 }
Exemplo n.º 8
0
 public static String getKernelVersion(boolean hasbusybox) {
   try {
     String result = "";
     if (!hasbusybox) {
       AdbUtility.push(
           Devices.getCurrent().getBusybox(false),
           GlobalConfig.getProperty("deviceworkdir") + "/busybox1",
           false);
       AdbUtility.run("chmod 755 " + GlobalConfig.getProperty("deviceworkdir") + "/busybox1");
       result = run(GlobalConfig.getProperty("deviceworkdir") + "/busybox1 uname -r");
       run("rm -r " + GlobalConfig.getProperty("deviceworkdir") + "/busybox1");
     } else result = run("busybox uname -r");
     return result;
   } catch (Exception e) {
     return "";
   }
 }
Exemplo n.º 9
0
 public static void addDevicesPlugins() {
   try {
     File dir = new File(Devices.getCurrent().getDeviceDir() + fsep + "features");
     File[] chld = dir.listFiles();
     MyLogger.getLogger().debug("Found " + chld.length + " device plugins to add");
     for (int i = 0; i < chld.length; i++) {
       if (chld[i].isDirectory()) {
         try {
           Properties p = new Properties();
           p.load(
               new FileInputStream(
                   new File(chld[i].getAbsolutePath() + fsep + "feature.properties")));
           MyLogger.getLogger().debug("Registering " + p.getProperty("classname"));
           ClassPath.addFile(chld[i].getAbsolutePath() + fsep + p.getProperty("plugin"));
           registerPlugin("device", p.getProperty("classname"), chld[i].getAbsolutePath());
         } catch (IOException ioe) {
         }
       }
     }
   } catch (Exception e) {
   }
 }
Exemplo n.º 10
0
 public static void doIdent() {
   Enumeration<Object> e = Devices.listDevices(true);
   if (!e.hasMoreElements()) {
     MyLogger.getLogger().error("No device is registered in Flashtool.");
     MyLogger.getLogger().error("You can only flash devices.");
     return;
   }
   boolean found = false;
   Properties founditems = new Properties();
   founditems.clear();
   Properties buildprop = new Properties();
   buildprop.clear();
   while (e.hasMoreElements()) {
     DeviceEntry current = Devices.getDevice((String) e.nextElement());
     String prop = current.getBuildProp();
     if (!buildprop.containsKey(prop)) {
       String readprop = DeviceProperties.getProperty(prop);
       buildprop.setProperty(prop, readprop);
     }
     Iterator<String> i = current.getRecognitionList().iterator();
     String localdev = buildprop.getProperty(prop);
     while (i.hasNext()) {
       String pattern = i.next().toUpperCase();
       if (localdev.toUpperCase().contains(pattern)) {
         founditems.put(current.getId(), current.getName());
       }
     }
   }
   if (founditems.size() == 1) {
     found = true;
     Devices.setCurrent((String) founditems.keys().nextElement());
     if (!Devices.isWaitingForReboot())
       MyLogger.getLogger().info("Connected device : " + Devices.getCurrent().getId());
   } else {
     MyLogger.getLogger().error("Cannot identify your device.");
     MyLogger.getLogger().error("You can only flash devices.");
   }
   if (found) {
     if (!Devices.isWaitingForReboot()) {
       MyLogger.getLogger()
           .info(
               "Installed version of busybox : "
                   + Devices.getCurrent().getInstalledBusyboxVersion());
       MyLogger.getLogger()
           .info(
               "Android version : "
                   + Devices.getCurrent().getVersion()
                   + " / kernel version : "
                   + Devices.getCurrent().getKernelVersion());
     }
     if (Devices.getCurrent().isRecovery()) {
       MyLogger.getLogger().info("Phone in recovery mode");
       if (!Devices.isWaitingForReboot()) MyLogger.getLogger().info("Root Access Allowed");
     } else {
       boolean hasSU = Devices.getCurrent().hasSU();
       if (hasSU) {
         boolean hasRoot = Devices.getCurrent().hasRoot();
         if (hasRoot)
           if (!Devices.isWaitingForReboot()) MyLogger.getLogger().info("Root Access Allowed");
       }
     }
     plugins.clear();
     addDevicesPlugins();
     addGenericPlugins();
     MyLogger.getLogger().debug("Stop waiting for device");
     if (Devices.isWaitingForReboot()) Devices.stopWaitForReboot();
     MyLogger.getLogger().debug("End of identification");
   }
 }
Exemplo n.º 11
0
 public String getInstalledBusyboxVersion(boolean force) {
   if (Devices.getCurrent().isBusyboxInstalled(force)) {
     return AdbUtility.getBusyboxVersion(getBusyBoxInstallPath());
   } else hasBusybox = false;
   return "N/A";
 }
Exemplo n.º 12
0
 public String getCustomDeviceDir() {
   return Devices.getCustomDevicesDir() + fsep + getId();
 }
Exemplo n.º 13
0
 public String getWorkDir() {
   return Devices.getDevicesDir() + fsep + getId() + fsep + "work";
 }
Exemplo n.º 14
0
 protected IStatus run(IProgressMonitor monitor) {
   try {
     DeviceEntry ent = new DeviceEntry(platform);
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + "cert.properties")
         .exists()) throw new Exception("cert.properties is missing");
     Properties p = new Properties();
     try {
       p.load(
           new FileInputStream(
               new File(
                   ent.getDeviceDir()
                       + File.separator
                       + "blu"
                       + File.separator
                       + "files"
                       + File.separator
                       + "cert.properties")));
     } catch (Exception ex) {
     }
     String bootwrite = "";
     Enumeration<Object> e = p.keys();
     while (e.hasMoreElements()) {
       String key = (String) e.nextElement();
       if (p.getProperty(key).equals(phonecert)) {
         bootwrite = key;
         break;
       }
     }
     if (bootwrite.length() == 0) throw new Exception("Phone certificate not identified");
     bootwrite = "bootwrite_" + bootwrite + "SL";
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + bootwrite)
         .exists()) throw new Exception(bootwrite + " is missing");
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + "fixPart")
         .exists()) throw new Exception("fixPart is missing");
     if (!new File(
             ent.getDeviceDir()
                 + File.separator
                 + "blu"
                 + File.separator
                 + "files"
                 + File.separator
                 + "mapper_2.6.29.ko")
         .exists()) throw new Exception("mapper_2.6.29.ko is missing");
     if (platform.equals("X10"))
       if (!new File(
               ent.getDeviceDir()
                   + File.separator
                   + "blu"
                   + File.separator
                   + "files"
                   + File.separator
                   + "mapper_2.6.29-00054-g5f01537.ko")
           .exists()) throw new Exception("mapper_2.6.29-00054-g5f01537.ko is missing");
     MyLogger.getLogger().info("Waiting for device to reboot");
     Devices.waitForReboot(false);
     if (!Devices.getCurrent().getKernelVersion().equals("2.6.29-00054-g5f01537")
         && !Devices.getCurrent().getKernelVersion().equals("2.6.29"))
       throw new Exception("Kernel does not match a compatible one");
     if (!Devices.getCurrent().hasRoot()) throw new Exception("Device must be rooted first");
     String mapper = "mapper_" + Devices.getCurrent().getKernelVersion() + ".ko";
     AdbUtility.push(
         ent.getDeviceDir()
             + File.separator
             + "blu"
             + File.separator
             + "files"
             + File.separator
             + "fixPart",
         GlobalConfig.getProperty("deviceworkdir"));
     FTShell fixpart =
         new FTShell(
             new File(
                 ent.getDeviceDir()
                     + File.separator
                     + "blu"
                     + File.separator
                     + "shells"
                     + File.separator
                     + "runfixPart"));
     String output = fixpart.runRoot();
     if (!output.contains("success")) throw new Exception("Error applying fixpart: " + output);
     MyLogger.getLogger().info("Successfully applied fixPart. Rebooting");
     Devices.getCurrent().reboot();
     Devices.waitForReboot(false);
     AdbUtility.push(
         ent.getDeviceDir()
             + File.separator
             + "blu"
             + File.separator
             + "files"
             + File.separator
             + mapper,
         GlobalConfig.getProperty("deviceworkdir"));
     AdbUtility.push(
         ent.getDeviceDir()
             + File.separator
             + "blu"
             + File.separator
             + "files"
             + File.separator
             + bootwrite,
         GlobalConfig.getProperty("deviceworkdir"));
     FTShell runbootwrite =
         new FTShell(
             new File(
                 ent.getDeviceDir()
                     + File.separator
                     + "blu"
                     + File.separator
                     + "shells"
                     + File.separator
                     + "runbootwrite"));
     runbootwrite.setProperty("KVER", Devices.getCurrent().getKernelVersion());
     runbootwrite.setProperty("BOOTWRITEBIN", bootwrite);
     output = runbootwrite.runRoot();
     if (!output.contains("success")) throw new Exception("Error applying fixpart: " + output);
     MyLogger.getLogger()
         .info("Successfully applied bootwrite. Bootloader should be unlocked. Rebooting");
     Devices.getCurrent().reboot();
     return Status.OK_STATUS;
   } catch (Exception e) {
     e.printStackTrace();
     MyLogger.getLogger().error(e.getMessage());
     return Status.CANCEL_STATUS;
   }
 }