gpt4 book ai didi

jadx.core.utils.files.ZipSecurity.isValidZipEntry()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-13 10:17:41 31 4
gpt4 key购买 nike

本文整理了Java中jadx.core.utils.files.ZipSecurity.isValidZipEntry()方法的一些代码示例,展示了ZipSecurity.isValidZipEntry()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZipSecurity.isValidZipEntry()方法的具体详情如下:
包路径:jadx.core.utils.files.ZipSecurity
类名称:ZipSecurity
方法名:isValidZipEntry

ZipSecurity.isValidZipEntry介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

private void loadFile(List<ResourceFile> list, File file) {
  if (file == null) {
    return;
  }
  try (ZipFile zip = new ZipFile(file)) {
    Enumeration<? extends ZipEntry> entries = zip.entries();
    while (entries.hasMoreElements()) {
      ZipEntry entry = entries.nextElement();
      if (ZipSecurity.isValidZipEntry(entry)) {
        addEntry(list, file, entry);
      }
    }
  } catch (Exception e) {
    LOG.debug("Not a zip file: {}", file.getAbsolutePath());
    addResourceFile(list, file);
  }
}

代码示例来源:origin: skylot/jadx

public void load(File input) throws IOException, DecodeException {
  String name = input.getName();
  try (InputStream inputStream = new FileInputStream(input)) {
    if (name.endsWith(CLST_EXTENSION)) {
      load(inputStream);
    } else if (name.endsWith(".jar")) {
      try (ZipInputStream in = new ZipInputStream(inputStream)) {
        ZipEntry entry = in.getNextEntry();
        while (entry != null) {
          if (entry.getName().endsWith(CLST_EXTENSION) && ZipSecurity.isValidZipEntry(entry)) {
            load(in);
          }
          entry = in.getNextEntry();
        }
      }
    } else {
      throw new JadxRuntimeException("Unknown file format: " + name);
    }
  }
}

代码示例来源:origin: skylot/jadx

@Override
  public String getContent() {
    try {
      ResourceFile.ZipRef zipRef = rf.getZipRef();
      if (zipRef == null) {
        File file = new File(rf.getName());
        try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
          return CertificateManager.decode(inputStream);
        }
      } else {
        try (ZipFile zipFile = new ZipFile(zipRef.getZipFile())) {
          ZipEntry entry = zipFile.getEntry(zipRef.getEntryName());
          if (entry == null) {
            throw new IOException("Zip entry not found: " + zipRef);
          }
          if (!ZipSecurity.isValidZipEntry(entry)) {
            return null;
          }
          try (InputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry))) {
            return CertificateManager.decode(inputStream);
          }
        }
      }
    } catch (Exception e) {
      LOG.error("Certificate decode error: {}", rf.getName(), e);
      return "Decode error: " + e.getMessage();
    }
  }
}

代码示例来源:origin: skylot/jadx

public static <T> T decodeStream(ResourceFile rf, ResourceDecoder<T> decoder) throws JadxException {
  try {
    ZipRef zipRef = rf.getZipRef();
    if (zipRef == null) {
      File file = new File(rf.getName());
      try (InputStream inputStream = new BufferedInputStream(new FileInputStream(file))) {
        return decoder.decode(file.length(), inputStream);
      }
    } else {
      try (ZipFile zipFile = new ZipFile(zipRef.getZipFile())) {
        ZipEntry entry = zipFile.getEntry(zipRef.getEntryName());
        if (entry == null) {
          throw new IOException("Zip entry not found: " + zipRef);
        }
        if (!ZipSecurity.isValidZipEntry(entry)) {
          return null;
        }
        try (InputStream inputStream = new BufferedInputStream(zipFile.getInputStream(entry))) {
          return decoder.decode(entry.getSize(), inputStream);
        }
      }
    }
  } catch (Exception e) {
    throw new JadxException("Error decode: " + rf.getName(), e);
  }
}

代码示例来源:origin: skylot/jadx

for (Enumeration<? extends ZipEntry> e = zf.entries(); e.hasMoreElements(); ) {
  ZipEntry entry = e.nextElement();
  if (!ZipSecurity.isValidZipEntry(entry)) {
    continue;

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com