D
D
Dev123452020-05-10 20:24:48
Android
Dev12345, 2020-05-10 20:24:48

How to bypass signature protection in the VKontakte application?

I know how you can bypass signature protection on VKontakte, when I change smali files it doesn’t enter the application, apparently the signature is being checked somewhere. Perhaps someone managed to do this and share their experience? (The application enters, hangs on the splash)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
S-trace, 2020-05-10
@S-trace

First, patch the smali of the original project with something like this:

grep -rlE 'invoke-virtual ({[pv][0-9]+, [pv][0-9]+, [pv][0-9]+}), Landroid\/content\/pm\/PackageManager;->getPackageInfo\(Ljava\/lang\/String;I\)Landroid\/content\/pm\/PackageInfo;' |xargs perl -pi -e 's/invoke-virtual (\{[pv][0-9]+, [pv][0-9]+, [pv][0-9]+}), Landroid\/content\/pm\/PackageManager;->getPackageInfo\(Ljava\/lang\/String;I\)Landroid\/content\/pm\/PackageInfo;/invoke-static \1,LSignatures;->getPackageInfo\(Landroid\/content\/pm\/PackageManager;Ljava\/lang\/String;I\)Landroid\/content\/pm\/PackageInfo;/g'

Then create a smali/Signatures.smali class like this:
.class public LSignatures;
.super Ljava/lang/Object;
.source "Signatures.java"


# static fields
.field public static SIGNATURES:Ljava/util/Map;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/Map<",
            "Ljava/lang/String;",
            "[",
            "Ljava/lang/String;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method static constructor <clinit>()V
    .locals 3

    .line 11
    new-instance v0, Ljava/util/HashMap;

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

    sput-object v0, LSignatures;->SIGNATURES:Ljava/util/Map;

    .line 14
    sget-object v0, LSignatures;->SIGNATURES:Ljava/util/Map;

    const-string v1, "com.vkontakte.kakegotam.paket.zovut"

    const-string v2, "3082062a30820412a00302010202044e33399c300d06092a864886f70d01010b05003081d6310b3009060355040613025553311330110603550408130a57617368696e67746f6e3110300e060355040713075265646d6f6e64311e301c060355040a13154d6963726f736f667420436f72706f726174696f6e31393037060355040b1330416e64726f6964204d61726b6574706c616365205369676e696e6720666f72204d6963726f736f6674204f6666696365314530430603550403133c4d6963726f736f667420436f72706f726174696f6e205468697264205061727479204d61726b6574706c6163652028446f204e6f7420547275737429301e170d3131303732393232353231325a170d3334303931393232353231325a3081d6310b3009060355040613025553311330110603550408130a57617368696e67746f6e3110300e060355040713075265646d6f6e64311e301c060355040a13154d6963726f736f667420436f72706f726174696f6e31393037060355040b1330416e64726f6964204d61726b6574706c616365205369676e696e6720666f72204d6963726f736f6674204f6666696365314530430603550403133c4d6963726f736f667420436f72706f726174696f6e205468697264205061727479204d61726b6574706c6163652028446f204e6f742054727573742930820222300d06092a864886f70d01010105000382020f003082020a028202010091ae14f78a8fa246203fd3e15ef6d3be1b45d2d8abaf2ead16e42194fa1ad7overdofigadlinnajahexstrokaoriginalnojsignaturbl"

    filled-new-array {v2}, [Ljava/lang/String;

    move-result-object v2

    invoke-interface {v0, v1, v2}, Ljava/util/Map;->put(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;

    .line 16
    return-void
.end method

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

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

    return-void
.end method

.method public static getPackageInfo(Landroid/content/pm/PackageManager;Ljava/lang/String;I)Landroid/content/pm/PackageInfo;
    .locals 6
    .param p0, "pm"    # Landroid/content/pm/PackageManager;
    .param p1, "name"    # Ljava/lang/String;
    .param p2, "flags"    # I
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Landroid/content/pm/PackageManager$NameNotFoundException;
        }
    .end annotation

    .line 30
    invoke-virtual {p0, p1, p2}, Landroid/content/pm/PackageManager;->getPackageInfo(Ljava/lang/String;I)Landroid/content/pm/PackageInfo;

    move-result-object v0

    .line 31
    .local v0, "info":Landroid/content/pm/PackageInfo;
    const-string v1, "S-trace"

    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v3, "getPackageInfo("

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

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

    const-string v3, ", "

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

    invoke-virtual {v2, p2}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    const-string v3, ")"

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

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

    move-result-object v2

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

    .line 32
    sget-object v1, LSignatures;->SIGNATURES:Ljava/util/Map;

    invoke-interface {v1, p1}, Ljava/util/Map;->containsKey(Ljava/lang/Object;)Z

    move-result v1

    if-eqz v1, :cond_1

    .line 33
    sget-object v1, LSignatures;->SIGNATURES:Ljava/util/Map;

    invoke-interface {v1, p1}, Ljava/util/Map;->get(Ljava/lang/Object;)Ljava/lang/Object;

    move-result-object v1

    check-cast v1, [Ljava/lang/String;

    .line 35
    .local v1, "hexSignatures":[Ljava/lang/String;
    if-eqz v1, :cond_1

    .line 36
    array-length v2, v1

    new-array v2, v2, [Landroid/content/pm/Signature;

    .line 37
    .local v2, "signatures":[Landroid/content/pm/Signature;
    const/4 v3, 0x0

    .line 37
    .local v3, "i":I
    :goto_0
    array-length v4, v1

    if-ge v3, v4, :cond_0

    .line 38
    new-instance v4, Landroid/content/pm/Signature;

    aget-object v5, v1, v3

    invoke-static {v5}, LSignatures;->hexStringToByteArray(Ljava/lang/String;)[B

    move-result-object v5

    invoke-direct {v4, v5}, Landroid/content/pm/Signature;-><init>([B)V

    aput-object v4, v2, v3

    .line 37
    add-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 40
    .end local v3    # "i":I
    :cond_0
    iput-object v2, v0, Landroid/content/pm/PackageInfo;->signatures:[Landroid/content/pm/Signature;

    .line 43
    .end local v1    # "hexSignatures":[Ljava/lang/String;
    .end local v2    # "signatures":[Landroid/content/pm/Signature;
    :cond_1
    return-object v0
.end method

.method public static hexStringToByteArray(Ljava/lang/String;)[B
    .locals 7
    .param p0, "s"    # Ljava/lang/String;

    .line 19
    invoke-virtual {p0}, Ljava/lang/String;->length()I

    move-result v0

    .line 20
    .local v0, "len":I
    div-int/lit8 v1, v0, 0x2

    new-array v1, v1, [B

    .line 22
    .local v1, "data":[B
    const/4 v2, 0x0

    .line 22
    .local v2, "i":I
    :goto_0
    if-ge v2, v0, :cond_0

    .line 23
    div-int/lit8 v3, v2, 0x2

    invoke-virtual {p0, v2}, Ljava/lang/String;->charAt(I)C

    move-result v4

    const/16 v5, 0x10

    invoke-static {v4, v5}, Ljava/lang/Character;->digit(CI)I

    move-result v4

    shl-int/lit8 v4, v4, 0x4

    add-int/lit8 v6, v2, 0x1

    invoke-virtual {p0, v6}, Ljava/lang/String;->charAt(I)C

    move-result v6

    invoke-static {v6, v5}, Ljava/lang/Character;->digit(CI)I

    move-result v5

    add-int/2addr v4, v5

    int-to-byte v4, v4

    aput-byte v4, v1, v3

    .line 22
    add-int/lit8 v2, v2, 0x2

    goto :goto_0

    .line 26
    .end local v2    # "i":I
    :cond_0
    return-object v1
.end method

Essno the name of the package and its signature must be replaced with real ones.
How to do this is your homework (the payroll is written in 5 minutes in the studio).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question