如何实现apk、ipa包修改注入参数打子包
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,这篇文章主要讲解了"如何实现apk、ipa包修改注入参数打子包",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"如何实现apk、ipa包修改注入参数打子包
千家信息网最后更新 2026年11月02日如何实现apk、ipa包修改注入参数打子包
这篇文章主要讲解了"如何实现apk、ipa包修改注入参数打子包",文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习"如何实现apk、ipa包修改注入参数打子包"吧!
项目背景:做推广员系统,需要把平台包注入推广员参数,推广员拿子包去推广
安卓子包效果:
ios子包效果

package com.qipa.util;import java.io.*;import java.util.zip.ZipEntry;import java.util.zip.ZipInputStream;import java.util.zip.ZipOutputStream;/** * apk文件复制修改注入参数打子包,ipa包注入参数打子包 * author:LiuYunJie */public class SixChannel {private final static String CURSTOM_ID = "curstomId:[ci],platformId:[pi]";public static void main(String[] args) {// public static String curstomId = "SM1";// 盒子编号 // public static int platformId = 1; // 平台编号 try {// add_zip_entry("D:/游戏对接/母包/666Game-1.0.7-1904161815-release.apk", "d:/222", "D:/游戏对接/qq.txt"); add_zip_entry_ios("E:\\盒子\\package\\i\\g\\app0106.ipa", "E:\\盒子\\package\\i\\g\\s", 2323, "cyy2323", "1.0"); } catch (Exception e) {// TODO Auto-generated catch block e.printStackTrace(); } }/** * 增加目录 * * @param zip_file 母包文件 * @param file_path 子包目录 * @param text text文件,里面有推广员参数 * @throws Exception */ public static void add_zip_entry(String zip_file, String file_path, String text) throws Exception { String entry_name = "META-INF/six_sdk";long time = System.currentTimeMillis();if (zip_file == null)throw new RuntimeException("zip file name is null");if (zip_file.isEmpty())throw new RuntimeException("zip file name is empty");if (file_path == null)throw new RuntimeException("zip file name is null");if (file_path.isEmpty())throw new RuntimeException("zip file name is empty");// if (file_name == null) // throw new RuntimeException("zip file name is null"); // if (file_name.isEmpty()) // throw new RuntimeException("zip file name is empty"); // if (entry_name == null) // throw new RuntimeException("zip file name is null"); if (entry_name.isEmpty())throw new RuntimeException("zip file name is empty"); File file_z = new File(zip_file);if (!file_z.exists())throw new RuntimeException("zip file is not exists");// ZipEntry ze = new ZipEntry(entry_name); // File file = new File(file_path); // if (!file.exists()) // file.mkdirs(); // ZipOutputStream zos = new ZipOutputStream(new FileOutputStream( // file_path + "/" + file_name)); // zos.putNextEntry(ze); // zos.write(Base64.decode(SDKEncryption.encode(CURSTOM_ID.replace("[ci]", // "2225").replace("[pi]", "2"), 16), flags)); File file = new File(zip_file); String name = file.getName().split("\\.")[0]; BufferedReader br = new BufferedReader(new InputStreamReader(getInputStream(new FileInputStream(text))));while (true) { String channel = br.readLine();if (channel == null)break; channel = channel.trim();if (channel.length() == 0)continue; ZipEntry ze = new ZipEntry(entry_name); File file1 = new File(file_path);if (!file1.exists()) file1.mkdirs(); ZipOutputStream zos = new ZipOutputStream(new FileOutputStream( file_path + "/" + name + "_" + "ps_" + channel + ".apk")); zos.putNextEntry(ze); zos.write(CURSTOM_ID.replace("[ci]", channel).replace("[pi]", "1") .getBytes("utf-8")); zos.closeEntry(); ZipInputStream zis = new ZipInputStream(new FileInputStream( zip_file));while ((ze = zis.getNextEntry()) != null) {if (!ze.isDirectory()) { zos.putNextEntry(new ZipEntry(ze.getName()));int len = -1;byte[] b = new byte[1024];while ((len = zis.read(b)) > 0) { zos.write(b, 0, len); } zos.closeEntry(); zis.closeEntry(); } } zos.flush(); zos.close(); zis.close(); } br.close(); System.out.println("打包成功!"); System.out.println("time:" + (System.currentTimeMillis() - time)); }/** * 安卓通过母包打子包,返回子包文件名,文件里面写推广员参数 * * @param zip_file 母包文件 * @param file_path 子包目录 * @param agentParam 推广员参数 * @param newFileName 注入的标记文件名 * @param version 包的版本号 * @throws Exception * @return 返回子包文件名 */ public static String add_zip_entry_Android(String zip_file, String file_path, Integer agentParam, String newFileName, String version) throws Exception { String entry_name = "META-INF/" + newFileName;long time = System.currentTimeMillis();if (zip_file == null)throw new RuntimeException("zip file name is null");if (zip_file.isEmpty())throw new RuntimeException("zip file name is empty");if (file_path == null)throw new RuntimeException("zip file name is null");if (file_path.isEmpty())throw new RuntimeException("zip file name is empty");// if (file_name == null) // throw new RuntimeException("zip file name is null"); // if (file_name.isEmpty()) // throw new RuntimeException("zip file name is empty"); // if (entry_name == null) // throw new RuntimeException("zip file name is null"); if (entry_name.isEmpty())throw new RuntimeException("zip file name is empty"); File file_z = new File(zip_file);if (!file_z.exists())throw new RuntimeException("zip file is not exists");// ZipEntry ze = new ZipEntry(entry_name); // File file = new File(file_path); // if (!file.exists()) // file.mkdirs(); // ZipOutputStream zos = new ZipOutputStream(new FileOutputStream( // file_path + "/" + file_name)); // zos.putNextEntry(ze); // zos.write(Base64.decode(SDKEncryption.encode(CURSTOM_ID.replace("[ci]", // "2225").replace("[pi]", "2"), 16), flags)); File file = new File(zip_file); String name = file.getName().split("\\.")[0]; ZipEntry ze = new ZipEntry(entry_name); File file1 = new File(file_path);if (!file1.exists()) file1.mkdirs();//子包母包增加新文件 String subPackageName = name + "_" + "ps_" + agentParam + "_vs_" + version + ".apk"; ZipOutputStream zos = new ZipOutputStream(new FileOutputStream( file_path + "/" + subPackageName));//进入到META-INF zos.putNextEntry(ze);//写入参数 zos.write(CURSTOM_ID.replace("[ci]", agentParam.toString()).replace("[pi]", "1") .getBytes("utf-8")); zos.closeEntry(); ZipInputStream zis = new ZipInputStream(new FileInputStream( zip_file));while ((ze = zis.getNextEntry()) != null) {if (!ze.isDirectory()) { zos.putNextEntry(new ZipEntry(ze.getName()));int len = -1;byte[] b = new byte[1024];while ((len = zis.read(b)) > 0) { zos.write(b, 0, len); } zos.closeEntry(); zis.closeEntry(); } } zos.flush(); zos.close(); zis.close(); System.out.println("安卓打包成功!"); System.out.println("time:" + (System.currentTimeMillis() - time));return subPackageName; }/** * ios通过母包打子包,返回子包文件名 * * @param zip_file 母包文件 * @param file_path 子包目录 * @param agentParam 推广员参数 * @param newFileName 注入的标记文件名 * @param version 包的版本号 * @throws Exception * @return 子包名 */ public static String add_zip_entry_ios(String zip_file, String file_path, Integer agentParam, String newFileName, String version) throws Exception { String entry_name = "Payload/lhtx.app/" + newFileName + "/";//生成目录 long time = System.currentTimeMillis();if (zip_file == null)throw new RuntimeException("zip file name is null");if (zip_file.isEmpty())throw new RuntimeException("zip file name is empty");if (file_path == null)throw new RuntimeException("zip file name is null");if (file_path.isEmpty())throw new RuntimeException("zip file name is empty");if (entry_name.isEmpty())throw new RuntimeException("zip file name is empty"); File file_z = new File(zip_file);if (!file_z.exists())throw new RuntimeException("zip file is not exists"); File file = new File(zip_file); String name = file.getName().split("\\.")[0]; ZipEntry ze = new ZipEntry(entry_name); File file1 = new File(file_path);if (!file1.exists()) file1.mkdirs();//子包母包增加新文件 String subPackageName = name + "_" + "ps_" + agentParam + "_vs_" + version + ".ipa";//输出流 ZipOutputStream zos = new ZipOutputStream(new FileOutputStream( file_path + "/" + subPackageName));//写入一个文件到子包指定位置 //Payload/lhtx.app/ zos.putNextEntry(ze); zos.closeEntry();//母包写入流 ZipInputStream zis = new ZipInputStream(new FileInputStream( zip_file));while ((ze = zis.getNextEntry()) != null) {if (!ze.isDirectory()) { zos.putNextEntry(new ZipEntry(ze.getName()));int len = -1;byte[] b = new byte[1024];while ((len = zis.read(b)) > 0) { zos.write(b, 0, len); } zos.closeEntry(); zis.closeEntry(); } } zos.flush(); zos.close(); zis.close(); System.out.println("ios打包成功!"); System.out.println("time:" + (System.currentTimeMillis() - time));return subPackageName; }private static InputStream getInputStream(InputStream in)throws IOException { PushbackInputStream testin = new PushbackInputStream(in);int ch = testin.read();if (ch != 0xEF) { testin.unread(ch); } else if ((ch = testin.read()) != 0xBB) { testin.unread(ch); testin.unread(0xef); } else if ((ch = testin.read()) != 0xBF) {throw new IOException("错误的UTF-8格式文件"); } else {// 不需要做,这里是bom头被读完了 // System.out.println("still exist bom"); }return testin; }}感谢各位的阅读,以上就是"如何实现apk、ipa包修改注入参数打子包"的内容了,经过本文的学习后,相信大家对如何实现apk、ipa包修改注入参数打子包这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是,小编将为大家推送更多相关知识点的文章,欢迎关注!
文件
参数
推广
推广员
文件名
目录
成功
盒子
学习
内容
平台
效果
标记
版本
安卓
utf-8
位置
完了
就是
思路
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
互联网科技名片
科技赋能下的互联网金融
互联网科技行业发展
中国互联网科技股
朗新科技与工业互联网
麻工互联网科技
互联网科技革命
互联网科技视频素材
四川狮子座互联网科技
互联网之后的科技是什么
贵州叶脉互联网科技有限公司所属行业
来此购互联网科技有限公司
互联网科技公司有风险吗
消费医药和互联网科技
互联网方面的科技前沿
从那以后互联网科技有限公司
半导体是互联网高科技吗
互联网科技包装股
广州智享互联网科技
亚光科技低轨卫星互联网
花魁咖啡
善班互联网科技
互联网科技logo
互联网科技公司名称
世界互联网科技公司市值排名
呼和浩特新华互联网科技学院
中国科技创新与世界互联网大会
如何创新互联网科技
佛山市拉法互联网科技有限公司
广州智享互联网科技