Update cloudflare interceptor and android studio

This commit is contained in:
inorichi 2018-04-05 10:36:29 +02:00
parent d38cd2547a
commit 95e60ed775
4 changed files with 9 additions and 10 deletions

View file

@ -30,7 +30,7 @@ ext {
android { android {
compileSdkVersion 27 compileSdkVersion 27
buildToolsVersion "27.0.2" buildToolsVersion '27.0.3'
publishNonDefault true publishNonDefault true
defaultConfig { defaultConfig {

View file

@ -47,19 +47,18 @@ class CloudflareInterceptor : Interceptor {
} }
val js = operation val js = operation
.replace(Regex("""a\.value =(.+?) \+.*"""), "$1") .replace(Regex("""a\.value = (.+ \+ t\.length).+"""), "$1")
.replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "") .replace(Regex("""\s{3,}[a-z](?: = |\.).+"""), "")
.replace("t.length", "${domain.length}")
.replace("\n", "") .replace("\n", "")
val result = (duktape.evaluate(js) as Double).toInt() val result = (duktape.evaluate(js) as Double)
val answer = "${result + domain.length}"
val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!! val cloudflareUrl = HttpUrl.parse("${url.scheme()}://$domain/cdn-cgi/l/chk_jschl")!!
.newBuilder() .newBuilder()
.addQueryParameter("jschl_vc", challenge) .addQueryParameter("jschl_vc", challenge)
.addQueryParameter("pass", pass) .addQueryParameter("pass", pass)
.addQueryParameter("jschl_answer", answer) .addQueryParameter("jschl_answer", "$result")
.toString() .toString()
val cloudflareHeaders = originalRequest.headers() val cloudflareHeaders = originalRequest.headers()
@ -71,4 +70,4 @@ class CloudflareInterceptor : Interceptor {
} }
} }
} }

View file

@ -7,7 +7,7 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.1.0'
classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0'
classpath 'com.github.zellius:android-shortcut-gradle-plugin:0.1.2' classpath 'com.github.zellius:android-shortcut-gradle-plugin:0.1.2'
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View file

@ -1,6 +1,6 @@
#Wed Oct 25 23:17:30 CEST 2017 #Thu Apr 05 09:21:32 CEST 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip