mirror of
https://github.com/dovecoteescapee/ByeDPIAndroid.git
synced 2024-12-21 22:06:22 +00:00
Support OOB and add custom fake SNI
This commit is contained in:
parent
fddf0b5c82
commit
52bf3cc272
@ -13,14 +13,22 @@ const enum demode DESYNC_METHODS[] = {
|
||||
DESYNC_NONE,
|
||||
DESYNC_SPLIT,
|
||||
DESYNC_DISORDER,
|
||||
DESYNC_FAKE
|
||||
DESYNC_FAKE,
|
||||
DESYNC_OOB,
|
||||
};
|
||||
|
||||
extern int NOT_EXIT;
|
||||
extern struct packet fake_tls, fake_http;
|
||||
|
||||
extern int get_default_ttl();
|
||||
|
||||
extern int get_addr(const char *str, struct sockaddr_ina *addr);
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_00024Companion_jniInit(JNIEnv *env, jobject thiz) {
|
||||
oob_data.data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
|
||||
JNIEnv *env,
|
||||
@ -36,6 +44,8 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
|
||||
jint split_position,
|
||||
jboolean split_at_host,
|
||||
jint fake_ttl,
|
||||
jstring fake_sni,
|
||||
jstring custom_oob_data,
|
||||
jboolean host_mixed_case,
|
||||
jboolean domain_mixed_case,
|
||||
jboolean host_remove_spaces,
|
||||
@ -52,6 +62,8 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
|
||||
if (get_addr(address, &s) < 0) {
|
||||
return -1;
|
||||
}
|
||||
(*env)->ReleaseStringUTFChars(env, ip, address);
|
||||
|
||||
s.in.sin_port = htons(port);
|
||||
|
||||
params.max_open = max_connections;
|
||||
@ -83,6 +95,34 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniCreateSocket(
|
||||
return get_e();
|
||||
}
|
||||
|
||||
if (params.attack == DESYNC_FAKE) {
|
||||
const char *sni = (*env)->GetStringUTFChars(env, fake_sni, 0);
|
||||
LOG(LOG_S, "fake_sni: %s", sni);
|
||||
int res = change_tls_sni(sni, fake_tls.data, fake_tls.size);
|
||||
(*env)->ReleaseStringUTFChars(env, fake_sni, sni);
|
||||
if (res) {
|
||||
fprintf(stderr, "error chsni\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (params.attack == DESYNC_OOB) {
|
||||
const char *oob = (*env)->GetStringUTFChars(env, custom_oob_data, 0);
|
||||
const size_t oob_len = strlen(oob);
|
||||
LOG(LOG_L, "custom_oob_data: %s", oob);
|
||||
oob_data.size = oob_len;
|
||||
LOG(LOG_L, "before free");
|
||||
free(oob_data.data);
|
||||
LOG(LOG_L, "after free");
|
||||
oob_data.data = malloc(oob_len);
|
||||
if (oob_data.data == NULL) {
|
||||
uniperror("malloc");
|
||||
return -1;
|
||||
}
|
||||
memcpy(oob_data.data, oob, oob_len);
|
||||
(*env)->ReleaseStringUTFChars(env, custom_oob_data, oob);
|
||||
}
|
||||
|
||||
LOG(LOG_S, "listen_socket, fd: %d", fd);
|
||||
return fd;
|
||||
}
|
||||
@ -106,4 +146,4 @@ Java_io_github_dovecoteescapee_byedpi_core_ByeDpiProxy_jniStopProxy(JNIEnv *env,
|
||||
return get_e();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,10 @@ class ByeDpiProxy {
|
||||
companion object {
|
||||
init {
|
||||
System.loadLibrary("byedpi")
|
||||
jniInit()
|
||||
}
|
||||
|
||||
private external fun jniInit(): Int
|
||||
}
|
||||
|
||||
private val mutex = Mutex()
|
||||
@ -49,6 +52,8 @@ class ByeDpiProxy {
|
||||
splitPosition = preferences.splitPosition,
|
||||
splitAtHost = preferences.splitAtHost,
|
||||
fakeTtl = preferences.fakeTtl,
|
||||
fakeSni = preferences.fakeSni,
|
||||
oobData = preferences.oobData,
|
||||
hostMixedCase = preferences.hostMixedCase,
|
||||
domainMixedCase = preferences.domainMixedCase,
|
||||
hostRemoveSpaces = preferences.hostRemoveSpaces,
|
||||
@ -77,6 +82,8 @@ class ByeDpiProxy {
|
||||
splitPosition: Int,
|
||||
splitAtHost: Boolean,
|
||||
fakeTtl: Int,
|
||||
fakeSni: String,
|
||||
oobData: String,
|
||||
hostMixedCase: Boolean,
|
||||
domainMixedCase: Boolean,
|
||||
hostRemoveSpaces: Boolean,
|
||||
|
@ -14,6 +14,8 @@ class ByeDpiProxyPreferences(
|
||||
splitPosition: Int? = null,
|
||||
splitAtHost: Boolean? = null,
|
||||
fakeTtl: Int? = null,
|
||||
fakeSni: String? = null,
|
||||
oobData: String? = null,
|
||||
hostMixedCase: Boolean? = null,
|
||||
domainMixedCase: Boolean? = null,
|
||||
hostRemoveSpaces: Boolean? = null,
|
||||
@ -32,6 +34,8 @@ class ByeDpiProxyPreferences(
|
||||
val splitPosition: Int = splitPosition ?: 3
|
||||
val splitAtHost: Boolean = splitAtHost ?: false
|
||||
val fakeTtl: Int = fakeTtl ?: 8
|
||||
val fakeSni: String = fakeSni ?: "www.w3c.org"
|
||||
val oobData: String = oobData ?: "a"
|
||||
val hostMixedCase: Boolean = hostMixedCase ?: false
|
||||
val domainMixedCase: Boolean = domainMixedCase ?: false
|
||||
val hostRemoveSpaces: Boolean = hostRemoveSpaces ?: false
|
||||
@ -52,6 +56,8 @@ class ByeDpiProxyPreferences(
|
||||
splitPosition = preferences.getString("byedpi_split_position", null)?.toIntOrNull(),
|
||||
splitAtHost = preferences.getBoolean("byedpi_split_at_host", false),
|
||||
fakeTtl = preferences.getString("byedpi_fake_ttl", null)?.toIntOrNull(),
|
||||
fakeSni = preferences.getString("byedpi_fake_sni", null),
|
||||
oobData = preferences.getString("byedpi_oob_data", null),
|
||||
hostMixedCase = preferences.getBoolean("byedpi_host_mixed_case", false),
|
||||
domainMixedCase = preferences.getBoolean("byedpi_domain_mixed_case", false),
|
||||
hostRemoveSpaces = preferences.getBoolean("byedpi_host_remove_spaces", false),
|
||||
@ -64,7 +70,8 @@ class ByeDpiProxyPreferences(
|
||||
None,
|
||||
Split,
|
||||
Disorder,
|
||||
Fake;
|
||||
Fake,
|
||||
OOB;
|
||||
|
||||
companion object {
|
||||
fun fromName(name: String): DesyncMethod {
|
||||
@ -73,6 +80,7 @@ class ByeDpiProxyPreferences(
|
||||
"split" -> Split
|
||||
"disorder" -> Disorder
|
||||
"fake" -> Fake
|
||||
"oob" -> OOB
|
||||
else -> throw IllegalArgumentException("Unknown desync method: $name")
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,13 @@
|
||||
<item name="split">Split</item>
|
||||
<item name="disorder">Disorder</item>
|
||||
<item name="fake">Fake</item>
|
||||
<item name="oob">Out-of-band</item>
|
||||
</array>
|
||||
<array name="byedpi_desync_methods_entries">
|
||||
<item name="none">none</item>
|
||||
<item name="split">split</item>
|
||||
<item name="disorder">disorder</item>
|
||||
<item name="fake">fake</item>
|
||||
<item name="oob">oob</item>
|
||||
</array>
|
||||
</resources>
|
||||
|
@ -49,4 +49,7 @@
|
||||
<string name="notification_title">ByeDPI</string>
|
||||
<string name="vpn_notification_content">VPN is running</string>
|
||||
<string name="proxy_notification_content">Proxy is running</string>
|
||||
<string name="general_category">General</string>
|
||||
<string name="byedpi_category">ByeDPI</string>
|
||||
<string name="about_category">About</string>
|
||||
</resources>
|
@ -4,8 +4,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:tag="settings_screen">
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="General">
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:title="@string/general_category">
|
||||
|
||||
<DropDownPreference
|
||||
android:key="app_theme"
|
||||
@ -23,10 +23,10 @@
|
||||
android:defaultValue="vpn"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="ByeDPI">
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:title="@string/byedpi_category">
|
||||
|
||||
<Preference
|
||||
android:key="byedpi_readme"
|
||||
@ -115,6 +115,18 @@
|
||||
android:defaultValue="8"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<com.takisoft.preferencex.EditTextPreference
|
||||
android:key="byedpi_fake_sni"
|
||||
android:title="SNI of fake packet"
|
||||
android:defaultValue="www.w3c.org"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<com.takisoft.preferencex.EditTextPreference
|
||||
android:key="byedpi_oob_data"
|
||||
android:title="OOB Data"
|
||||
android:defaultValue="a"
|
||||
app:useSimpleSummaryProvider="true" />
|
||||
|
||||
<CheckBoxPreference
|
||||
android:key="byedpi_host_mixed_case"
|
||||
android:title="@string/byedpi_host_mixed_case_setting"
|
||||
@ -147,10 +159,10 @@
|
||||
android:title="@string/byedpi_tlsrec_at_sni_setting"
|
||||
android:defaultValue="false" />
|
||||
|
||||
</PreferenceCategory>
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
android:title="About">
|
||||
<androidx.preference.PreferenceCategory
|
||||
android:title="@string/about_category">
|
||||
|
||||
<Preference
|
||||
android:key="version"
|
||||
@ -167,6 +179,6 @@
|
||||
android:data="https://github.com/dovecoteescapee/ByeDPIAndroid" />
|
||||
</Preference>
|
||||
|
||||
</PreferenceCategory>
|
||||
</androidx.preference.PreferenceCategory>
|
||||
|
||||
</PreferenceScreen>
|
||||
|
Loading…
Reference in New Issue
Block a user