标签:源文件 .sh native csdn rect roi 安装包 width 触控
Coco2d-x引擎是相对于Unity3D的又一实力派引擎。尽管随着3D游戏的热门,很多其它的厂商偏向于Unity3D。可是Coco2d-x的普及量也不容小觑,特别是一些比較大的手游公司。比方触控科技仍然一直沿用着Coco2d-x的东西。我们从三个热门游戏来说说Coco2d-x游戏的一般文件验证方法。 |
1、捕鱼达人2:将Smali文件里获取包路径的參数转向我们自己定义的。
该种方法最早见于:http://bbs.csdn.net/topics/390598569?page=2#post-395954285居然闪退那必定会在主Activity的oncreate中启动相关代码。以下是流程:
public class FishingJoy extends FishingJoyWrapper-->public class FishingJoyWrapper extends Cocos2dxActivity-->public abstract class Cocos2dxActivity extends Activity。注意:class A extends B 表示A类承接B类,即B是A的相对父类。
从而知 Cocos2dxActivity 是程序启动时的根类。查看 oncreate 方法:
protected void onCreate(Bundle paramBundle) { super.onCreate(paramBundle); init(); Cocos2dxHelper.init(this, this); }又转向至 Cocos2dxHelper 类的 init 方法中,以下是其基本的smali代码:
<pre name="code" class="javascript"> //“參考文章:http://android.tgbus.com/Android/tutorial/201108/362210.shtml” //通过ApplicationInfo类中的packageName方法获取程序名称并保存在sPackageName字符串中 iget-object v1, v0, Landroid/content/pm/ApplicationInfo;->packageName:Ljava/lang/String; sput-object v1, Lorg/cocos2dx/lib/Cocos2dxHelper;->sPackageName:Ljava/lang/String; //通过ApplicationInfo类中的sourceDir方法获取APK程序的路径,并传递给native层 iget-object v1, v0, Landroid/content/pm/ApplicationInfo;->sourceDir:Ljava/lang/String; invoke-static {v1}, Lorg/cocos2dx/lib/Cocos2dxHelper;->nativeSetApkPath(Ljava/lang/String;)V通过以上分析我们非常easy得出,仅仅需将获取APK路径的v1转向原版的APK就可以绕过程序的校验。代码改动为:
iget-object v1, v0,Landroid/content/pm/ApplicationInfo;->sourceDir:Ljava/lang/String; const-string v1, "/sdcard/buyudaren.apk" invoke-static {v1}, Lorg/cocos2dx/lib/Cocos2dxHelper;->nativeSetApkPath(Ljava/lang/String;)V须要的操作是将原版apk更名为buyudaren.apk放在sdcard的根文件夹就可以。
2、我是车神 Ver1.2.6:将Smali文件里获取包路径的參数转向其它的就可以。
分析的流程是于捕鱼达人2一样的,知道这样我们能够直接搜索关键词“->sourceDir:”。出现两个结果,例如以下图:
3、保卫萝卜 Ver1.2.0:
这个游戏总体反编译apk的时候 会出现错误,貌似是资源文件的问题,可是我们能够直接拖出dex反编译。
相同是直接搜索“->sourceDir:”,然后将路径指定即可。
就像曾经在博客中说的,假设不正确apk进行加壳或者利用第三方进行防护的话。apk本身的校验貌似真的仅仅有签名校验和对文件的合法性进行验证。
不管是在smali、so还是dll。签名关键词“signature”或者“publickey”。pubkey 关键词的会获取一串MD5的值;
.method public static getSign(Landroid/content/Context;)Ljava/lang/String; .locals 6 .param p0, "context" # Landroid/content/Context; //########################以下是签名校验的部分########################### .prologue .line 374 //初始化v4为空 const-string v4, "" //读取com/txbnx/torrentsearcher/Utils方法中的mPublicKey字符串 赋给v5 sget-object v5, Lcom/txbnx/torrentsearcher/Utils;->mPublicKey:Ljava/lang/String; //推断v4,v5是否相等 并返回为v4布尔值 invoke-virtual {v4, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z move-result v4 if-nez v4, :cond_0 .line 375 sget-object v4, Lcom/txbnx/torrentsearcher/Utils;->mPublicKey:Ljava/lang/String; .line 385 :goto_0 return-object v4 .line 376 :cond_0 //引用获取已安装包信息的方法getPackageManager() invoke-virtual {p0}, Landroid/content/Context;->getPackageManager()Landroid/content/pm/PackageManager; move-result-object v2 .line 378 .local v2, "pm":Landroid/content/pm/PackageManager; :try_start_0 //获取包名字符串并保存在v4中 invoke-virtual {p0}, Landroid/content/Context;->getPackageName()Ljava/lang/String; move-result-object v4 const/16 v5, 0x40 invoke-virtual {v2, v4, v5}, Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo; move-result-object v1 .line 380 .local v1, "packageinfo":Landroid/content/pm/PackageInfo; //获取包信息里面的签名 iget-object v4, v1, Landroid/content/pm/PackageInfo;->signatures:[Landroid/content/pm/Signature; const/4 v5, 0x0 aget-object v3, v4, v5 .line 382 .local v3, "sign":Landroid/content/pm/Signature; //将签名信息转换为字符串 并保存在v4寄存器中 invoke-virtual {v3}, Landroid/content/pm/Signature;->toCharsString()Ljava/lang/String; move-result-object v4 sput-object v4, Lcom/txbnx/torrentsearcher/Utils;->mPublicKey:Ljava/lang/String; .line 383 sget-object v4, Lcom/txbnx/torrentsearcher/Utils;->mPublicKey:Ljava/lang/String; :try_end_0 .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0 goto :goto_0 .line 384 .end local v1 # "packageinfo":Landroid/content/pm/PackageInfo; .end local v3 # "sign":Landroid/content/pm/Signature; :catch_0 move-exception v0 .line 385 .local v0, "e":Ljava/lang/Exception; const/4 v4, 0x0 goto :goto_0 .end method
.local v0, "pubkeyMd5":Ljava/lang/String; const-string v1, "SigntureUtil" //##########################################以下是利用pubkey关键词校验的代码######################################## new-instance v2, Ljava/lang/StringBuilder; invoke-direct {v2}, Ljava/lang/StringBuilder;-><init>()V const-string v3, "pubkeyMd5:" invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; move-result-object v2 invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v2 invoke-static {v1, v2}, Lcn/com/cmbc/mbank/Log;->i(Ljava/lang/String;Ljava/lang/String;)V .line 68 if-eqz v0, :cond_0 const-string v1, "e6a81c9a3c88040678ae615f063d14d0" invoke-virtual {v1, v0}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z move-result v1 const/4 v1,0x1文件检验首先是获取文件的路径,或者直接文件名称,关键词“classes.dex”或者“->sourceDir:”,后者获取路径以后会传入其它的方法进行验证,如so方法。
iget-object v7, v13, Landroid/content/pm/ActivityInfo;->packageName:Ljava/lang/String; //获取文件路径 iget-object v8, v14, Landroid/content/pm/ApplicationInfo;->sourceDir:Ljava/lang/String; const-string v8, "/sdcard/woshicheshen.apk" //路径转向 sget v9, Landroid/os/Build$VERSION;->SDK_INT:I里面里面会有非常多的错误之处。望大牛们不吝指出啊。不让让我以讹传讹啊 我要进步..
标签:源文件 .sh native csdn rect roi 安装包 width 触控
原文地址:http://www.cnblogs.com/mfmdaoyou/p/6940324.html