apk不改变签名的情况下修改渠道号

今天看到一篇博客讲到可以在apk文件末尾追加数据以防止反编译工具反编,测试了一下,发现不能阻止。但是有个意外收获,就是文件末尾添加的数据可以作为渠道号来使用!

添加方法可以自己找工具,我使用的是c32asm。

获取文件末尾数据方法,如下:

//获取安装后的文件路径

         try {
            ApplicationInfo info = getPackageManager()
                     .getApplicationInfo(this.getPackageName(),
                                     PackageManager.GET_UNINSTALLED_PACKAGES);
            System.out.println("" + info.sourceDir);
            readFileByBytes(info.sourceDir, 14);
            
            
        } catch (NameNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }


// 读取文件最后几个字节

    public void readFileByBytes(String fileName, int lSize) {  
        File file = new File(fileName);
        InputStream in = null;
        try {

            in = new FileInputStream(file);
            int fileSize = in.available();
            System.out.println("fileSize:" + fileSize);
            int offset = fileSize - lSize;
            if (offset < 0) {
                offset = 0;
            }
            System.out.println("offset:" + offset);
            byte[] arrByte = new byte[lSize];
            in.skip(offset);
            in.read(arrByte);
            //in.read(arrByte, 15, arrByte.length);
            String sChannel = new String(arrByte);
            System.out.println("最后" + lSize + "字节数据为:" + sChannel);
            TextView tv = (TextView)findViewById(R.id.tv1);
            tv.setText(sChannel);

        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
        } finally {
            if (in != null) {
                try {
                    in.close();
                } catch (IOException e1) {
                }
            }
        }

测试这个功能过程中发现了一个问题,FileInputStream的read(byte[] b, int offset, int len)这个方法好奇葩,offset竟然是指的byte数组b的偏移量,无语了,并且skip的函数竟然也不确定能不能正确跳过,再次无语,哪位大神知道,望指点我一下!
            

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值