DonnyBrasco25 / androguard

Automatically exported from code.google.com/p/androguard
Apache License 2.0
0 stars 0 forks source link

androsim can not handle obfuscated methods very well #132

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
I test with 1.APK and 2.APK, actually they are same, but 2.APK is obfuscated in 
code.
the command is like: ./androsim.py -i 1.APK 2.APK -d
with the output, I found most obfuscated methods are tagged as "New methods" or 
"Delete methods", while expected output is in "Similar methods" or "identical 
methods".

I use latest androguard 1.9

I list the similar method here:
this is not obfuscated one:
public String getTalkInPhone(int paramInt)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("\n--------------------------------\n");
    localStringBuilder.append("\n[通话信息]\n");
    try
    {
      ContentResolver localContentResolver = getContentResolver();
      String[] arrayOfString = { "_id", "name", "number", "new", "type", "date", "duration" };
      localCursor = localContentResolver.query(CallLog.Calls.CONTENT_URI, arrayOfString, null, null, "date DESC");
      boolean bool = localCursor.moveToFirst();
      int i = 0;
      if (bool)
      {
        str1 = localCursor.getString(localCursor.getColumnIndex("name"));
        if (str1 == null)
          str1 = "【未知】";
        str2 = localCursor.getString(localCursor.getColumnIndex("number"));
        localStringBuilder.append("\n[");
        int j = localCursor.getInt(localCursor.getColumnIndex("type"));
        if (j == 1)
          localStringBuilder.append("被叫: " + str2 + "(" + str1 + ")" + "->我, ");
        while (true)
        {
          long l = localCursor.getLong(localCursor.getColumnIndex("duration"));
          String str3 = localCursor.getString(localCursor.getColumnIndex("date"));
          SimpleDateFormat localSimpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA);
          String str4 = localSimpleDateFormat.format(new Date(Long.parseLong(str3)));
          localStringBuilder.append("时长: " + l + "s,");
          localStringBuilder.append("日期: " + str4 + "]");
          i++;
          if (i < paramInt)
            break label529;
          localStringBuilder.append("\n此处省略...条\n");
          localStringBuilder.append("\n--------------------------------\n");
          localStringBuilder.append("\n-END-\n");
          return localStringBuilder.toString();
          if (j != 2)
            break;
          localStringBuilder.append("主叫: 我->" + str2 + "(" + str1 + ")" + ", ");
        }
      }
    }
    catch (SQLiteException localSQLiteException)
    {
      while (true)
      {
        Cursor localCursor;
        String str1;
        String str2;
        MyLog.v("SQLiteException in getTalkInPhone", localSQLiteException.getMessage());
        continue;
        localStringBuilder.append("未接: " + str2 + "(" + str1 + ")" + "->我, ");
        continue;
        label529: if (!localCursor.moveToNext())
        {
          continue;
          localStringBuilder.append("无通话记录!");
        }
      }
    }
  }

this is obfuscated one:
private String d(int paramInt)
  {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("\n--------------------------------\n");
    localStringBuilder.append("\n[通话信息]\n");
    try
    {
      ContentResolver localContentResolver = getContentResolver();
      String[] arrayOfString = { "_id", "name", "number", "new", "type", "date", "duration" };
      localCursor = localContentResolver.query(CallLog.Calls.CONTENT_URI, arrayOfString, null, null, "date DESC");
      if (localCursor.moveToFirst())
      {
        i1 = 0;
        str1 = localCursor.getString(localCursor.getColumnIndex("name"));
        if (str1 == null)
          str1 = "【未知】";
        str2 = localCursor.getString(localCursor.getColumnIndex("number"));
        localStringBuilder.append("\n[");
        int i2 = localCursor.getInt(localCursor.getColumnIndex("type"));
        if (i2 == 1)
          localStringBuilder.append("被叫: " + str2 + "(" + str1 + ")->我, ");
        while (true)
        {
          long l1 = localCursor.getLong(localCursor.getColumnIndex("duration"));
          String str3 = localCursor.getString(localCursor.getColumnIndex("date"));
          String str4 = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss", Locale.CHINA).format(new Date(Long.parseLong(str3)));
          localStringBuilder.append("时长: " + l1 + "s,");
          localStringBuilder.append("日期: " + str4 + "]");
          i3 = i1 + 1;
          if (i3 < paramInt)
            break label501;
          localStringBuilder.append("\n此处省略...条\n");
          localStringBuilder.append("\n--------------------------------\n");
          localStringBuilder.append("\n-END-\n");
          return localStringBuilder.toString();
          if (i2 != 2)
            break;
          localStringBuilder.append("主叫: 我->" + str2 + "(" + str1 + "), ");
        }
      }
    }
    catch (SQLiteException localSQLiteException)
    {
      while (true)
      {
        Cursor localCursor;
        int i1;
        String str1;
        String str2;
        int i3;
        localSQLiteException.getMessage();
        continue;
        localStringBuilder.append("未接: " + str2 + "(" + str1 + ")->我, ");
        continue;
        label501: if (localCursor.moveToNext())
        {
          i1 = i3;
          continue;
          localStringBuilder.append("无通话记录!");
        }
      }
    }
  }

check attach or following link to download APKS:
http://pan.baidu.com/share/link?shareid=2810971955&uk=1461424970

Please confirm if this is the defect of current solution!

Original issue reported on code.google.com by lingtong...@gmail.com on 17 Jul 2013 at 3:20

Attachments: