commit 3fa3a182ec0d3383011f31e74f382b8d17d59582 Author: kulikov Date: Thu Mar 19 17:06:56 2026 +0100 initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/README.md b/README.md new file mode 100644 index 0000000..d14dfe6 --- /dev/null +++ b/README.md @@ -0,0 +1,99 @@ +# Whitelist Bypass + +Tunnels internet traffic through VK call DataChannels to bypass government whitelist censorship. + +## How it works + +VK calls use WebRTC with an SFU (Selective Forwarding Unit). The SFU forwards all SCTP data channels between participants without inspecting them. This tool creates a custom DataChannel (id:2) alongside VK's built-in animoji channel (id:1) and uses it as a bidirectional data pipe. + +``` +Joiner (censored) Creator (free internet) + +All apps + | +VpnService (captures all traffic) + | +tun2socks (IP -> TCP) + | +SOCKS5 proxy (Go, :1080) + | +WebSocket (:9000) + | +WebView (VK call) Browser (VK call) + | | +DataChannel id:2 <--- VK SFU ---> DataChannel id:2 + | + WebSocket (:9000) + | + Go relay + | + Internet +``` + +Traffic goes through VK's TURN servers (155.212.x.x:19302) which are whitelisted. To the network firewall it looks like a normal VK call. + +## Components + +- `hook.js` - Injected into VK call page on both sides. Hooks RTCPeerConnection, creates tunnel DataChannel, bridges to local WebSocket. +- `relay/` - Go binary and gomobile library. SOCKS5 proxy + WebSocket server + tun2socks. +- `app/` - Android app. WebView + VpnService + Go relay (.aar). + +## Setup + +### Creator side (free internet, PC) + +1. Build the relay: +``` +cd relay +go build -o relay . +``` + +2. Start it: +``` +./relay --mode creator +``` + +3. Open Chrome, go to Sources -> Snippets, create snippet with contents of `hook.js`, run it. + +4. Create a VK call, copy the join link, send it to the joiner. + +### Joiner side (censored, Android) + +1. Build the Go library: +``` +./build-go.sh +``` + +2. Build the APK: +``` +./build-app.sh +``` + +3. Install `whitelist-bypass.apk` on the phone. + +4. Set the VK call link in `MainActivity.kt` (`VK_CALL_LINK` constant) or paste it in the app. + +5. The app joins the call, establishes the tunnel, starts VPN. All device traffic flows through the VK call. + +### Joiner side (censored, PC) + +1. Start the relay: +``` +./relay --mode joiner +``` + +2. Open Chrome, go to Sources -> Snippets, create snippet with contents of `hook.js`, run it. + +3. Navigate to the VK call link. + +4. Wait for `=== CALL CONNECTED ===` and `WebSocket connected to Go relay`. + +5. Set system proxy to `socks5://127.0.0.1:1080`. + +## Build requirements + +- Go 1.21+ +- gomobile (`go install golang.org/x/mobile/cmd/gomobile@latest`) +- gobind (`go install golang.org/x/mobile/cmd/gobind@latest`) +- Android SDK + NDK 27 +- Java 11+ diff --git a/app/.gitignore b/app/.gitignore new file mode 100644 index 0000000..87f66f5 --- /dev/null +++ b/app/.gitignore @@ -0,0 +1,10 @@ +*.iml +.gradle +/local.properties +.idea/ +.DS_Store +/build +/captures +.externalNativeBuild +.cxx +local.properties diff --git a/app/app/.gitignore b/app/app/.gitignore new file mode 100644 index 0000000..42afabf --- /dev/null +++ b/app/app/.gitignore @@ -0,0 +1 @@ +/build \ No newline at end of file diff --git a/app/app/build.gradle.kts b/app/app/build.gradle.kts new file mode 100644 index 0000000..1c4d6ad --- /dev/null +++ b/app/app/build.gradle.kts @@ -0,0 +1,63 @@ +plugins { + alias(libs.plugins.android.application) + alias(libs.plugins.kotlin.android) +} + +android { + namespace = "bypass.whitelist" + compileSdk { + version = release(36) + } + + defaultConfig { + applicationId = "bypass.whitelist" + minSdk = 23 + targetSdk = 36 + versionCode = 1 + versionName = "1.0" + + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + + signingConfigs { + getByName("debug") { + storeFile = file("../debug.keystore") + storePassword = "android" + keyAlias = "debug" + keyPassword = "android" + } + } + + buildTypes { + debug { + signingConfig = signingConfigs.getByName("debug") + } + release { + isMinifyEnabled = false + signingConfig = signingConfigs.getByName("debug") + proguardFiles( + getDefaultProguardFile("proguard-android-optimize.txt"), + "proguard-rules.pro" + ) + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_11 + targetCompatibility = JavaVersion.VERSION_11 + } + kotlinOptions { + jvmTarget = "11" + } +} + +dependencies { + implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.aar")))) + implementation(libs.androidx.core.ktx) + implementation(libs.androidx.appcompat) + implementation(libs.material) + implementation(libs.androidx.activity) + implementation(libs.androidx.constraintlayout) + testImplementation(libs.junit) + androidTestImplementation(libs.androidx.junit) + androidTestImplementation(libs.androidx.espresso.core) +} \ No newline at end of file diff --git a/app/app/libs/mobile.aar b/app/app/libs/mobile.aar new file mode 100644 index 0000000..ffde08c Binary files /dev/null and b/app/app/libs/mobile.aar differ diff --git a/app/app/proguard-rules.pro b/app/app/proguard-rules.pro new file mode 100644 index 0000000..481bb43 --- /dev/null +++ b/app/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile \ No newline at end of file diff --git a/app/app/src/androidTest/java/bypass/whitelist/ExampleInstrumentedTest.kt b/app/app/src/androidTest/java/bypass/whitelist/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..9445f5f --- /dev/null +++ b/app/app/src/androidTest/java/bypass/whitelist/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package bypass.whitelist + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("bypass.whitelist", appContext.packageName) + } +} \ No newline at end of file diff --git a/app/app/src/main/AndroidManifest.xml b/app/app/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c5d1505 --- /dev/null +++ b/app/app/src/main/AndroidManifest.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/app/src/main/assets/hook.js b/app/app/src/main/assets/hook.js new file mode 100644 index 0000000..d46acf0 --- /dev/null +++ b/app/app/src/main/assets/hook.js @@ -0,0 +1,162 @@ +(() => { + 'use strict'; + + const WS_URL = 'ws://127.0.0.1:9000/ws'; + const log = (...args) => console.log('[VK-HOOK]', ...args); + const peers = []; + let activeWS = null; + let activeDC = null; + let dcOpen = false; + let wsOpen = false; + + const OrigPC = window.RTCPeerConnection; + window.RTCPeerConnection = function (config) { + log('New PeerConnection created'); + const pc = new OrigPC(config); + peers.push(pc); + + pc.addEventListener('connectionstatechange', () => { + log('Connection state:', pc.connectionState); + if (pc.connectionState === 'connected') { + log('=== CALL CONNECTED ==='); + setupDC(pc); + } + }); + + return pc; + }; + + Object.keys(OrigPC).forEach((key) => { + window.RTCPeerConnection[key] = OrigPC[key]; + }); + window.RTCPeerConnection.prototype = OrigPC.prototype; + + function setupDC(pc) { + const dc = pc.createDataChannel('tunnel', { negotiated: true, id: 2 }); + dc.binaryType = 'arraybuffer'; + bindDC(dc); + } + + function bindDC(dc) { + if (activeDC && activeDC !== dc && activeDC.readyState === 'open') { + activeDC.close(); + } + activeDC = dc; + dcOpen = false; + + dc.onopen = () => { + if (dc !== activeDC) return; + log('DataChannel open'); + dcOpen = true; + connectWS(); + }; + + dc.onclose = () => { + if (dc !== activeDC) return; + log('DataChannel closed'); + dcOpen = false; + }; + + let bwRecvBytes = 0; + let bwRecvStart = 0; + let bwMode = false; + + dc.onmessage = (e) => { + if (dc !== activeDC) return; + if (bwMode) { + if (e.data instanceof ArrayBuffer) { + if (bwRecvStart === 0) bwRecvStart = performance.now(); + bwRecvBytes += e.data.byteLength; + return; + } + if (typeof e.data === 'string' && e.data === 'bw:done') { + const elapsed = (performance.now() - bwRecvStart) / 1000; + const kbps = (bwRecvBytes * 8 / 1024 / elapsed).toFixed(1); + log('=== RECV COMPLETE: ' + (bwRecvBytes/1024).toFixed(1) + ' KB in ' + elapsed.toFixed(2) + 's = ' + kbps + ' kbps ==='); + bwRecvBytes = 0; + bwRecvStart = 0; + bwMode = false; + return; + } + } + if (typeof e.data === 'string' && e.data === 'bw:start') { + bwMode = true; + bwRecvBytes = 0; + bwRecvStart = 0; + return; + } + if (activeWS && wsOpen) { + activeWS.send(e.data); + } + }; + } + + function connectWS() { + if (activeWS && activeWS.readyState === WebSocket.OPEN) { + activeWS.close(); + } + const ws = new WebSocket(WS_URL); + ws.binaryType = 'arraybuffer'; + activeWS = ws; + + ws.onopen = () => { + if (ws !== activeWS) return; + log('WebSocket connected to Go relay'); + wsOpen = true; + if (typeof AndroidBridge !== 'undefined' && AndroidBridge.onTunnelReady) { + AndroidBridge.onTunnelReady(); + } + }; + + ws.onclose = () => { + if (ws !== activeWS) return; + wsOpen = false; + if (dcOpen) { + log('WebSocket disconnected, reconnecting in 2s...'); + setTimeout(() => { + if (dcOpen && ws === activeWS) connectWS(); + }, 2000); + } + }; + + ws.onerror = () => { + if (ws !== activeWS) return; + log('WebSocket error'); + }; + + ws.onmessage = (e) => { + if (activeDC && dcOpen) { + activeDC.send(e.data); + } + }; + } + + window.__vkHook = { peers, log }; + window.__vkHook.runBandwidthTest = (totalMB = 1) => { + if (!dcOpen || !activeDC) { log('DC not open'); return; } + const chunkSize = 16384; + const chunk = new ArrayBuffer(chunkSize); + const totalBytes = totalMB * 1024 * 1024; + let sent = 0; + const start = performance.now(); + activeDC.send('bw:start'); + log('Starting bandwidth test: ' + totalMB + ' MB...'); + const sendBatch = () => { + while (sent < totalBytes) { + if (activeDC.bufferedAmount > 512 * 1024) { + setTimeout(sendBatch, 5); + return; + } + activeDC.send(chunk); + sent += chunkSize; + } + activeDC.send('bw:done'); + const elapsed = (performance.now() - start) / 1000; + const kbps = (totalBytes * 8 / 1024 / elapsed).toFixed(1); + log('=== SEND COMPLETE: ' + (totalBytes/1024).toFixed(1) + ' KB in ' + elapsed.toFixed(2) + 's = ' + kbps + ' kbps ==='); + }; + sendBatch(); + }; + + log('Hook installed. Now open the VK call link.'); +})(); diff --git a/app/app/src/main/java/bypass/whitelist/MainActivity.kt b/app/app/src/main/java/bypass/whitelist/MainActivity.kt new file mode 100644 index 0000000..2a66fa8 --- /dev/null +++ b/app/app/src/main/java/bypass/whitelist/MainActivity.kt @@ -0,0 +1,189 @@ +package bypass.whitelist + +import android.util.Log +import android.annotation.SuppressLint +import android.content.Intent +import android.net.VpnService +import android.os.Bundle +import android.webkit.* +import android.widget.Button +import android.widget.EditText +import android.widget.TextView +import androidx.activity.enableEdgeToEdge +import androidx.activity.result.contract.ActivityResultContracts +import androidx.appcompat.app.AppCompatActivity +import androidx.core.view.ViewCompat +import androidx.core.view.WindowInsetsCompat +import mobile.Mobile +import mobile.LogCallback + +class MainActivity : AppCompatActivity() { + + companion object { + private const val VK_CALL_LINK = "https://vk.com/call/join/6kGvQofFiOyjuK0w_BeQvAx8gTsUg0PKUVzWt0VmkIg" // Open call page on app start + } + + private lateinit var webView: WebView + private lateinit var logView: TextView + private lateinit var urlInput: EditText + + private val vpnLauncher = registerForActivityResult( + ActivityResultContracts.StartActivityForResult() + ) { result -> + if (result.resultCode == RESULT_OK) { + startVpnService() + } else { + appendLog("VPN permission denied") + } + } + + private val hookJs by lazy { + assets.open("hook.js").bufferedReader().readText() + } + + @SuppressLint("SetJavaScriptEnabled") + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + enableEdgeToEdge() + setContentView(R.layout.activity_main) + ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main)) { v, insets -> + val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars()) + v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom) + insets + } + + logView = findViewById(R.id.logView) + urlInput = findViewById(R.id.urlInput) + webView = findViewById(R.id.webView) + + setupWebView() + startRelay() + + val goButton = findViewById