首页 > 其他分享 >【Android逆向】滚动的天空中插入smali日志

【Android逆向】滚动的天空中插入smali日志

时间:2023-02-17 19:00:10浏览次数:46  
标签:lang Ljava invoke StringBuilder v0 static Android smali 日志

1. 编写一个MyLog.java 放到一个android工程下,编译打包,然后反编译拿到MyLog的smali代码

package com.example.logapplication;

import android.util.Log;

public class MyLog {
    public static final String TAG = "JIA";

    public static void logd(Object obj) {
        Log.d(TAG, "logd: " + obj);
    }

    public static void logi(Object obj) {
        Log.i(TAG, "logi: " + obj);
    }

    public static void loge(Object obj) {
        Log.e(TAG, "logde: " + obj);
    }

    public static void print() {
        Log.e(TAG, "logde print: =====" );
    }
}

拿到MyLog.smali后,第一件事是抹去他的包信息,得到

.class public LMyLog;
.super Ljava/lang/Object;
.source "MyLog.java"


# static fields
.field public static final TAG:Ljava/lang/String; = "JIA"


# direct methods
.method public constructor <init>()V
    .locals 0

    .line 5
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static logd(Ljava/lang/Object;)V
    .locals 2
    .param p0, "obj"    # Ljava/lang/Object;

    .line 9
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "logd: "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const-string v1, "JIA"

    invoke-static {v1, v0}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    .line 10
    return-void
.end method

.method public static loge(Ljava/lang/Object;)V
    .locals 2
    .param p0, "obj"    # Ljava/lang/Object;

    .line 17
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "logde: "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const-string v1, "JIA"

    invoke-static {v1, v0}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 18
    return-void
.end method

.method public static logi(Ljava/lang/Object;)V
    .locals 2
    .param p0, "obj"    # Ljava/lang/Object;

    .line 13
    new-instance v0, Ljava/lang/StringBuilder;

    invoke-direct {v0}, Ljava/lang/StringBuilder;-><init>()V

    const-string v1, "logi: "

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0, p0}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    const-string v1, "JIA"

    invoke-static {v1, v0}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;)I

    .line 14
    return-void
.end method

.method public static print()V
    .locals 2

    .line 21
    const-string v0, "JIA"

    const-string v1, "logde print: ====="

    invoke-static {v0, v1}, Landroid/util/Log;->e(Ljava/lang/String;Ljava/lang/String;)I

    .line 22
    return-void
.end method

3. 将滚动天空拖入到AndroidKiller 中进行反编译,打开smali目录的位置,将MyLog.smali放到目录下,等于是是在源代码的根目录下(这也是要抹除包信息的原因),在目标文件a.smalionPayCancel插入自己的代码


# virtual methods
.method public varargs onPayCancel(Lcom/turbochilli/rollingsky/pay/IProduct;I[Ljava/lang/String;)V
    .locals 3

    .prologue
    const/4 v2, 0x4

    .line 57
    iget-object v0, p0, Lcom/turbochilli/rollingsky/b/a;->a:Ljava/lang/String;

    const-string v1, "ball_50"
    
	# my code begin
    invoke-static {}, LMyLog;->print()V
    invoke-static {v0}, LMyLog;->loge(Ljava/lang/Object;)V
	# my code end


    invoke-static {v0, v1}, Landroid/text/TextUtils;->equals(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Z

    move-result v0           

    if-eqz v0, :cond_1

    .line 77
    :cond_0
    :goto_0
    invoke-static {}, Lcom/turbochilli/rollingsky/util/NativeUtil;->getInstance()Lcom/turbochilli/rollingsky/util/NativeUtil;

    move-result-object v0

 ......
.end method

4. 通过AndroidKiller 重打包,并安装(手动打也可以,就是有些繁琐,借助工具更香)

5. 看到了自己的日志

JIA                     com...llingsky_cn.nearme.gamecenter  E  logde print: =====
JIA                     com...llingsky_cn.nearme.gamecenter  E  logde: ball_500

标签:lang,Ljava,invoke,StringBuilder,v0,static,Android,smali,日志
From: https://www.cnblogs.com/gradyblog/p/17131320.html

相关文章

  • 关于net core 开发服务时,使用Serilog根据appsettings.json输出日志错误的问题。
    使用Serilog输出日志时,配置内容如下,"Serilog":{"Using":["Serilog.Sinks.Console","Serilog.Sinks.File"],"MinimumLevel":"Debug","WriteTo":[......
  • k8s日志收集方案
    节点系统日志            节点应用日志        节点Pod日志      通过边车容器机制共享Pod卷采集主容器的日志 ......
  • 蓝桥杯备战日志(Python)16-玩具蛇&序列个数-(DFS&枚举、递归)
    玩具蛇原题小蓝有一条玩具蛇,一共有16节,上面标着数字1至16。每一节都是一个正方形的形状。相邻的两节可以成直线或者成90度角。小蓝还有一个4×4的方格盒子,用于存放......
  • adb日志文件
    一、获取日志文件一般情况下,我们在做app测试时,其实并不需要经常使用adb去抓取我们的日志,通常情况下都是有预期结果和实际结果做对比的。真正需要adb抓取日志的时候,是......
  • Android app:回调方式实现Service向activity传递数据
    一、开启服务的时候,如果我们是通过bindService来绑定服务并且要向服务传递数据,可以直接在Intent中设置bundle来达到效果,但是如果是我们需要从服务中返回一些数据到Activit......
  • kafka日志数据清理策略
    vim/kafka/server.properties #日志清理策略优先级是谁先满足条件.#保留7天的日志数据log.retention.hours=168#日志数据总大小保留100G,默认-1无穷大log.retenti......
  • 人像抠图App(android版)图片分享
     想要让你的照片变得更加有趣和个性化吗?那么就来试试我们的人像抠图App吧!我们的App专门为Android用户设计,支持人像手势移动、缩放和旋转,让你轻松地调整照片中的人物位置和......
  • Android Emulator 画面闪烁
    Android虚拟机经常会出现画面闪烁,可以通过修改设置解决。打开虚拟机之后,点击“...”按钮。按照下图改为“D3D11”,冷重启虚拟机就好了。......
  • 深入探索Android 启动优化(七) - JetPack App Startup 使用及源码浅析
    本文首发我的微信公众号:徐公,想成为一名优秀的Android开发者,需要一份完备的知识体系,在这里,让我们一起成长,变得更好~。前言前一阵子,写了几篇Android启动优化的文章......
  • 【技术分享】Android系统版本代号一览
    Android系统版本代号一览VersionCodeNameAPI时间11.0R/11302020.0910.0Q/10292019.059.0P/(Pie)282018.088.1O_MR1272017.128.......