AS--›Gradle乐固加固和下载
推荐阅读, 优先了解Gradle
的使用:
AS–›Gradle上传文件至七牛云
AS–›Gradle上传文件至蒲公英
目录
- 说明
- 1.只能加固url对应的apk
- 2.需要自己手动重新签名
- 乐固加固
- 待完善
- 联系作者
说明
1.只能加固url对应的apk
由于乐固加固
只能使用在线APK的url, 所以需要先将本地的APK, 上传至七牛云或者其他文件存储服务器. 拿到url之后, 才能使用乐固加固
2.需要自己手动重新签名
乐固加固
后的APK, 并没有签名. 所以, 加固下载后的APK, 需要手动签名. 才能正常安装.
乐固加固
注意: IDE爆红, 不影响代码运行. 请忽视爆红.
import okhttp3.MultipartBody
import okhttp3.OkHttpClient
import okhttp3.Request
import okhttp3.RequestBody
import okhttp3.MediaTypeimport java.security.MessageDigest
import java.security.NoSuchAlgorithmException
import java.util.concurrent.TimeUnit
import com.google.gson.Gsonimport com.tencentcloudapi.common.*
import com.tencentcloudapi.common.profile.*
import com.tencentcloudapi.common.exception.*import com.tencentcloudapi.ms.v20180408.*
import com.tencentcloudapi.ms.v20180408.models.*buildscript {repositories {jcenter()}dependencies {classpath "com.squareup.okhttp3:okhttp:3.12.0"classpath "com.google.code.gson:gson:2.8.5"classpath "com.tencentcloudapi:tencentcloud-sdk-java:3.0.8"}
}ext.leguConfig = ["SecretId" : "","SecretKey" : "",//需要加固的APK url地址"apkUrl" : "",//本地APK的路径, 用来计算MD5值"apkPath" : "./ademo.apk",//加固后, 下载保存到本地路径"downloadApkPath": "./ademo_legu.apk",//每隔多少秒, 查询一次加固结果"pollTime" : "10",//加固后, 返回的ItemId, 用来轮询结果"ItemId" : "",//加固成功的下载地址"downloadUrl" : ""
]task _leguJiaGu() {doFirst {Credential cred = new Credential(leguConfig.SecretId, leguConfig.SecretKey)HttpProfile httpProfile = new HttpProfile()httpProfile.setEndpoint("ms.tencentcloudapi.com")ClientProfile clientProfile = new ClientProfile()clientProfile.setHttpProfile(httpProfile)MsClient client = new MsClient(cred, "", clientProfile)def req = new CreateShieldInstanceRequest()def appInfo = new com.tencentcloudapi.ms.v20180408.models.AppInfo()appInfo.AppUrl = leguConfig.apkUrlappInfo.AppMd5 = getFileMd5(leguConfig.apkPath)def serviceInfo = new com.tencentcloudapi.ms.v20180408.models.ServiceInfo()serviceInfo.ServiceEdition = "basic"serviceInfo.SubmitSource = "RDM-rdm"serviceInfo.CallbackUrl = ""req.AppInfo = appInforeq.ServiceInfo = serviceInfoCreateShieldInstanceResponse resp = client.CreateShieldInstance(req)leguConfig.ItemId = resp.ItemId//Progress任务状态: 1-已完成,2-处理中,3-处理出错,4-处理超时println "加固处理中:" + DescribeShieldInstancesRequest.toJsonString(resp)_legtGetResult.doLast {println "加固结束"}_legtGetResult.execute()}
}/*** 用户查询提交过的app列表* */
task _leguGetAppList() {doFirst {Credential cred = new Credential(leguConfig.SecretId, leguConfig.SecretKey)HttpProfile httpProfile = new HttpProfile()httpProfile.setEndpoint("ms.tencentcloudapi.com")ClientProfile clientProfile = new ClientProfile()clientProfile.setHttpProfile(httpProfile)MsClient client = new MsClient(cred, "", clientProfile)String params = "{}"DescribeShieldInstancesRequest req = DescribeShieldInstancesRequest.fromJsonString(params, DescribeShieldInstancesRequest.class)DescribeShieldInstancesResponse resp = client.DescribeShieldInstances(req)System.out.println(DescribeShieldInstancesRequest.toJsonString(resp))}
}/*** 查询加固结果* */
task _legtGetResult() {doFirst {def TaskStatus = 2while (TaskStatus == 2) {println ""def cred = new Credential(leguConfig.SecretId, leguConfig.SecretKey)def httpProfile = new HttpProfile()httpProfile.setEndpoint("ms.tencentcloudapi.com")def clientProfile = new ClientProfile()clientProfile.setHttpProfile(httpProfile)def client = new MsClient(cred, "", clientProfile)def params = "{\"ItemId\":\"" + leguConfig.ItemId + "\"}"def req = DescribeShieldResultRequest.fromJsonString(params, DescribeShieldResultRequest.class)println leguConfig.pollTime + "s后, 查询加固状态:" + paramsThread.sleep(Integer.parseInt(leguConfig.pollTime) * 1000L)def resp = client.DescribeShieldResult(req)TaskStatus = resp.TaskStatusleguConfig.downloadUrl = resp.ShieldInfo.AppUrl//TaskStatus任务状态: 1-已完成,2-处理中,3-处理出错,4-处理超时println DescribeShieldResultRequest.toJsonString(resp)}println ""if (TaskStatus == 1) {println "加固成功下载地址:" + leguConfig.downloadUrlprintln "开始下载->" + file(leguConfig.downloadApkPath).getAbsolutePath()downloadFile(leguConfig.downloadUrl, leguConfig.downloadApkPath)} else {println "加固失败"}}
}static def getFileMd5(filePath) {def FILE_READ_BUFFER_SIZE = 16 * 1024MessageDigest digester = MessageDigest.getInstance("MD5")def stream = new FileInputStream(filePath)int bytesReadbyte[] buf = new byte[FILE_READ_BUFFER_SIZE]while ((bytesRead = stream.read(buf)) >= 0) {digester.update(buf, 0, bytesRead)}def md5code = new BigInteger(1, digester.digest()).toString(16)// 16进制数字// 如果生成数字未满32位,需要前面补0for (int i = 0; i < 32 - md5code.length(); i++) {md5code = "0" + md5code}return md5code}//下载加固后的文件
static def downloadFile(url, filePath) {def clientBuilder = new OkHttpClient.Builder()clientBuilder.connectTimeout(10, TimeUnit.SECONDS)clientBuilder.readTimeout(60, TimeUnit.SECONDS)OkHttpClient client = clientBuilder.build()def request = new Request.Builder().url(url).get().build()def response = client.newCall(request).execute()def write = new BufferedOutputStream(new FileOutputStream(filePath, false))def read = new BufferedInputStream(response.body().byteStream())def bytes = new byte[1024]def bytesRead = 0while ((bytesRead = read.read(bytes)) != -1) {write.write(bytes, 0, bytesRead)}read.close()write.flush()write.close()
}
执行:
gradlew _leguJiaGu
待完善
- 1:添加自动签名脚本
- 2:添加
Walle
分包脚本
如果有小伙伴写好了, 欢迎分享给我.
群内有各(pian)种(ni)各(jin)样(qun)
的大佬,等你来撩.
联系作者
点此快速加群
请使用QQ扫码加群, 小伙伴们都在等着你哦!
关注我的公众号, 每天都能一起玩耍哦!
AS--›Gradle乐固加固和下载相关推荐
- Android项目Jenkins配置(自定义参数构建,构建完成后360加固+自动下载签名+多渠道配置,自动乐固加固+签名,自动上传蒲公英,自动上传OSS,自动发送钉钉消息,自动发送企业微信应用)
Mac,window,unix,Linux等系统安装Jenkins服务就不说了... 直接上干货 编译后shell脚本参考 #推送钉钉群curl 'https://oapi.dingtalk.com/ ...
- java调用腾讯云的乐固加固给apk进行加固处理。
利用maven下载相应的jar包 <dependency> <groupId>com.tencentcloudapi</groupId> ...
- 上传Android应用到腾讯应用宝,乐固加固应用使用
当我们开发完安卓系统APP之后.需要上传到应用市场 在上传到腾讯应用宝是,需要使用腾讯加固工具 乐固 加固apk.才能正常上架. 如没有加固应用会提示: 加固步骤: 1.下载乐固包:https://d ...
- 关于使用腾讯乐固加固,涉及的签名及其他问题
年前的俩个项目,都涉及到了Apk加固的概念,那我们先大概说一下为什么要加固. 先看一下官方的说法; 这里给一下官方文档的链接腾讯乐固文档添加链接描述 所以我们使用的是腾讯乐固加固工具. 这里还需要了解 ...
- android Tinker 热修复 乐固加固后友盟打多渠道包之后的补丁失效
继上一篇 android tinker 热修复使用及注意事项 生成了热修复的补丁; 现在的需求是这样的,我想把这个包用腾讯乐固加固,然后生成多渠道包,希望这个补丁能修复所有这些渠道的包,经过测试,直 ...
- 使用腾讯乐固加固安卓APK
内容简介 为了保护我们的劳动成果和知识产权,必须对APK对加固工作,否则极易被人破解.篡改,二次打包.市面上当前做加固的有很多家,实际使用了腾讯乐固和360加固(看了网易也有易盾,但是因为只能试用,所 ...
- 乐固加固后windows下实现给apk签名
遇到了这样一个问题:我们已经在centos下签名生成好的apk,拿到腾讯乐固上加固以后,签名没有了,就需要重新签名,我乐滋滋的想,既然原来是在centos下签名的,那再去centos上签名一次就好了, ...
- 乐固加固APP后无法启动
最近在上线项目的时候,使用了腾讯的乐固加固软件,签名加固前APP正常启动,签名加固后APP启动后立马闪退.分别使用了三款测试机OPPO R9(android 5.0).华为P10(android 8. ...
- android 乐固加固,android - 上应用宝之前,使用乐固 进行加固。 (只能在windows 下)...
android - 上应用宝之前,使用乐固 进行加固. (只能在windows 下) 2019-05-27 15:04 访问量: 1249 分类: 技术 跟360的加固一样,应用宝的加固是3个步骤: ...
最新文章
- javascript 死循环
- VTK:量化多数据点用法实战
- 悔不当初:回顾进化之路
- Angular之ngx-permissions的控制视图访问
- 再来一波不错的学习资源
- python入门三:文件操作
- 规模数据导入高效方式︱将数据快速读入R—readr和readxl包
- 一次使用BeanPostProcessor疏漏引起的重大bug
- python绘制密度图
- 使用 Fiddler Hook 报错:502 Fiddler - Connection Failed
- 计算机省vb二级试题,湖南省计算机二级考试VB试题
- DelayQueue用例
- 【掩码机制】解决LSTM中特征长度不一致问题
- helm charts 入门指南
- 线性空间----【1】n维向量的线性相关
- 爆款AR游戏如何打造?网易杨鹏以《悠梦》为例详解前沿技术
- LDAP中CN,OU,DC的含义
- day27 学习HTML-01天
- python学习笔记14 图像格式转换png转jpg
- 原数据库和现有数据库不同
热门文章
- Dynamics 365 New Feature之Rich Text Editor Control
- 用户登录和用户注册案例
- Microsoft Edge打开主页就是2345界面
- 迪杰斯特拉--链式向前星
- Linux nodejs 安装以及配置环境
- 数据研究之综合评分(一) 权重-评分-指标
- python人工智能方向怎么学_如何学习人工智能
- 用HTML编写携程旅行,StaticHtmlPage(仿照携程写的静态网页)
- 1. 学校在线考试系统
- 微信公众号回复服务器参数错误,为什么微信文章网址在浏览器访问提示参数错误...