Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# RKNHardering

<a href="https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech"><img src="https://img.shields.io/badge/matrix-%23000000?style=for-the-badge&logo=matrix&logoColor=white" alt="Matrix" width="200"></a>
<a href="https://t.me/RKNHardering"><img src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram" width="200"></a>

Android-приложение для обнаружения VPN и прокси на устройстве. Реализует методику РКН по выявлению средств обхода блокировок.

Expand All @@ -25,7 +26,7 @@ Android-приложение для обнаружения VPN и прокси
- **Обход нативных проверок** (противодействие JNI-проверкам через `/proc/self/maps`, `getifaddrs()`, `dlsym`)
- **Маскировка установленных приложений** (скрытие пакетов VPN-приложений от `PackageManager`)

Если вы обладаете знаниями в этих областях, пожалуйста, откройте Issue или Pull Request, либо напишите в [чат Matrix](https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech) с описанием метода, условий применимости и ограничений. Любая информация ценна — от теоретических идей до работающих PoC.
Если вы обладаете знаниями в этих областях, пожалуйста, откройте Issue или Pull Request, либо напишите в [чат Matrix](https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech)/[Telegram](https://t.me/RKNHardering) с описанием метода, условий применимости и ограничений. Любая информация ценна — от теоретических идей до работающих PoC.

> **EN**

Expand All @@ -42,7 +43,7 @@ I am looking for people willing to help collect, organize, and test information
- **Bypassing native checks** (countering JNI-based checks through `/proc/self/maps`, `getifaddrs()`, and `dlsym`)
- **Masking installed applications** (hiding VPN app packages from `PackageManager`)

If you have expertise in these areas, please open an Issue or Pull Request describing the method, the conditions under which it applies, and its limitations. Any information is valuable, from theoretical ideas to working PoCs.
If you have expertise in these areas, please open an Issue or [Сhat in Matrix](https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech)/[Telegram](https://t.me/RKNHardering), the conditions under which it applies, and its limitations. Any information is valuable, from theoretical ideas to working PoCs.

## Архитектура

Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/com/notcvnt/rknhardering/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1869,7 +1869,7 @@ class MainActivity : AppCompatActivity() {

private fun ensureCardVisible(
card: MaterialCardView,
animate: Boolean = true,
@Suppress("UNUSED_PARAMETER") animate: Boolean = true,
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

он более не используется, убирать надо просто

shouldAutoScroll: Boolean = false,
) {
val inHiddenHost = card.parent === hiddenLegacyCardsHost
Expand Down Expand Up @@ -2704,14 +2704,6 @@ class MainActivity : AppCompatActivity() {
} else {
getString(R.string.main_card_call_transport_stun_none_responded)
}
val groupResult = com.notcvnt.rknhardering.model.IpCheckerGroupResult(
title = groupTitle,
detected = false,
needsReview = false,
statusLabel = statusLabel,
summary = statusLabel,
responses = emptyList(),
)

val card = com.google.android.material.card.MaterialCardView(themedContext()).apply {
layoutParams = LinearLayout.LayoutParams(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ internal class SettingsAboutFragment : Fragment(R.layout.fragment_settings_about
startActivity(Intent(Intent.ACTION_VIEW, getString(R.string.matrix_room_url).toUri()))
}

view.findViewById<MaterialCardView>(R.id.cardTelegram).setOnClickListener {
startActivity(Intent(Intent.ACTION_VIEW, getString(R.string.telegram_group_url).toUri()))
}

view.findViewById<MaterialCardView>(R.id.cardGithub).setOnClickListener {
startActivity(Intent(Intent.ACTION_VIEW, getString(R.string.github_repo_url).toUri()))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ internal class SettingsCategoriesFragment : Fragment(R.layout.fragment_settings_
"dark" -> getString(R.string.settings_theme_dark)
else -> getString(R.string.settings_theme_system)
}
val language = when (val stored = prefs.getString(SettingsPrefs.PREF_LANGUAGE, "").orEmpty()) {
val language = when (prefs.getString(SettingsPrefs.PREF_LANGUAGE, "").orEmpty()) {
"en" -> "EN"
"ru" -> "RU"
"fa" -> "FA"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ object CdnPullingChecker {
val successfulCount = successfulResponses.size
val actionableResponses = successfulResponses.filter { it.targetLabel in ACTIONABLE_TARGETS }
val actionableCount = actionableResponses.size
val actionableTargetCount = responses.count { it.targetLabel in ACTIONABLE_TARGETS }

val allIpv4s = successfulResponses.mapNotNull { it.ipv4 ?: it.ip?.takeIf { ip -> CdnPullingClient.looksLikeIpv4(ip) } }.distinct()
val allIpv6s = successfulResponses.mapNotNull { it.ipv6 ?: it.ip?.takeIf { ip -> CdnPullingClient.looksLikeIpv6(ip) } }.distinct()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ object DirectSignsChecker {
return SignalOutcome(detected = detected, needsReview = needsReview)
}

@Suppress("DEPRECATION")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

private fun collectProxyInfoProfiles(context: Context): ProxyProfileCollection {
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager

Expand Down Expand Up @@ -734,7 +735,7 @@ object DirectSignsChecker {
val hasDnsPathMismatch = comparison?.dnsPathMismatch == true
if (hasDnsPathMismatch) {
val transportOnly = comparison!!.usedCurlCompatibleFallback() &&
comparison!!.curlCompatible!!.transportDiagnostics.resolveStrategy != TunProbeResolveStrategy.KOTLIN_INJECTED
comparison.curlCompatible.transportDiagnostics.resolveStrategy != TunProbeResolveStrategy.KOTLIN_INJECTED
val confidence = if (transportOnly) EvidenceConfidence.MEDIUM else EvidenceConfidence.HIGH
evidence.add(
EvidenceItem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,8 +333,7 @@ object IndirectSignsChecker {
capsString = capsString,
routes = linkProperties.routes.map { route ->
RouteSnapshot(
destination = route.destination?.toString()
?: if (route.isDefaultRoute) "0.0.0.0/0" else "unknown",
destination = route.destination.toString(),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Потенциальная потеря fallback-логики "0.0.0.0/0"/"unknown"

gateway = route.gateway?.hostAddress?.takeUnless { it == "0.0.0.0" || it == "::" },
interfaceName = NetworkInterfaceNameNormalizer.canonicalName(
route.`interface` ?: linkProperties.interfaceName,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:Suppress("DEPRECATION")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

так нельзя делать, на весь файл suppress не вешают


package com.notcvnt.rknhardering.checker

import android.Manifest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ object VpnCheckRunner {
}

private object Fallbacks {
fun geoIp(context: Context, error: Throwable): CategoryResult = CategoryResult(
fun geoIp(@Suppress("UNUSED_PARAMETER") context: Context, error: Throwable): CategoryResult = CategoryResult(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

если unused то убирать надо, а не глушить warning

name = "GeoIP",
detected = false,
findings = listOf(Finding(error.message ?: error::class.java.simpleName, isError = true)),
Expand Down Expand Up @@ -243,18 +243,18 @@ object VpnCheckRunner {
needsReview = true,
findings = listOf(Finding(error.message ?: error::class.java.simpleName, isError = true)),
)
fun indirect(context: Context, error: Throwable): CategoryResult = CategoryResult(
fun indirect(@Suppress("UNUSED_PARAMETER") context: Context, error: Throwable): CategoryResult = CategoryResult(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже самое

name = "Indirect",
detected = false,
needsReview = true,
findings = listOf(Finding(error.message ?: error::class.java.simpleName, isError = true)),
)
fun location(context: Context, error: Throwable): CategoryResult = CategoryResult(
fun location(@Suppress("UNUSED_PARAMETER") context: Context, error: Throwable): CategoryResult = CategoryResult(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже самое

name = "Location",
detected = false,
findings = listOf(Finding(error.message ?: error::class.java.simpleName, isError = true)),
)
fun native(context: Context, error: Throwable): CategoryResult = CategoryResult(
fun native(@Suppress("UNUSED_PARAMETER") context: Context, error: Throwable): CategoryResult = CategoryResult(
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тоже самое

name = "Native",
detected = false,
findings = listOf(Finding(error.message ?: error::class.java.simpleName, isError = true)),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class AsnResolver(
const val BATCH_TIMEOUT_MS = 5_000L
const val PER_REQUEST_TIMEOUT_MS = 3_000L

fun default(context: Context, resolverConfig: DnsResolverConfig): AsnResolver {
fun default(@Suppress("UNUSED_PARAMETER") context: Context, resolverConfig: DnsResolverConfig): AsnResolver {
return AsnResolver(
lookup = { ip -> lookupViaIpapiIs(ip, resolverConfig) },
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ object IpConsensusBuilder {
channel = Channel.DIRECT,
source = "geoip",
targetGroup = null,
countryCode = geoIp.geoFacts?.countryCode,
asn = geoIp.geoFacts?.asn,
countryCode = geoIp.geoFacts.countryCode,
asn = geoIp.geoFacts.asn,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ internal class DirectDns(
}
}
if (!typeResolved && type == 1 && resolved.isEmpty() && lastFailure is UnknownHostException) {
throw lastFailure as UnknownHostException
throw lastFailure
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ object LocalSocketInspector {
@Suppress("DEPRECATION")
pm.getApplicationInfo(packageName, 0)
}
pm.getApplicationLabel(appInfo)?.toString()
pm.getApplicationLabel(appInfo).toString()
}.getOrNull()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ object NativeCurlBridge {
if (!isLibraryLoaded()) {
return NativeCurlResponse(localError = lastLoadErrorMessage() ?: "Native curl bridge is not loaded")
}
val activeCaBundle = request.caBundlePath?.takeIf { it.isNotBlank() } ?: caBundleInfo?.absolutePath
val activeCaBundle = request.caBundlePath.takeIf { it.isNotBlank() } ?: caBundleInfo?.absolutePath
if (activeCaBundle.isNullOrBlank()) {
return NativeCurlResponse(localError = "Native CA bundle is unavailable")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,7 @@ object UnderlyingNetworkProber {
)
}

@Suppress("DEPRECATION")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

убрать/передать функцию вместо глушения ошибки

private fun buildProbeEnvironment(context: Context): ProbeEnvironment {
val cm = context.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
val networks = cm.allNetworks.mapNotNull { network ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ object InstalledVpnAppDetector {

return resolveInfos
.asSequence()
.mapNotNull { it.loadLabel(pm)?.toString()?.trim() }
.mapNotNull { it.loadLabel(pm).toString().trim() }
.firstOrNull { it.isNotBlank() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ object VpnAppMetadataScanner {
@Suppress("DEPRECATION")
pm.getApplicationInfo(packageName, 0)
}
pm.getApplicationLabel(appInfo)?.toString()?.trim()?.takeIf { it.isNotBlank() }
pm.getApplicationLabel(appInfo).toString().trim().takeIf { it.isNotBlank() }
}.getOrNull()
}

Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/drawable/ic_telegram.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="#000000"
android:pathData="M9.78,18.65l0.28,-4.23l7.68,-6.92c0.34,-0.31 -0.07,-0.46 -0.52,-0.19L7.74,13.3L3.64,12c-0.88,-0.25 -0.89,-0.86 0.2,-1.3l15.97,-6.13c0.73,-0.33 1.43,0.18 1.15,1.3l-2.72,12.81c-0.19,0.91 -0.74,1.13 -1.5,0.71L12.6,16.3l-1.99,1.93C10.38,18.46 10.1,18.65 9.78,18.65Z"/>
</vector>
51 changes: 51 additions & 0 deletions app/src/main/res/layout/fragment_settings_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,57 @@
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:id="@+id/cardTelegram"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:clickable="true"
android:focusable="true"
app:cardBackgroundColor="?attr/colorSurfaceContainer"
app:strokeColor="?attr/colorOutlineVariant"
app:strokeWidth="1dp">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="16dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/settings_telegram"
android:textColor="?android:attr/textColorPrimary"
android:textSize="15sp"
android:textStyle="bold" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:text="@string/settings_telegram_desc"
android:textColor="?android:attr/textColorSecondary"
android:textSize="13sp" />
</LinearLayout>

<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:contentDescription="@null"
android:importantForAccessibility="no"
android:src="@drawable/ic_telegram"
app:tint="?android:attr/textColorSecondary" />
</LinearLayout>
</com.google.android.material.card.MaterialCardView>

<com.google.android.material.card.MaterialCardView
android:id="@+id/cardGithub"
android:layout_width="match_parent"
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-fa/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
<string name="settings_github">GitHub</string>
<string name="settings_matrix">Matrix</string>
<string name="settings_matrix_desc">RKN_Hardering:matrix.kangel.tech</string>
<string name="telegram_group_url">https://t.me/RKNHardering</string>
<string name="settings_telegram">Telegram</string>
<string name="settings_telegram_desc">@RKNHardering</string>
<string name="main_copy_diagnostics">کپی تشخیص</string>
<string name="main_diagnostics_copied">تشخیص کپی شد</string>
<string name="main_export">خروجی</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-ru/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@
<string name="settings_github_desc">xtclovver/RKNHardering</string>
<string name="settings_matrix">Matrix</string>
<string name="settings_matrix_desc">RKN_Hardering:matrix.kangel.tech</string>
<string name="telegram_group_url">https://t.me/RKNHardering</string>
<string name="settings_telegram">Telegram</string>
<string name="settings_telegram_desc">@RKNHardering</string>
<string name="settings_port_range_from">От</string>
<string name="settings_port_range_to">До</string>

Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@
<string name="settings_github">GitHub</string>
<string name="settings_matrix">Matrix</string>
<string name="settings_matrix_desc">RKN_Hardering:matrix.kangel.tech</string>
<string name="telegram_group_url">https://t.me/RKNHardering</string>
<string name="settings_telegram">Telegram</string>
<string name="settings_telegram_desc">@RKNHardering</string>
<string name="main_copy_diagnostics">复制诊断</string>
<string name="main_diagnostics_copied">诊断已复制</string>
<string name="main_export">导出</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@
<string name="settings_github_desc">xtclovver/RKNHardering</string>
<string name="settings_matrix">Matrix</string>
<string name="settings_matrix_desc">RKN_Hardering:matrix.kangel.tech</string>
<string name="telegram_group_url">https://t.me/RKNHardering</string>
<string name="settings_telegram">Telegram</string>
<string name="settings_telegram_desc">@RKNHardering</string>
<string name="settings_port_range_from">From</string>
<string name="settings_port_range_to">To</string>

Expand Down
3 changes: 2 additions & 1 deletion docs/README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# RKNHardering

<a href="https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech"><img src="https://img.shields.io/badge/matrix-%23000000?style=for-the-badge&logo=matrix&logoColor=white" alt="Matrix" width="200"></a>
<a href="https://t.me/RKNHardering"><img src="https://img.shields.io/badge/Telegram-2CA5E0?style=for-the-badge&logo=telegram&logoColor=white" alt="Telegram" width="200"></a>

Android app for detecting VPNs and proxies on a device. Implements the Roskomnadzor-style methodology for identifying censorship circumvention tools.

Expand All @@ -23,7 +24,7 @@ I am looking for people willing to help collect, organize, and test information
- **Bypassing native checks** (countering JNI-based checks through `/proc/self/maps`, `getifaddrs()`, and `dlsym`)
- **Masking installed applications** (hiding VPN app packages from `PackageManager`)

If you have expertise in these areas, please open an Issue or Pull Request, or reach out in the [Matrix chat](https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech) describing the method, the conditions under which it applies, and its limitations. Any information is valuable, from theoretical ideas to working PoCs.
If you have expertise in these areas, please open an Issue or Pull Request, or reach out in the [Matrix chat](https://matrix.to/#/%23RKN_Hardering:matrix.kangel.tech)/[Telegram](https://t.me/RKNHardering) describing the method, the conditions under which it applies, and its limitations. Any information is valuable, from theoretical ideas to working PoCs.

## Architecture

Expand Down
Loading
Loading