public String decompileClassNode(ClassNode cn, byte[] b) {
    String fileStart = BytecodeViewer.tempDir.getAbsolutePath() + BytecodeViewer.fs + "temp";

    String start = MiscUtils.getUniqueName(fileStart, ".class");

    final File tempClass = new File(start + ".class");
    final File tempZip = new File(start + ".jar");
    final File tempDex = new File(start + ".dex");
    final File tempSmali = new File(start + "-smali"); // output directory

    try {
      final FileOutputStream fos = new FileOutputStream(tempClass);

      fos.write(b);

      fos.close();
    } catch (final IOException e) {
      new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
    }

    ZipUtil.packEntry(tempClass, tempZip);

    Dex2Jar.saveAsDex(tempZip, tempDex);

    try {
      org.jf.baksmali.main.main(
          new String[] {"-o", tempSmali.getAbsolutePath(), "-x", tempDex.getAbsolutePath()});
    } catch (Exception e) {
      new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
    }

    File outputSmali = null;

    boolean found = false;
    File current = tempSmali;
    while (!found) {
      File f = current.listFiles()[0];
      if (f.isDirectory()) current = f;
      else {
        outputSmali = f;
        found = true;
      }
    }
    try {
      return FileUtils.readFileToString(outputSmali, "UTF-8");
    } catch (Exception e) {
      new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
    }

    return null;
  }
  @Test
  public void testZIPFolder() {

    String pathToFolder = "C:\\PROJECTS\\ArtifactoryDeployTool\\ArtifactoryDeployTool";

    String pathToZIP = "C:\\PROJECTS\\ArtifactoryDeployTool\\ArtifactoryDeployTool.zip";

    ZipUtil.pack(new File(pathToFolder), new File(pathToZIP));
  }
Exemplo n.º 3
0
 public static void decodeResources(File input, File output) {
   try {
     Path temporaryDirectory = Files.createTempDirectory("apkresources");
     File directory = temporaryDirectory.toFile();
     Files.delete(temporaryDirectory);
     cmdDecode(input, directory);
     File original = new File(directory, "original");
     FileUtils.deleteDirectory(original);
     File apktool = new File(directory, "apktool.yml");
     apktool.delete();
     ZipUtil.pack(directory, output);
     FileUtils.deleteDirectory(directory);
   } catch (Exception e) {
     ExceptionHandler.handle(e);
   }
 }
  /** Déplace le dossier template de rapport du plugin dans le projet et le dezipe */
  private void copierTemplate() {
    String resourceName = "Resultat-HTML.zip";

    InputStream is = MutantReport.class.getResourceAsStream(resourceName);
    try {
      File target = new File("./target/" + resourceName);
      OutputStream os = new FileOutputStream(target);
      IOUtils.copy(is, os);
      ZipUtil.unpack(target, new File("target"));
      is.close();
      os.close();
      target.delete();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  public void generator(ProxyObject proxyObject) throws IOException, JAXBException {

    String apiDir = "/" + proxyObject.getApiBundleName() + "/" + "apiproxy";
    String apiProxyZip = proxyObject.getApiBundleLocation() + "/" + "apiproxy.zip";
    String proxyDir = apiDir + "/" + "proxies";
    String targetDir = apiDir + "/" + "targets";
    String policiesDir = apiDir + "/" + "policies";

    boolean success =
        (new File(proxyObject.getApiBundleLocation() + "/" + proxyObject.getApiBundleName()))
            .mkdir();
    (new File(proxyObject.getApiBundleLocation() + apiDir)).mkdir();
    (new File(proxyObject.getApiBundleLocation() + proxyDir)).mkdir();
    (new File(proxyObject.getApiBundleLocation() + targetDir)).mkdir();

    try {

      if (proxyObject.getSwaggerType().equalsIgnoreCase("n")) {
        GeneralProxyGenerator genProxy = new GeneralProxyGenerator(proxyObject);
        genProxy.createProxy();

      } else if (proxyObject.getSwaggerType().equalsIgnoreCase("y")) {
        ProxyGenerator proxy = new ProxyGenerator(proxyObject);
        proxy.createProxy();
      }

    } catch (IOException e) {
      e.printStackTrace();
    } catch (JAXBException e) {
      e.printStackTrace();
    }

    TargetGenerator target = new TargetGenerator(proxyObject);
    try {
      target.createTarget();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (JAXBException e) {
      e.printStackTrace();
    }

    ApplicationGenerator application = new ApplicationGenerator(proxyObject);
    try {
      application.createProxy();
    } catch (IOException e) {
      e.printStackTrace();
    } catch (JAXBException e) {
      e.printStackTrace();
    }

    if (proxyObject.isApplyProlicies()) {
      (new File(proxyObject.getApiBundleLocation() + policiesDir)).mkdir();

      PolicyGenerator policies = new PolicyGenerator(proxyObject);
      try {
        policies.createPolicies();
      } catch (IOException e) {
        e.printStackTrace();
      } catch (JAXBException e) {
        e.printStackTrace();
      }
    }

    String proxyDefault = proxyObject.getApiBundleLocation() + proxyDir + "/default.xml";
    String targetDefault = proxyObject.getApiBundleLocation() + targetDir + "/default.xml";

    String appfile =
        proxyObject.getApiBundleLocation()
            + "/"
            + apiDir
            + "/"
            + proxyObject.getApiBundleName()
            + ".xml";

    // Create a apiproxy.zip
    ZipUtil.pack(
        new File(proxyObject.getApiBundleLocation() + "/" + proxyObject.getApiBundleName() + "/"),
        new File(
            proxyObject.getApiBundleLocation()
                + "/"
                + proxyObject.getApiBundleName()
                + "/"
                + "apiproxy.zip"));
  }
Exemplo n.º 6
0
 public static void withUs() {
   ZipUtil.unpack(new File("demo.zip"), new File("demo"));
 }