我如何在Android保护中找到复活节彩蛋,却没有在Google找到工作

Google喜欢复活节彩蛋。 他非常喜欢,您几乎可以在公司的每种产品中找到它们。 Android的复活节彩蛋传统源于操作系统的第一个版本(我想每个人都知道,如果在设置中多次单击与Android版本相同的行,将会发生什么情况)。

但是也有可能在最意想不到的地方发现了复活节彩蛋。 甚至还有这样的传说:一旦程序员使用Google“互斥锁”,而不是搜索结果,进入foo.bar页面,解决了所有问题并在Google找到了工作。

赛事重组
图片

这是我发生的同样惊人的故事(只有没有幸福的结局)。 隐藏的消息(绝对不可能),反向Java代码和本机库,秘密的虚拟机,Google的采访-所有这些都被削减了。

机器人卫士


一个无聊的夜晚,我恢复了出厂设置,并开始重新配置智能手机。 首先,新鲜的Android要求我输入我的Google帐户。 “有趣,但是Android中的注册和登录是如何发生的?”我想。 傍晚不再闷闷不乐。

为了拦截和分析流量,我使用了PortSwigger的Burp Suite。 一个免费的社区版本就足够了。 为了能够看到https请求,首先需要在设备上安装PortSwigger的证书。 为了进行测试,我在我的垃圾箱中发现了一个装有Android 4.4的8年历史的三星GalaxyS。 如果您有新鲜事物,可能会遇到https:证书固定等问题。

实际上,访问Google API并没有特别有趣的地方。 设备发送有关其自身的数据,反过来接收令牌……唯一无法理解的时刻是对反滥用服务的POST请求。



发出此请求后,在不起眼的参数中,出现了一个神秘的参数,名称为droidguard_result 。 这是一个很长的Base64字符串:



DroidGuard是Google的一种机制,用于将机器人和仿真器与真实设备分开。 SafetyNet在其工作中还使用了DroidGuard的数据。 Google对于浏览器也有类似的东西-Botguard。

但是,这些数据是什么,在其中传输了什么? 现在我们将了解。

协议缓冲区


链接www.googleapis.com/androidantiabuse/v1/x/create的位置是哪里? alt = PROTO&key = AIzaSyBofcZsgLSS7BOnBjZPEkk4rYwzOIz-lTI的确切来源是谁? 很容易发现此链接直接以这种形式存储在混淆的Google Play服务类之一中:

public bdd(Context var1, bdh var2) {
  this(var1, "https://www.googleapis.com/androidantiabuse/v1/x/create?alt=PROTO&key=AIzaSyBofcZsgLSS7BOnBjZPEkk4rYwzOIz-lTI", var2);
}

Burp, Content-Type POST — application/x-protobuf (Google Protocol Buffers, Google). json, — , .

protocol buffers :

  • .proto
  • .proto , protoc ( Android Java)

protobuf . — - protobuf .proto . — protoc- Google Play Services. .

apk Google Play Services , ( , apk ). dex2jar .dex .jar . Fernflower JetBrains. IntelliJ IDEA ( Android Studio), Android Studio . proguard , Java protobuf .

, protobuf Build.* (, ):

...
var3.a("4.0.33 (910055-30)");
a(var3, "BOARD", Build.BOARD);
a(var3, "BOOTLOADER", Build.BOOTLOADER);
a(var3, "BRAND", Build.BRAND);
a(var3, "CPU_ABI", Build.CPU_ABI);
a(var3, "CPU_ABI2", Build.CPU_ABI2);
a(var3, "DEVICE", Build.DEVICE);
...

, , protobuf . , . , :

if (!var7.d()) {
    throw new bdf("byteCode");
}
if (!var7.f()) {
    throw new bdf("vmUrl");
}
if (!var7.h()) {
    throw new bdf("vmChecksum");
}
if (!var7.j()) {
	throw new bdf("expiryTimeSecs");
}

, : byteCode, vmUrl, vmChecksum expiryTimeSecs. .

Google Play Services , , Build.* ( ). - , .

:
00:06:26.761 [main] INFO d.a.response.AntiabuseResponse — byteCode size: 34446
00:06:26.761 [main] INFO d.a.response.AntiabuseResponse — vmChecksum: C15E93CCFD9EF178293A2334A1C9F9B08F115993
00:06:26.761 [main] INFO d.a.response.AntiabuseResponse — vmUrl: www.gstatic.com/droidguard/C15E93CCFD9EF178293A2334A1C9F9B08F115993
00:06:26.761 [main] INFO d.a.response.AntiabuseResponse — expiryTimeSecs: 10

. , vmUrl.

apk


.apk , SHA-1 . apk — 150 . : Android , 270 .



DroidGuardService, Google Play Services, , , .dex .so , reflection, com.google.ccc.abuse.droidguard.DroidGuard. - , DroidGuardService DroidGuard Droidguasso. Droidguasso — .

, DroidGuard — JNI .so . ABI , protobuf CPU_ABI: armeabi, x86, mips.

DroidGuardService - DroidGuard. DroidGuard, byteCode protobuf , , . droidguard_result.

, DroidGuard DroidGuardService ( apk, ). .dex APK, .jar . , DroidGuard . loadDroidGuardLibrary():

static
  {
    try
    {
      loadDroidGuardLibrary();
    }
    catch (Exception ex)
    {
      throw new RuntimeException(ex);
    }
  }

, loadDroidGuardLibrary() library.txt ( .apk ) System.load(String filename). , - apk, library.txt .so . .so lib System.loadLibrary(String libname).

. smali/baksmali — / dex . classes.dex .smali . com.google.ccc.abuse.droidguard.DroidGuard , System.loadLibrary("droidguard") loadDroidGuardLibrary(). smali , :

.method static constructor <clinit>()V
    .locals 1
    const-string v0, "droidguard"
    invoke-static {v0}, Ljava/lang/System;->loadLibrary(Ljava/lang/String;)V
    return-void
.end method

baksmali .dex, .jar. jar , . , .

DroidGuard . — , anti-abuse DroidGuard.

private fun runDroidguard() {
        var byteCode: ByteArray? = loadBytecode("bytecode.base64");
        byteCode?.let {
            val droidguard = DroidGuard(applicationContext, "addAccount", it)
            val params = mapOf("dg_email" to "test@gmail.com", "dg_gmsCoreVersion" to "910055-30",
                "dg_package" to "com.google.android.gms", "dg_androidId" to UUID.randomUUID().toString())
            droidguard.init()
            val result = droidguard.ss(params)
            droidguard.close()
        }
    }

Android Studio , DroidGuard.



initNative() java-: hasSystemFeature(), getMemoryInfo(), getPackageInfo()… -, . , , .so .

libdroidguard.so


, , .dex .jar . , Hex-Rays IDA arm x86, . arm, . , x86 .

, Hex-Rays IDA, - c-. Java_com_google_ccc_abuse_droidguard_DroidGuard_ssNative, :

__int64 __fastcall Java_com_google_ccc_abuse_droidguard_DroidGuard_initNative(int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8, int a9)  
...
  v14 = (*(_DWORD *)v9 + 684))(v9, a5);  
  v15 = (*(_DWORD *)v9 + 736))(v9, a5, 0);
...

. , . JNI, Android NDK jni.h. , JNI — JNIEnv* jobject (this). Java DroidGuard. , JNI :

__int64 __fastcall Java_com_google_ccc_abuse_droidguard_DroidGuard_initNative(_JNIEnv *env, jobject thiz, jobject context, jstring flow, jbyteArray byteCode, jobject runtimeApi, jobject extras, jint loggingFd, int runningInAppSide)
{
...
  programLength = _env->functions->GetArrayLength)(_env, byteCode);  
  programBytes = (jbyte *)_env->functions->GetByteArrayElements)(_env, byteCode, 0);
...

, anti-abuse , . , « ?» . -, — . AES , - . — , . , 70: int, byte, , java , , if-goto .

Wake up, Neo


- . : ( ) , . , Java.

- . , , dlsym . java 5 25 - anti-abuse . 26- -. , .
Virtual Machine command #26
Method invocation vm->vm_method_table[2 * 0x77]
Method vmMethod_readString
index is 0x9d
string length is 0x0066
(new key is generated)
encoded string bytes are EB 4E E6 DC 34 13 35 4A DD 55 B3 91 33 05 61 04 C0 54 FD 95 2F 18 72 04 C1 55 E1 92 28 11 66 04 DD 4F B3 94 33 04 35 0A C1 4E B2 DB 12 17 79 4F 92 55 FC DB 33 05 35 45 C6 01 F7 89 29 1F 71 43 C7 40 E1 9F 6B 1E 70 48 DE 4E B8 CD 75 44 23 14 85 14 A7 C2 7F 40 26 42 84 17 A2 BB 21 19 7A 43 DE 44 BD 98 29 1B
decoded string bytes are 59 6F 75 27 72 65 20 6E 6F 74 20 6A 75 73 74 20 72 75 6E 6E 69 6E 67 20 73 74 72 69 6E 67 73 20 6F 6E 20 6F 75 72 20 2E 73 6F 21 20 54 61 6C 6B 20 74 6F 20 75 73 20 61 74 20 64 72 6F 69 64 67 75 61 72 64 2D 68 65 6C 6C 6F 2B 36 33 32 36 30 37 35 34 39 39 36 33 66 36 36 31 40 67 6F 6F 67 6C 65 2E 63 6F 6D
decoded string value is (You're not just running strings on our .so! Talk to us at droidguard@google.com)

, . , , . , , anti-abuse -. 25-30 - . , . , , . «droidguard+tag@google.com»: anti-abuse tag .
droidguard@google.com: Don't be a stranger!
You got in! Talk to us at droidguard@google.com
Greetings from droidguard@google.com intrepid traveller! Say hi!
Was it easy to find this? droidguard@google.com would like to know
The folks at droidguard@google.com would appreciate hearing from you!
What's all this gobbledygook? Ask droidguard@google.com… they'd know!
Hey! Fancy seeing you here. Have you spoken to droidguard@google.com yet?
You're not just running strings on our .so! Talk to us at droidguard@google.com

, ? , DroidGuard Google, .


. , . , - . , . , Hex-Rays IDA, . .

Java . jelf ( ELF ) Java_com_google_ccc_abuse_droidguard_DroidGuard_initNative , Capstone ( , , Java) .

, DroidGuard: anti-abuse , apk, , , , -. , Google. glassdoor . .

. DroidGuard : « ?».



«» — . Google , DroidGuard: Android ( !). DroidGuard. .


. DroidGuard . ? !

Google . , — hr . .

Google . , Google Doc , . «» coursera, hackerrank, …

. , — . Google Doc IDE. , . , , 5 . — . — , . , …



… . , , . . Base64 . Base64. , Base64, Java.

Google
, , ! . , .

3 , , . Google .

DroidGuard , , . , . , : , .

, Google . , ( , ). .

Source: https://habr.com/ru/post/zh-CN442872/


All Articles