Skip to content

Commit 73266d5

Browse files
authored
Merge pull request #42 from aquamarine5/v1.7-security-dev
v1.7.2: `SponsorList` is fetched from remote server, hackdoor after restricted user of `BlockedContent`
2 parents f83f20c + cdaebd4 commit 73266d5

File tree

4 files changed

+169
-99
lines changed

4 files changed

+169
-99
lines changed

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ android {
3737
applicationId = "org.aquamarine5.brainspark.chaoxingsignfaker"
3838
minSdk = 26
3939
targetSdk = 35
40-
versionCode = 107010001
41-
versionName = "1.7.1-stable-250518"
40+
versionCode = 107022025
41+
versionName = "1.7.2-stable-250529"
4242

4343
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
4444
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*
2+
* Copyright (c) 2025, @aquamarine5 (@海蓝色的咕咕鸽). All Rights Reserved.
3+
* Author: aquamarine5@163.com (Github: https://github.com/aquamarine5) and Brainspark (previously RenegadeCreation)
4+
* Repository: https://github.com/aquamarine5/ChaoxingSignFaker
5+
*/
6+
7+
package org.aquamarine5.brainspark.chaoxingsignfaker.components
8+
9+
import androidx.compose.foundation.layout.Arrangement
10+
import androidx.compose.foundation.layout.Column
11+
import androidx.compose.foundation.layout.Spacer
12+
import androidx.compose.foundation.layout.fillMaxSize
13+
import androidx.compose.foundation.layout.height
14+
import androidx.compose.foundation.layout.padding
15+
import androidx.compose.foundation.layout.size
16+
import androidx.compose.material3.Icon
17+
import androidx.compose.material3.IconButton
18+
import androidx.compose.material3.Text
19+
import androidx.compose.runtime.Composable
20+
import androidx.compose.runtime.LaunchedEffect
21+
import androidx.compose.runtime.getValue
22+
import androidx.compose.runtime.mutableIntStateOf
23+
import androidx.compose.runtime.mutableStateListOf
24+
import androidx.compose.runtime.remember
25+
import androidx.compose.runtime.setValue
26+
import androidx.compose.ui.Alignment
27+
import androidx.compose.ui.Modifier
28+
import androidx.compose.ui.res.painterResource
29+
import androidx.compose.ui.unit.dp
30+
import com.alibaba.fastjson2.JSONObject
31+
import kotlinx.coroutines.Dispatchers
32+
import kotlinx.coroutines.withContext
33+
import okhttp3.Request
34+
import org.aquamarine5.brainspark.chaoxingsignfaker.R
35+
import org.aquamarine5.brainspark.chaoxingsignfaker.api.ChaoxingHttpClient
36+
37+
private const val UNBLOCKED_BUTTON_CLICK_LIMIT = 10
38+
39+
@Composable
40+
fun BlockedContent(content: @Composable () -> Unit) {
41+
val bannedFidList = remember { mutableStateListOf<Int>() }
42+
var unblockedButtonClickCount by remember { mutableIntStateOf(0) }
43+
LaunchedEffect(Unit) {
44+
withContext(Dispatchers.IO){
45+
ChaoxingHttpClient.instance?.okHttpClient?.newCall(
46+
Request.Builder()
47+
.get()
48+
.url("http://cdn.aquamarine5.fun/chaoxingsignfaker_banlist.json")
49+
.build()
50+
)?.execute().use {
51+
bannedFidList.addAll(
52+
JSONObject.parseObject(it?.body?.string()).getJSONArray("banfids")
53+
.toList(Int::class.java)
54+
)
55+
}
56+
}
57+
}
58+
if (unblockedButtonClickCount < UNBLOCKED_BUTTON_CLICK_LIMIT && bannedFidList.contains(
59+
ChaoxingHttpClient.instance!!.userEntity.fid
60+
)
61+
) {
62+
Column(
63+
modifier = Modifier
64+
.fillMaxSize()
65+
.padding(16.dp),
66+
verticalArrangement = Arrangement.Center,
67+
horizontalAlignment = Alignment.CenterHorizontally
68+
) {
69+
IconButton(onClick = {
70+
unblockedButtonClickCount++
71+
}, modifier = Modifier.size(48.dp)) {
72+
Icon(painterResource(R.drawable.ic_user_lock), null)
73+
}
74+
Spacer(modifier = Modifier.height(8.dp))
75+
Text("受限于应用策略,当前账号无法使用此功能")
76+
}
77+
} else {
78+
content()
79+
}
80+
}

app/src/main/java/org/aquamarine5/brainspark/chaoxingsignfaker/components/SponsorAlertDialog.kt

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,27 @@ import android.provider.MediaStore
1616
import android.widget.Toast
1717
import androidx.activity.compose.LocalActivity
1818
import androidx.compose.foundation.Image
19+
import androidx.compose.foundation.border
1920
import androidx.compose.foundation.layout.Column
2021
import androidx.compose.foundation.layout.Row
2122
import androidx.compose.foundation.layout.Spacer
2223
import androidx.compose.foundation.layout.height
24+
import androidx.compose.foundation.layout.padding
2325
import androidx.compose.foundation.layout.width
2426
import androidx.compose.foundation.rememberScrollState
27+
import androidx.compose.foundation.shape.RoundedCornerShape
2528
import androidx.compose.foundation.verticalScroll
2629
import androidx.compose.material3.AlertDialog
2730
import androidx.compose.material3.Button
2831
import androidx.compose.material3.MaterialTheme
2932
import androidx.compose.material3.OutlinedButton
3033
import androidx.compose.material3.Text
3134
import androidx.compose.runtime.Composable
35+
import androidx.compose.runtime.LaunchedEffect
3236
import androidx.compose.runtime.MutableState
3337
import androidx.compose.runtime.getValue
38+
import androidx.compose.runtime.mutableStateListOf
39+
import androidx.compose.runtime.remember
3440
import androidx.compose.runtime.rememberCoroutineScope
3541
import androidx.compose.runtime.setValue
3642
import androidx.compose.ui.Modifier
@@ -46,12 +52,14 @@ import androidx.compose.ui.unit.dp
4652
import androidx.compose.ui.unit.sp
4753
import androidx.core.content.ContextCompat
4854
import androidx.core.graphics.drawable.toBitmap
55+
import com.alibaba.fastjson2.JSONObject
4956
import com.google.accompanist.permissions.ExperimentalPermissionsApi
5057
import com.google.accompanist.permissions.isGranted
5158
import com.google.accompanist.permissions.rememberPermissionState
5259
import kotlinx.coroutines.Dispatchers
5360
import kotlinx.coroutines.launch
5461
import kotlinx.coroutines.withContext
62+
import okhttp3.Request
5563
import org.aquamarine5.brainspark.chaoxingsignfaker.R
5664
import org.aquamarine5.brainspark.chaoxingsignfaker.UMengHelper
5765
import org.aquamarine5.brainspark.chaoxingsignfaker.api.ChaoxingHttpClient
@@ -65,19 +73,29 @@ private const val SPONSOR_IMAGE_FILENAME_BASE = "ChaoxingSignFaker_sponsor"
6573
@Composable
6674
fun SponsorAlertDialog(showDialog: MutableState<Boolean>) {
6775
val context = LocalActivity.current!!.applicationContext
68-
val sponsorList = listOf(
69-
listOf("Xcellent","18.80"),
70-
listOf("催什么崔", "8.88"),
71-
listOf("不愿透露姓名的耿先生", "8.88"),
72-
listOf("不愿透露姓名的景先生", "7.66"),
73-
listOf("G*.", "6.66"),
74-
listOf("R*e","6.66"),
75-
listOf("不愿透露姓名的高先生", "6.66"),
76-
listOf("云端哥特", "6.60"),
77-
listOf("*.", "6.00"),
78-
listOf("死后世界战线", "5.88"),
79-
listOf("不愿透露姓名的张先生", "2.88"),
80-
)
76+
val sponsorList = remember { mutableStateListOf<List<String>>() }
77+
LaunchedEffect(Unit) {
78+
withContext(Dispatchers.IO){
79+
ChaoxingHttpClient.instance?.okHttpClient?.newCall(
80+
Request.Builder()
81+
.get()
82+
.url("http://cdn.aquamarine5.fun/chaoxingsignfaker_sponsor.json")
83+
.build()
84+
)?.execute().use {
85+
val json = JSONObject.parseObject(it?.body?.string())
86+
val list = json.getJSONArray("sponsorList")
87+
if (list.isNotEmpty()) {
88+
sponsorList.clear()
89+
for (i in 0 until list.size) {
90+
val item = list.getJSONArray(i)
91+
if (item.size == 2) {
92+
sponsorList.add(listOf(item.getString(0), item.getString(1)))
93+
}
94+
}
95+
}
96+
}
97+
}
98+
}
8199
val coroutineScope = rememberCoroutineScope()
82100
val permissionCheck =
83101
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.R) rememberPermissionState(
@@ -221,7 +239,7 @@ fun SponsorAlertDialog(showDialog: MutableState<Boolean>) {
221239
)
222240
Spacer(modifier = Modifier.height(4.dp))
223241
Text(buildAnnotatedString {
224-
sponsorList.forEach {
242+
sponsorList.forEachIndexed { index, it->
225243
withStyle(SpanStyle(fontWeight = FontWeight.Bold)) {
226244
append(it[0])
227245
}
@@ -236,9 +254,11 @@ fun SponsorAlertDialog(showDialog: MutableState<Boolean>) {
236254
append(it[1])
237255
}
238256
append("")
257+
if(index!=sponsorList.size-1)
239258
append("\n")
240259
}
241-
})
260+
},modifier=Modifier.border(1.dp, MaterialTheme.colorScheme.primary,
261+
RoundedCornerShape(4.dp)).padding(8.dp))
242262
}
243263
})
244264
}

0 commit comments

Comments
 (0)