Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Check environment patch #3610

Merged
merged 29 commits into from
Sep 6, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
bd69298
feat: Add `Check environment` patch
oSumAtrIX Sep 1, 2024
87e2d0e
move check before calling function
oSumAtrIX Sep 1, 2024
20d001d
rename method
oSumAtrIX Sep 1, 2024
0c3865a
use activity context
oSumAtrIX Sep 1, 2024
5acebd2
small changes
oSumAtrIX Sep 1, 2024
f1036e0
Use last three digits to prevent brute forcing the hashed IP
oSumAtrIX Sep 2, 2024
6280d13
fix some issues add todos
oSumAtrIX Sep 2, 2024
fed02f8
refactor
LisoUseInAIKyrios Sep 2, 2024
29506c2
fix: Check data returned from ip service. Try other services if needed.
LisoUseInAIKyrios Sep 3, 2024
285131d
fix: Remove Check if manager is installed
LisoUseInAIKyrios Sep 3, 2024
dbcea08
fix: Remove ip check that sometimes fails due to privacy concerns and…
LisoUseInAIKyrios Sep 3, 2024
2f74e88
fix: Remove social media links, as the main website is where they sh…
LisoUseInAIKyrios Sep 3, 2024
19a1b53
fix: Don't show any dialog buttons until after a few seconds
LisoUseInAIKyrios Sep 3, 2024
e64ba5b
fix: Adjust text
LisoUseInAIKyrios Sep 3, 2024
116d343
fix: Adjust text
LisoUseInAIKyrios Sep 3, 2024
e0fcbe1
fix: Add patch as dependency to Settings, until a way for mandatory p…
LisoUseInAIKyrios Sep 3, 2024
1329337
fix: Remove unused network address code
LisoUseInAIKyrios Sep 3, 2024
5840c75
fix: adjust text
LisoUseInAIKyrios Sep 3, 2024
f4132cd
Update src/main/resources/addresources/values/strings.xml
LisoUseInAIKyrios Sep 3, 2024
4a9793e
fix: Adjust text
LisoUseInAIKyrios Sep 3, 2024
da65772
fix: Show how old the patched apk is if any other checks fail
LisoUseInAIKyrios Sep 4, 2024
fadd7a4
Remove name so the patch does not appear as selectable
oSumAtrIX Sep 4, 2024
f52dd9f
Fix correctness of strings
oSumAtrIX Sep 4, 2024
ff969e3
fix: Use same base64 encoding for integrations and patches
LisoUseInAIKyrios Sep 5, 2024
36de93c
fix: use UTF8 just in case `Build` has foreign characters
LisoUseInAIKyrios Sep 5, 2024
98e143d
Update src/main/resources/addresources/values/strings.xml
LisoUseInAIKyrios Sep 5, 2024
7620abf
fix: Use more concise text
LisoUseInAIKyrios Sep 3, 2024
5f857a8
fix: Use consistent line break elements
LisoUseInAIKyrios Sep 6, 2024
a7115d7
fix: Use paragraph for last element to add some padding between the d…
LisoUseInAIKyrios Sep 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: Check data returned from ip service. Try other services if needed.
  • Loading branch information
LisoUseInAIKyrios committed Sep 3, 2024
commit 29506c27e200221ba76373145148a96f4257c54f
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ import com.android.tools.smali.dexlib2.immutable.value.ImmutableStringEncodedVal
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.HttpURLConnection
import java.net.InetAddress
import java.net.URL
import java.net.UnknownHostException
import java.security.MessageDigest
import java.util.logging.Logger
import kotlin.io.encoding.Base64
import kotlin.io.encoding.ExperimentalEncodingApi
import kotlin.random.Random

abstract class BaseCheckEnvironmentPatch(
oSumAtrIX marked this conversation as resolved.
Show resolved Hide resolved
private val mainActivityOnCreateFingerprint: MethodFingerprint,
Expand Down Expand Up @@ -124,39 +125,47 @@ abstract class BaseCheckEnvironmentPatch(
private val publicIp: String?
get() {
// Using multiple services to increase reliability, distribute the load and minimize tracking.
val getIpServices = listOf(
mutableListOf(
"https://wtfismyip.com/text",
"https://whatsmyfuckingip.com/text",
"https://api.ipify.org?format=text",
"https://icanhazip.com",
"https://ifconfig.me/ip",
)

var publicIP: String? = null

try {
val service = getIpServices[Random.Default.nextInt(getIpServices.size - 1)]
val urlConnection = URL(service).openConnection() as HttpURLConnection

).shuffled().forEach { service ->
try {
// It is ok to make the url call here and not on a background thread,
// since Manager already does patching off the main thread
// and with CLI patching there is no UI to worry about blocking.
val stream = urlConnection.inputStream
BufferedReader(InputStreamReader(stream)).use { reader ->
publicIP = reader.readLine()
var urlConnection : HttpURLConnection? = null

try {
urlConnection = URL(service).openConnection() as HttpURLConnection
urlConnection.setFixedLengthStreamingMode(0)
urlConnection.readTimeout = 10000
urlConnection.connectTimeout = 10000

// It is ok to make the url call here and not on a background thread,
// since Manager already does patching off the main thread
// and with CLI patching there is no UI to worry about blocking.
BufferedReader(InputStreamReader(urlConnection.inputStream)).use {
val ipString = it.readLine()
//noinspection ResultOfMethodCallIgnored
InetAddress.getByName(ipString) // Validate IP address.
return ipString
}
} catch (e: UnknownHostException) {
// Site is returning nonsense. Try another.
} finally {
urlConnection?.disconnect()
}

} finally {
urlConnection.disconnect()
} catch (e: Exception) {
// If the app does not have the INTERNET permission or the service is down,
// the public IP can not be retrieved.
Logger.getLogger(this::class.simpleName)
.info("Failed to get public IP address: " + e.message)
}
} catch (e: Exception) {
// If the app does not have the INTERNET permission or the service is down,
// the public IP can not be retrieved.
Logger.getLogger(this::class.simpleName).severe("Failed to get public IP address: " + e.message)
}

return publicIP
Logger.getLogger(this::class.simpleName).severe("Failed to get network address")

return null
}
}
}
Loading