XCTF新手区mobile之Ph0en1x-100

安卓题的native是真的多。。。。。

将APK上JEB:

看onclick方法:
public void onGoClick(View arg5) {
        if(this.getSecret(this.getFlag()).equals(this.getSecret(this.encrypt(this.etFlag.getText().toString())))) {
            Toast.makeText(((Context)this), "Success", 1).show();
        }
        else {
            Toast.makeText(((Context)this), "Failed", 1).show();
        }
    }

两边都有getSecrect方法,那这个方法暂时就不用看了。

看getFlag()和encrypt(),看到又是native方法,这是得多爱IDA。。。。

拖进IDA无脑F5:

encrypt:

//点击a1,按下y,输入JNIEnv*就能得到以下伪代码效果
int __cdecl Java_com_ph0en1x_android_1crackme_MainActivity_encrypt(JNIEnv *a1, int a2, int a3)
{
  size_t v3; // esi
  const char *s; // edi

  v3 = 0;
  for ( s = (*a1)->GetStringUTFChars(a1, (jstring)a3, 0); v3 < strlen(s); --s[v3++] )
    ;
  return (*a1)->NewStringUTF(a1, s);
}

大胆推测指针s是传入的字符串。

看for循环:当v3小于s的长度时循环执行,分号后面是--s[v3++]

这里可以看到s[v3++]自减了1.相当于给每个字符的ascii码减了1.

再看getFlag方法:

int __cdecl Java_com_ph0en1x_android_1crackme_MainActivity_getFlag(JNIEnv *a1)
{
  signed int v1; // esi
  char *v2; // edi
  char v3; // al
  int result; // eax
  int v5; // [esp+26h] [ebp-46h]
  int v6; // [esp+2Ah] [ebp-42h]
  int v7; // [esp+2Eh] [ebp-3Eh]
  __int16 v8; // [esp+32h] [ebp-3Ah]
  int v9; // [esp+34h] [ebp-38h]
  int v10; // [esp+38h] [ebp-34h]
  int v11; // [esp+3Ch] [ebp-30h]
  int v12; // [esp+40h] [ebp-2Ch]
  int v13; // [esp+44h] [ebp-28h]
  int v14; // [esp+48h] [ebp-24h]
  int v15; // [esp+4Ch] [ebp-20h]
  int v16; // [esp+50h] [ebp-1Ch]
  int v17; // [esp+54h] [ebp-18h]
  int v18; // [esp+58h] [ebp-14h]
  unsigned int v19; // [esp+5Ch] [ebp-10h]

  v1 = 38;
  v2 = (char *)&v18 + 2;
  v9 = 1279407662;
  v10 = 987807583;
  v19 = __readgsdword(0x14u);
  v11 = 1663091624;
  v12 = 482391945;
  v13 = 683820061;
  v14 = 235072895;
  v15 = -1735432611;
  v16 = 382777269;
  v17 = -67599539;
  v18 = 4670209;
  v5 = 1819043144;
  v6 = 1750081647;
  v7 = 829318448;
  v8 = 120;
  do
  {
    v3 = *v2--;
    v2[1] = (*((_BYTE *)&v5 + v1-- % 13) ^ (v3 + 1 - *v2)) - 1;
  }
  while ( v1 );
  LOBYTE(v9) = (v9 ^ 0x48) - 1;
  result = (int)(*a1)->NewStringUTF(a1, (const char *)&v9);
  if ( __readgsdword(0x14u) != v19 )
    sub_4B0();
  return result;
}

这一大坨代码对于我这种C学的很差汇编早还给老师的菜鸡来说难如登天,我根本不知道它在写什么,尝试用动态调试看看:

接下来学习一波动态调试。

------未完待续---------

发布了118 篇原创文章 · 获赞 38 · 访问量 12万+

猜你喜欢

转载自blog.csdn.net/shuaicenglou3032/article/details/104429452
今日推荐