首页
社区
课程
招聘
[原创]AD Blocker Trial 注册算法
2012-8-16 16:12 15364

[原创]AD Blocker Trial 注册算法

2012-8-16 16:12
15364
【文章标题】: 【原创】AD Blocker Trial 注册算法
【下载地址】: http://as.baidu.com/a/item?docid=150568&pre=web_am_se
【操作平台】: Ubuntu11.10
【使用工具】: Apktool v1.4.3 , dex2jar-0.0.9.9,  jd-gui-0.3.3
【作者邮箱】:  iltgcl@163.com
【作者声明】: 仅作为研究交流使用。
【软件名称】: 英文名: AD Blocker Trial  中文名:广告拦截器及净触发器的审判。
【破解过程】
    先安装程序,启动以后,点击弹出菜单Buy 选项,进入到注册界面。发现程序已经给出了我的Product Code:44173112,  输入试练码:12345678,程序弹出对话框表示出错了。

好了,基本信息搜集完了。使用dex2jar反编译,然后用jd-gui打开,太好了,代码尽然没有混淆,省了不少麻烦。虽然这个程序的算法非常简单,但我还是尽量详细的将分析过程写下来。

首先需要找到注册界面。从前面信息搜集过程中知道是在弹出菜单中点击Buy选项出现的注册界面,找到如下代码片段
  
public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    int i = 1;
    switch (paramMenuItem.getItemId())
    {
    default:
      i = 0;
    case 1:
    case 0:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      return i;
      showAbout();
      continue;
      showHelp();
      continue;
      Intent localIntent = new Intent();
      localIntent.setClass(this, ProtectorPreferencesActivity.class);
      startActivity(localIntent);
      continue;
     [COLOR=Red] showDonateDialog();[/COLOR]
      continue;
      startActivity(new Intent("android.intent.action.VIEW", Uri.parse("market://search?q=\"SmartDog Studio\"")));
    }
  }
由于反编译不太可能与原码一样,所以上面这段代码流程比较乱。通常这种情况需要通过smali文件来仔细分析,
不过这里你可以试着猜猜看,我反正一眼就看到了showDonateDialog() 。

private void showDonateDialog()
  {
    View localView = LayoutInflater.from(this).inflate(2130903043, null);
    EditText localEditText = (EditText)localView.findViewById(2131296263);
    ((TextView)localView.findViewById(2131296262)).setText(RegUtil.getProdCode(this));
    ((TextView)localView.findViewById(2131296264)).setText(ContentUtil.getDonateGuide(this));
    new AlertDialog.Builder(this).setTitle(Html.fromHtml("<b>" + getText(2131165207) + "</b>")).setView(localView).setPositiveButton("OK", [COLOR=Red]new ADBlocker.3[/COLOR](this, localEditText)).setNeutralButton("Buy", new ADBlocker.4(this)).setNegativeButton("Cancel", null).show();
  }
我们知道,点击OK会进行注册判断,继续进入ADBlocker.3看看

class ADBlocker$3
  implements DialogInterface.OnClickListener
{
  public void onClick(DialogInterface paramDialogInterface, int paramInt)
  {
    if (this.val$key.getText() != null)
      ADBlocker.[COLOR=Red]access$3[/COLOR](this.this$0, this.this$0, this.val$key.getText().toString());
  }
}
哦,点击后会调用ADBlocker.access$3(...),我输入的试炼码会作为参数。比较讨厌的是access$3是什么意思呢?

当在JAVA内部类中调用外部类的私有方法时,编译器会自动合成一个静态函数。好了,使用Apktool工具反编译吧,然后打开

.method static synthetic access$3(Lnet/xdevelop/adblocker_t/ADBlocker;Landroid/content/Context;Ljava/lang/String;)V
    .locals 0
    .parameter
    .parameter
    .parameter

    .prologue
    .line 476
    invoke-direct {p0, p1, p2}, Lnet/xdevelop/adblocker_t/ADBlocker;->reg(Landroid/content/Context;Ljava/lang/String;)V

    return-void
.end method
仅仅调用了reg函数而已。

private final void reg(Context paramContext, String paramString)
  {
    if ([COLOR=Red]RegUtil.check(paramContext, paramString)[/COLOR])
    {
      ProtectorPrefModel localProtectorPrefModel = ProtectorPreferences.getPref(this);
      localProtectorPrefModel.donated = [COLOR=Red]true[/COLOR];
      ProtectorPreferences.savePref(this, localProtectorPrefModel);
      showMsg(getText(2131165201).toString(), getText(2131165203).toString());
    }
    while (true)
    {
      return;
      showMsg(getText(2131165202).toString(), getText(2131165204).toString());
    }
  }
看到这里,聪明的你一定知道RegUtil.check就是关键比较点了!只要返回true就可以了。

public static boolean check(Context paramContext, String paramString)
  {
    return check(getProdCode(getLocalPhone(paramContext)), paramString);
  }

private static boolean check(String paramString1, String paramString2)
  {
    int i = 0;
    if ((paramString1 == null) || (paramString2 == null));
    while (true)
    {
      return i;
      try
      {
        boolean bool =[COLOR=Red] genKey(paramString1)[/COLOR].equals(paramString2);
        if (!bool)
          continue;
        i = 1;
      }
      catch (Exception localException)
      {
      }
    }
  }
看后面那个check函数
paramString1 :Product Code(模拟器上就是44173112)
paramString2:试炼码
显然只要genKey函数返回值等于试炼码就可以了,注意genKey函数的参数就是ProductCode,那么来看看该函数吧

private static String genKey(String paramString)
  {
    long l1 = Long.parseLong(paramString);
    long l2 = l1 / 10000L;
    long l3 = l1 - 10000L * l2;
    return Long.toString((l2 + l3) * (l2 * l3));
  }
我靠,这么简单!用白话来说就是将ProductCode分成两个部分:l2 = 前4位,l3 = 后4位
试炼码应该等于(l2 + l3) * (l2 * l3)
那么对于44173112来说,注册码=((4417+3112)*(4417*3112)) = 103491405416

[培训]内核驱动高级班,冲击BAT一流互联网大厂工 作,每周日13:00-18:00直播授课

上传的附件:
收藏
点赞3
打赏
分享
最新回复 (5)
雪    币: 317
活跃值: (67)
能力值: ( LV5,RANK:60 )
在线值:
发帖
回帖
粉丝
iltgcl 1 2012-8-16 16:27
2
0
占位!!!!!!!!
雪    币: 32403
活跃值: (18860)
能力值: (RANK:350 )
在线值:
发帖
回帖
粉丝
kanxue 8 2012-8-16 20:28
3
0
欢迎交流 Android研究心得~
雪    币: 4176
活跃值: (2492)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
lylxd 2012-8-16 21:52
4
0
....作者天天求狷狂。。。结果你还来着出,命苦了。~
雪    币: 1489
活跃值: (955)
能力值: (RANK:860 )
在线值:
发帖
回帖
粉丝
仙果 19 2012-8-17 11:10
5
0
写的非常不错
雪    币: 3
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
xinandwan 2015-4-9 13:00
6
0
与我是土匪的AD Blocker Trial破解的好像是同一款软件,但是思路不一致,也更清晰。借鉴~~~~
游客
登录 | 注册 方可回帖
返回