Jailbreaker.java 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. package de.nplusc.izc.senabitwiggler;
  2. import java.io.File;
  3. import java.io.IOException;
  4. public class Jailbreaker {
  5. private static String nvscmd = EntryPoint.BlueLabPath+"nvscmd";
  6. private static String pscli = EntryPoint.BlueLabPath+"pscli";
  7. private static String dfuunbuild = EntryPoint.BlueLabPath+"dfuunbuild";
  8. private static String dfubuild = EntryPoint.BlueLabPath+"dfubuild";
  9. private static String dfusign = EntryPoint.BlueLabPath+"dfusign";
  10. public static void dumpFlash(String file, File folder)
  11. {
  12. folder.mkdirs();
  13. File internaldump = new File(folder,file+"internal.xuv");
  14. File externaldump = new File(folder,file+"external.xuv");
  15. File externalpartitioned = new File(folder,file+"external.ptn");
  16. File psr = new File(folder,file+"psr");
  17. try {
  18. Utils.runTool(nvscmd,"-nvstype","int","dump",internaldump.getPath());
  19. Utils.runTool(nvscmd,"dump",externaldump.getPath());
  20. Utils.runTool(nvscmd,"dump",externalpartitioned.getPath());
  21. Utils.runTool(pscli,"dump",psr.getPath());
  22. } catch (IOException e) {
  23. e.printStackTrace();
  24. }
  25. }
  26. public static void jailbreak()
  27. {
  28. try {
  29. Utils.runTool(pscli,"merge",EntryPoint.APPDIR+File.separator+"jailbreak"+File.separator+"jailbreak.psr");
  30. } catch (IOException e) {
  31. e.printStackTrace();
  32. }
  33. }
  34. public static void resignDFU(String file, File outputFolder)
  35. {
  36. File scratch = new File(outputFolder,"temp");
  37. scratch.mkdirs();
  38. String dfuinput = new File(file).getAbsolutePath();
  39. String dfuname = new File(file).getName();
  40. String dfuout = new File(outputFolder,dfuname).getAbsolutePath();
  41. try {
  42. Utils.runTool(scratch,dfuunbuild,"-v","-f",dfuinput,"-o","extracted");
  43. Utils.runTool(scratch,dfusign,"-v", "-o","extracted0000signed.fs","-h","extracted0000.fs", "-ka",EntryPoint.APPDIR+File.separator+"jailbreak"+File.separator+"jailbreak.private.key");
  44. File oldfs = new File(scratch,"extracted0000.fs");
  45. oldfs.delete();
  46. File newfs = new File(scratch,"extracted0000signed.fs");
  47. newfs.renameTo(oldfs);
  48. Utils.runTool(scratch,dfubuild,"-c","extracted.cl","-f",dfuout);
  49. } catch (IOException e) {
  50. e.printStackTrace();
  51. }
  52. }
  53. }