Add GCAuth skip SSL validation
This commit is contained in:
parent
3fb413074c
commit
ebbb5a8c13
@ -33,7 +33,10 @@ import java.io.ByteArrayOutputStream
|
|||||||
import java.io.InputStreamReader
|
import java.io.InputStreamReader
|
||||||
import java.net.HttpURLConnection
|
import java.net.HttpURLConnection
|
||||||
import java.net.URL
|
import java.net.URL
|
||||||
|
import java.security.SecureRandom
|
||||||
|
import java.security.cert.X509Certificate
|
||||||
import java.util.regex.Pattern
|
import java.util.regex.Pattern
|
||||||
|
import javax.net.ssl.*
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
|
|
||||||
@ -82,6 +85,42 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
"log-upload-os.hoyoverse.com"
|
"log-upload-os.hoyoverse.com"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private var socketFactory: SSLSocketFactory
|
||||||
|
private var verifier: DefaultHostnameVerifier
|
||||||
|
|
||||||
|
init {
|
||||||
|
val ctx = SSLContext.getInstance("TLS")
|
||||||
|
ctx.init(arrayOf<KeyManager>(), arrayOf<TrustManager>(DefaultTrustManager()), SecureRandom())
|
||||||
|
ctx.clientSessionContext.sessionTimeout = 15
|
||||||
|
ctx.clientSessionContext.sessionCacheSize = 1000
|
||||||
|
socketFactory = ctx.socketFactory
|
||||||
|
verifier = DefaultHostnameVerifier()
|
||||||
|
}
|
||||||
|
|
||||||
|
class DefaultHostnameVerifier : HostnameVerifier {
|
||||||
|
@SuppressLint("BadHostnameVerifier")
|
||||||
|
override fun verify(p0: String?, p1: SSLSession?): Boolean {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CustomX509TrustManager")
|
||||||
|
private class DefaultTrustManager : X509TrustManager {
|
||||||
|
|
||||||
|
@SuppressLint("TrustAllX509TrustManager")
|
||||||
|
override fun checkClientTrusted(chain: Array<X509Certificate?>?, authType: String?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("TrustAllX509TrustManager")
|
||||||
|
override fun checkServerTrusted(chain: Array<X509Certificate?>?, authType: String?) {
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun getAcceptedIssuers(): Array<X509Certificate> {
|
||||||
|
return arrayOf()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) {
|
override fun initZygote(startupParam: IXposedHookZygoteInit.StartupParam) {
|
||||||
modulePath = startupParam.modulePath
|
modulePath = startupParam.modulePath
|
||||||
moduleRes = XModuleResources.createInstance(modulePath, null)
|
moduleRes = XModuleResources.createInstance(modulePath, null)
|
||||||
@ -115,7 +154,7 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
setCancelable(false)
|
setCancelable(false)
|
||||||
setTitle(moduleRes.getString(R.string.SelectServer))
|
setTitle(moduleRes.getString(R.string.SelectServer))
|
||||||
setMessage(moduleRes.getString(R.string.Tips))
|
setMessage(moduleRes.getString(R.string.Tips))
|
||||||
setNegativeButton(moduleRes.getString(R.string.Settings)) {_, _ ->
|
setNegativeButton(moduleRes.getString(R.string.Settings)) { _, _ ->
|
||||||
AlertDialog.Builder(activity).apply {
|
AlertDialog.Builder(activity).apply {
|
||||||
setMessage(moduleRes.getString(R.string.Tips2))
|
setMessage(moduleRes.getString(R.string.Tips2))
|
||||||
setCancelable(false)
|
setCancelable(false)
|
||||||
@ -198,7 +237,7 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
setPositiveButton(moduleRes.getString(R.string.Back)) { _, _ ->
|
setPositiveButton(moduleRes.getString(R.string.Back)) { _, _ ->
|
||||||
showDialog()
|
showDialog()
|
||||||
}
|
}
|
||||||
setNeutralButton(moduleRes.getString(R.string.ExitGames)) {_, _ ->
|
setNeutralButton(moduleRes.getString(R.string.ExitGames)) { _, _ ->
|
||||||
exitProcess(0)
|
exitProcess(0)
|
||||||
}
|
}
|
||||||
}.show()
|
}.show()
|
||||||
@ -251,8 +290,7 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
val x = event.rawX
|
val x = event.rawX
|
||||||
val y = event.rawY
|
val y = event.rawY
|
||||||
|
|
||||||
val params: WindowManager.LayoutParams =
|
val params: WindowManager.LayoutParams = v.layoutParams as WindowManager.LayoutParams
|
||||||
v.layoutParams as WindowManager.LayoutParams
|
|
||||||
|
|
||||||
val newX = (x - offsetX).toInt()
|
val newX = (x - offsetX).toInt()
|
||||||
val newY = (y - offsetY).toInt()
|
val newY = (y - offsetY).toInt()
|
||||||
@ -318,12 +356,21 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
Thread() {
|
Thread() {
|
||||||
try {
|
try {
|
||||||
XposedBridge.log("$server/authentication/type")
|
XposedBridge.log("$server/authentication/type")
|
||||||
(URL("$server/authentication/type").openConnection() as HttpURLConnection).apply {
|
URL("$server/authentication/type").apply {
|
||||||
requestMethod = "GET"
|
val conn = if (server.startsWith("https")) {
|
||||||
readTimeout = 8000
|
(openConnection() as HttpsURLConnection).apply {
|
||||||
connectTimeout = 8000
|
sslSocketFactory = socketFactory
|
||||||
val reader = BufferedReader(InputStreamReader(inputStream))
|
hostnameVerifier = verifier
|
||||||
if (responseCode == 200) {
|
}
|
||||||
|
} else {
|
||||||
|
openConnection() as HttpURLConnection
|
||||||
|
}
|
||||||
|
conn.requestMethod = "GET"
|
||||||
|
conn.readTimeout = 8000
|
||||||
|
conn.connectTimeout = 8000
|
||||||
|
|
||||||
|
val reader = BufferedReader(InputStreamReader(conn.inputStream))
|
||||||
|
if (conn.responseCode == 200) {
|
||||||
val response = StringBuilder()
|
val response = StringBuilder()
|
||||||
var line = ""
|
var line = ""
|
||||||
while (reader.readLine()?.also { line = it } != null) {
|
while (reader.readLine()?.also { line = it } != null) {
|
||||||
@ -399,20 +446,28 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
setOnClickListener {
|
setOnClickListener {
|
||||||
Thread() {
|
Thread() {
|
||||||
try {
|
try {
|
||||||
(URL("$server/authentication/login").openConnection() as HttpURLConnection).apply {
|
URL("$server/authentication/type").apply {
|
||||||
requestMethod = "POST"
|
val conn = if (server.startsWith("https")) {
|
||||||
readTimeout = 8000
|
(openConnection() as HttpsURLConnection).apply {
|
||||||
connectTimeout = 8000
|
sslSocketFactory = socketFactory
|
||||||
doOutput = true
|
hostnameVerifier = verifier
|
||||||
doInput = true
|
}
|
||||||
useCaches = false
|
} else {
|
||||||
|
openConnection() as HttpURLConnection
|
||||||
|
}
|
||||||
|
conn.requestMethod = "POST"
|
||||||
|
conn.readTimeout = 8000
|
||||||
|
conn.connectTimeout = 8000
|
||||||
|
conn.doOutput = true
|
||||||
|
conn.doInput = true
|
||||||
|
conn.useCaches = false
|
||||||
|
|
||||||
outputStream.apply {
|
conn.outputStream.apply {
|
||||||
write("{\"username\":\"${userEdit.text}\",\"password\":\"${passEdit.text}\"}".toByteArray())
|
write("{\"username\":\"${userEdit.text}\",\"password\":\"${passEdit.text}\"}".toByteArray())
|
||||||
flush()
|
flush()
|
||||||
}
|
}
|
||||||
if (responseCode == 200) {
|
if (conn.responseCode == 200) {
|
||||||
val input = inputStream
|
val input = conn.inputStream
|
||||||
val message = ByteArrayOutputStream()
|
val message = ByteArrayOutputStream()
|
||||||
|
|
||||||
var len: Int
|
var len: Int
|
||||||
@ -456,25 +511,13 @@ class MainHook : IXposedHookLoadPackage, IXposedHookZygoteInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
windowManager = activity.windowManager
|
windowManager = activity.windowManager
|
||||||
windowManager.addView(mainView, WindowManager.LayoutParams(
|
windowManager.addView(mainView, WindowManager.LayoutParams(dp2px(activity, 200f), WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT).apply {
|
||||||
dp2px(activity, 200f),
|
|
||||||
WindowManager.LayoutParams.MATCH_PARENT,
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION,
|
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
|
|
||||||
PixelFormat.TRANSLUCENT
|
|
||||||
).apply {
|
|
||||||
gravity = Gravity.START or Gravity.TOP
|
gravity = Gravity.START or Gravity.TOP
|
||||||
x = 0
|
x = 0
|
||||||
y = 0
|
y = 0
|
||||||
})
|
})
|
||||||
|
|
||||||
val layoutParams = WindowManager.LayoutParams(
|
val layoutParams = WindowManager.LayoutParams(WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.WRAP_CONTENT, WindowManager.LayoutParams.TYPE_APPLICATION, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL, PixelFormat.TRANSLUCENT).apply {
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
WindowManager.LayoutParams.WRAP_CONTENT,
|
|
||||||
WindowManager.LayoutParams.TYPE_APPLICATION,
|
|
||||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE or WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
|
|
||||||
PixelFormat.TRANSLUCENT
|
|
||||||
).apply {
|
|
||||||
gravity = Gravity.START or Gravity.TOP
|
gravity = Gravity.START or Gravity.TOP
|
||||||
x = 0
|
x = 0
|
||||||
y = 0
|
y = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user