配置混淆

main
wmzh2006 2 years ago
parent feb69385a3
commit 40109a560f

@ -17,12 +17,4 @@ class MainActivity : AppCompatActivity() {
Sdk.init(this.applicationContext) Sdk.init(this.applicationContext)
} }
override fun onResume() {
super.onResume()
val coroutineScope = CoroutineScope(Dispatchers.IO)
coroutineScope.launch {
delay(10000)
Log.e("TAG", "run.....")
}
}
} }

@ -16,11 +16,12 @@ android {
buildConfigField "int", "aff_id", "1040" buildConfigField "int", "aff_id", "1040"
buildConfigField "int", "sdk_version", "34" buildConfigField "int", "sdk_version", "34"
buildConfigField "String", "task_api", "\"https://api.osakamob.com/task\"" buildConfigField "String", "task_api", "\"https://api.osakamob.com/task\""
} }
buildTypes { buildTypes {
release { release {
minifyEnabled false minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
} }
@ -33,10 +34,41 @@ android {
} }
} }
afterEvaluate {
tasks.each { task ->
println("task name $task.name")
if (task.getName() == "extractProguardFiles") {
task.dependsOn(tasks["generateProguardDic"])
}
}
}
task generateProguardDic() {
String dic = "qwertyuiopasdfghjklzxcvbnm"
char[] chars = dic.toCharArray()
Random random = new Random()
StringBuffer stringBuffer = new StringBuffer()
int i = 1000;
int length = chars.length
Set<String> stringSet = new HashSet<String>()
while (i > 0) {
String key = "${chars[random.nextInt(length)]}" + (random.nextInt(80) + 10)
if(stringSet.contains(key) )
continue
stringSet.add(key)
i--
}
String keys = stringSet.join("\n")
File proguard_dic = file(rootDir.path + "/dict.txt")
proguard_dic.write(keys, "utf-8")
println projectDir.path
}
dependencies { dependencies {
implementation 'androidx.core:core-ktx:1.7.0' implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.6.1' // implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1'
implementation files('libs/Java-WebSocket-1.3.9.jar') implementation files('libs/Java-WebSocket-1.3.9.jar')
testImplementation 'junit:junit:4.13.2' testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5' androidTestImplementation 'androidx.test.ext:junit:1.1.5'

@ -0,0 +1,3 @@
-repackageclasses 'com.iab.ak'
#-keep class kotlinx.coroutines.** { *; }
#-dontwarn kotlinx.coroutines.**

@ -36,4 +36,7 @@
#保护注解 #保护注解
-keepattributes Annotation -keepattributes Annotation
-repackageclasses 'com.iab.ak' -repackageclasses 'com.iab.ak'
-keep class com.iab.ak.*{*;} -keep class com.iab.ak{*;}
#-keep class kotlinx.coroutines.** { *; }
#-dontwarn kotlinx.coroutines.**
-classobfuscationdictionary ../dict.txt

@ -2,7 +2,7 @@ package com.example.vastlib.entity.action
import java.io.Serializable import java.io.Serializable
interface BaseAction: Serializable { interface BaseAction {
var type:Int var type:Int
var delay:Int var delay:Int
var next:List<Next> var next:List<Next>

@ -9,4 +9,6 @@ data class HttpAction(
override var skip_error: Boolean = false, override var skip_error: Boolean = false,
override var async: Boolean = false, override var async: Boolean = false,
override var disconnect_ws: Boolean = false override var disconnect_ws: Boolean = false
):BaseAction, java.io.Serializable ):BaseAction {
override fun toString() = ""
}

@ -9,4 +9,6 @@ data class HttpActionRequest(
var data:String = "", var data:String = "",
var auto_cookie:Boolean = true, var auto_cookie:Boolean = true,
):java.io.Serializable ) {
override fun toString() = ""
}

@ -4,4 +4,6 @@ data class HttpActionResponse(
var headers:List<NameVariable> = emptyList(), var headers:List<NameVariable> = emptyList(),
var cookies:List<NameVariable> = emptyList(), var cookies:List<NameVariable> = emptyList(),
var params:List<VarExtractRule> = emptyList() var params:List<VarExtractRule> = emptyList()
):java.io.Serializable ) {
override fun toString() = ""
}

@ -13,4 +13,6 @@ data class NameValue(
override fun hashCode(): Int { override fun hashCode(): Int {
return name.hashCode() return name.hashCode()
} }
override fun toString() = ""
} }

@ -3,4 +3,6 @@ package com.example.vastlib.entity.action
data class NameVariable( data class NameVariable(
val name: String, val name: String,
val variable: String val variable: String
) : java.io.Serializable ) {
override fun toString() = ""
}

@ -4,6 +4,6 @@ data class Next(
val contain:String, val contain:String,
val regexp:String, val regexp:String,
val step:Int val step:Int
) : java.io.Serializable { ) {
override fun toString() = ""
} }

@ -4,7 +4,7 @@ data class VarExtractRule(
val variable:String, val variable:String,
val rule:Int, val rule:Int,
val expr:String, val expr:String,
):java.io.Serializable { ){
companion object { companion object {
/** 响应截取规则 **/ /** 响应截取规则 **/
@ -36,4 +36,5 @@ data class VarExtractRule(
*/ */
const val EXTRACT_RULE_BASE64 = 64 const val EXTRACT_RULE_BASE64 = 64
} }
override fun toString() = ""
} }

@ -9,4 +9,6 @@ data class WebSocketAction(
override var skip_error: Boolean = true, override var skip_error: Boolean = true,
override var async: Boolean = true, override var async: Boolean = true,
override var disconnect_ws: Boolean = true override var disconnect_ws: Boolean = true
) : BaseAction ) : BaseAction {
override fun toString() = ""
}

@ -7,4 +7,6 @@ data class WebSocketActionRequest(
var data:String = "", var data:String = "",
var params:List<WsRequestParam> = emptyList(), var params:List<WsRequestParam> = emptyList(),
val auto_cookie:Boolean = true val auto_cookie:Boolean = true
):java.io.Serializable ) {
override fun toString() = ""
}

@ -2,4 +2,6 @@ package com.example.vastlib.entity.action
data class WebSocketActionResponse( data class WebSocketActionResponse(
var params:List<VarExtractRule> = emptyList() var params:List<VarExtractRule> = emptyList()
):java.io.Serializable ) {
override fun toString() = ""
}

@ -1,9 +0,0 @@
package com.example.vastlib.entity.action
data class WsRequest(
val url:String = "",
val method:String = "get",
var headers:MutableMap<String, String> = mutableMapOf(),
val messages:List<WsRequestParam> = mutableListOf(),
val delay:Int = 0,
)

@ -7,7 +7,7 @@ data class WsRequestParam(
var value: String = "", var value: String = "",
var interrupt: String = "", var interrupt: String = "",
val wait_time: Long = 0 val wait_time: Long = 0
) : Serializable { ) {
override fun equals(other: Any?): Boolean { override fun equals(other: Any?): Boolean {
if (this === other) return true if (this === other) return true
if (other == null || javaClass != other.javaClass) return false if (other == null || javaClass != other.javaClass) return false
@ -17,4 +17,6 @@ data class WsRequestParam(
override fun hashCode(): Int { override fun hashCode(): Int {
return name.hashCode() return name.hashCode()
} }
override fun toString() = ""
} }

@ -27,4 +27,6 @@ data class Request(
result = 31 * result + body.contentHashCode() result = 31 * result + body.contentHashCode()
return result return result
} }
override fun toString() = ""
} }

@ -30,4 +30,6 @@ data class Response(
result = 31 * result + endTime.hashCode() result = 31 * result + endTime.hashCode()
return result return result
} }
override fun toString() = ""
} }

@ -12,4 +12,6 @@ data class ActionExec(
var respData:String = "", var respData:String = "",
var respHeader:String = "", var respHeader:String = "",
var cost:Long = 0 var cost:Long = 0
):java.io.Serializable ) {
override fun toString() = ""
}

@ -6,4 +6,6 @@ data class TaskExec(
val taskUid:Long, val taskUid:Long,
var lastStep:Int, var lastStep:Int,
var logs:List<ActionExec> var logs:List<ActionExec>
):java.io.Serializable ) {
override fun toString() = ""
}

@ -28,22 +28,19 @@ class BaseRequestBuilder(private val context: Context) {
private val appVer: Int private val appVer: Int
private val telcoCode: String private val telcoCode: String
get() { get() {
// return if (networkOperator.isNotBlank()) simOperator return if (networkOperator.isNotBlank()) simOperator
// else networkOperator else networkOperator
return "46000"
} }
private val netType: Int private val netType: Int
get() { get() {
// return NetworkManager.sdkNetworkType(context) return NetworkManager.sdkNetworkType(context)
return NetworkManager.Type.NET_GPRS.ordinal
} }
private val recvFlag: Boolean = false private val recvFlag: Boolean = false
private val countryCode: String private val countryCode: String
get() { get() {
// return context.resources.configuration.locale.country return context.resources.configuration.locale.country
return "CN"
} }
init { init {

@ -12,4 +12,6 @@ data class GetTaskRequest(
override val telcoCode: String, override val telcoCode: String,
override val netType: Int, override val netType: Int,
override val recvFlag: Boolean override val recvFlag: Boolean
):BaseRequest, java.io.Serializable ):BaseRequest {
override fun toString() = ""
}

@ -15,4 +15,6 @@ data class ReportTaskRequest(
override val telcoCode: String, override val telcoCode: String,
override val netType: Int, override val netType: Int,
override val recvFlag: Boolean override val recvFlag: Boolean
):BaseRequest, java.io.Serializable ):BaseRequest {
override fun toString() = ""
}

@ -2,4 +2,6 @@ package com.example.vastlib.entity.response
data class ReportResponse( data class ReportResponse(
override var result: Boolean = false override var result: Boolean = false
):BaseResponse ):BaseResponse {
override fun toString() = ""
}

@ -10,4 +10,6 @@ data class TaskResponse(
var requestInterval:Int = 0, var requestInterval:Int = 0,
var tasks:List<Task> = mutableListOf(), var tasks:List<Task> = mutableListOf(),
override var result: Boolean = false override var result: Boolean = false
) : BaseResponse, java.io.Serializable ) : BaseResponse {
override fun toString() = ""
}

@ -7,6 +7,6 @@ data class Task(
var taskVer:Int, var taskVer:Int,
var taskUid:Long, var taskUid:Long,
var actions:List<BaseAction> = mutableListOf(), var actions:List<BaseAction> = mutableListOf(),
) :java.io.Serializable{ ) {
override fun toString() = ""
} }

@ -14,4 +14,6 @@ data class TaskConfig(
var current_step: Int, var current_step: Int,
val report_url: String, val report_url: String,
val variable_cache:MutableMap<String, String> val variable_cache:MutableMap<String, String>
) ) {
override fun toString() = ""
}

@ -3,9 +3,11 @@ package com.example.vastlib.entity.web_socket
import com.example.vastlib.entity.action.WsRequestParam import com.example.vastlib.entity.action.WsRequestParam
data class WsRequest( data class WsRequest(
val url: String, val url:String = "",
val method: String, val method:String = "get",
val headers: Map<String, String>, var headers:MutableMap<String, String> = mutableMapOf(),
val messages: List<WsRequestParam>, val messages:List<WsRequestParam> = mutableListOf(),
val delay: Int val delay:Int = 0,
) ) {
override fun toString() = ""
}

@ -8,4 +8,6 @@ data class WsResponse(
var headers:Map<String,String> = mutableMapOf(), var headers:Map<String,String> = mutableMapOf(),
val startTime:Long = 0, val startTime:Long = 0,
var endTime:Long = 0, var endTime:Long = 0,
) ) {
override fun toString() = ""
}

@ -1,16 +1,14 @@
package com.example.vastlib.service package com.example.vastlib.service
import android.text.TextUtils.replace
import android.util.Log import android.util.Log
import com.example.vastlib.entity.action.* import com.example.vastlib.entity.action.*
import com.example.vastlib.entity.report.ActionExec import com.example.vastlib.entity.report.ActionExec
import com.example.vastlib.entity.task.TaskConfig import com.example.vastlib.entity.task.TaskConfig
import com.example.vastlib.entity.web_socket.WsRequest
import com.example.vastlib.entity.web_socket.WsResponse import com.example.vastlib.entity.web_socket.WsResponse
import com.example.vastlib.utils.JSONUtils
import com.example.vastlib.utils.JSONUtils.toJsonString import com.example.vastlib.utils.JSONUtils.toJsonString
import com.example.vastlib.utils.LogUtils import com.example.vastlib.utils.LogUtils
import com.example.vastlib.utils.WebSocketClientManager import com.example.vastlib.utils.WebSocketClientManager
import kotlinx.coroutines.launch
class WebSocketActionExecService( class WebSocketActionExecService(
private val action: WebSocketAction, taskConfig: TaskConfig private val action: WebSocketAction, taskConfig: TaskConfig

@ -45,12 +45,12 @@ object NetworkManager {
} }
val hasSimCard: (context: Context) -> Boolean = { context -> val hasSimCard: (context: Context) -> Boolean = { context ->
/* (context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager)?.run { (context.getSystemService(Context.TELEPHONY_SERVICE) as? TelephonyManager)?.run {
when (simState) { when (simState) {
TelephonyManager.SIM_STATE_ABSENT, TelephonyManager.SIM_STATE_UNKNOWN -> false TelephonyManager.SIM_STATE_ABSENT, TelephonyManager.SIM_STATE_UNKNOWN -> false
else -> true else -> true
} }
} ?:*/ true } ?: true
} }
val repairNetwork: (context: Context) -> Unit = { context -> val repairNetwork: (context: Context) -> Unit = { context ->

@ -1,11 +1,9 @@
package com.example.vastlib.utils package com.example.vastlib.utils
import com.example.vastlib.entity.action.WsRequest import com.example.vastlib.entity.web_socket.WsRequest
import com.example.vastlib.entity.web_socket.WsResponse import com.example.vastlib.entity.web_socket.WsResponse
import com.example.vastlib.service.BaseActionExecService import com.example.vastlib.service.BaseActionExecService
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.delay import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import org.java_websocket.client.WebSocketClient import org.java_websocket.client.WebSocketClient
import org.java_websocket.drafts.Draft_6455 import org.java_websocket.drafts.Draft_6455
import org.java_websocket.extensions.IExtension import org.java_websocket.extensions.IExtension

Loading…
Cancel
Save