
strumento di ricerca e patch della memoria su APK debuggabile senza root e NDK
Apk-medit è uno strumento di ricerca e patch della memoria per apk debuggable senza root e ndk. È stato creato per i test di sicurezza dei giochi mobili. Molti giochi mobili hanno il rilevamento del rooting, ma apk-medit non richiede privilegi di root, quindi la modifica della memoria può essere eseguita senza bypassare il rilevamento del rooting.
La modifica della memoria è il modo più semplice per imbrogliare nei giochi, è uno degli elementi da verificare nel test di sicurezza. Esistono anche strumenti cheat che possono essere usati casualmente come GameGuardian. Tuttavia, non erano disponibili strumenti per dispositivi non root e CUI. Quindi l'ho creato come strumento di test di sicurezza. La versione che ha come target le app iOS è sterrasec/ipa-medit.
Questa è una demo che utilizza apk-medit per completare un gioco che richiede un milione di tocchi per essere completato.


Scarica il binario da GitHub Releases, quindi carica il binario in /data/local/tmp/ su un dispositivo Android.
$ adb push medit /data/local/tmp/medit
medit: 1 file pushed. 29.0 MB/s (3135769 bytes in 0.103s)
Puoi compilare con il comando make. Richiede un compilatore Go.
Dopo il completamento della compilazione, se adb è connesso, carica il binario compilato in /data/local/tmp/ su un dispositivo Android.
$ make
GOOS=linux GOARCH=arm64 GOARM=7 go build -o medit
/bin/sh -c "adb push medit /data/local/tmp/medit"
medit: 1 file pushed. 23.7 MB/s (3131205 bytes in 0.126s)
Usa il comando run-as per leggere i file usati dall'app target, quindi apk-medit può essere utilizzato solo con app che hanno l'attributo debuggable abilitato.
Per abilitare l'attributo debuggable, apri AndroidManifest.xml, aggiungi il seguente attributo xml nel nodo application:
android:debuggable="true"
Puoi anche usare sterrasec/apkutil per abilitare facilmente l'attributo debuggable senza modificare AndroidManifest.xml, è utile.
$ apkutil debuggable <target-apk-name>.apk
Dopo aver eseguito il comando run-as, la directory viene cambiata automaticamente. Quindi copia medit da /data/local/tmp/.
Eseguire medit avvia un prompt interattivo.
$ adb shell
$ pm list packages # to check <target-package-name>
$ run-as <target-package-name>
$ cp /data/local/tmp/medit ./medit
$ ./medit
Puoi anche scegliere di non usare ptrace durante la scrittura in memoria. Questo evita il rilevamento del debugger da parte di ptrace, ma non funziona su Android 10 o successivi a causa di SELinux.
$ ./medit -without-ptrace
Ecco i comandi disponibili in un prompt interattivo.
Cerca l'intero specificato in memoria.
> find 999982
Search UTF-8 String...
Target Value: 999982([57 57 57 57 56 50])
Found: 0!
------------------------
Search Word...
parsing 999982: value out of range
------------------------
Search Double Word...
Target Value: 999982([46 66 15 0])
Found: 1!
Address: 0xe7021f70
Puoi anche specificare il tipo di dato come string, word, dword, qword.
> find dword 999996
Search Double Word...
Target Value: 999996([60 66 15 0])
Found: 1!
Address: 0xe7021f70
Filtra i risultati di ricerca precedenti che corrispondono ai risultati di ricerca correnti.
> filter 993881
Check previous results of searching dword...
Target Value: 993881([89 42 15 0])
Found: 1!
Address: 0xe7021f70
Scrivi il valore specificato all'indirizzo trovato dalla ricerca.
> patch 10
...
Successfully patched!
Trova il processo target e se ce n'è uno solo, impostalo come target. ps viene eseguito automaticamente all'avvio.
> ps
Package: jp.sterrasec.tap1000000, PID: 4398
Target PID has been set to 4398.
Se il pid target è impostato da ps, si collega al processo target, ferma tutti i processi nell'app tramite ptrace.
> attach
Target PID: 4398
Attached TID: 4398
Attached TID: 4405
Attached TID: 4407
Attached TID: 4408
Attached TID: 4410
Attached TID: 4411
Attached TID: 4412
Attached TID: 4413
Attached TID: 4414
Attached TID: 4415
Attached TID: 4418
Attached TID: 4420
Attached TID: 4424
Attached TID: 4429
Attached TID: 4430
Attached TID: 4436
Attached TID: 4437
Attached TID: 4438
Attached TID: 4439
Attached TID: 4440
Attached TID: 4441
Attached TID: 4442
Se il pid target non è impostato, può essere specificato sulla riga di comando.
> attach <pid>
Si scollega dal processo collegato.
> detach
Detached TID: 4398
Detached TID: 4405
Detached TID: 4407
Detached TID: 4408
Detached TID: 4410
Detached TID: 4411
Detached TID: 4412
Detached TID: 4413
Detached TID: 4414
Detached TID: 4415
Detached TID: 4418
Detached TID: 4420
Detached TID: 4424
Detached TID: 4429
Detached TID: 4430
Detached TID: 4436
Detached TID: 4437
Detached TID: 4438
Detached TID: 4439
Detached TID: 4440
Detached TID: 4441
Detached TID: 4442
Mostra il dump della memoria come hexdump.
> dump 0xf0aee000 0xf0aee300
Address range: 0xf0aee000 - 0xf0aee300
----------------------------------------------
00000000 34 32 20 61 6e 73 77 65 72 20 28 74 6f 20 6c 69 |42 answer (to li|
00000010 66 65 20 74 68 65 20 75 6e 69 76 65 72 73 65 20 |fe the universe |
00000020 65 74 63 7c 33 29 0a 33 31 34 20 70 69 0a 31 30 |etc|3).314 pi.10|
00000030 30 33 20 61 75 64 69 74 64 20 28 61 76 63 7c 33 |03 auditd (avc|3|
00000040 29 0a 31 30 30 34 20 63 68 61 74 74 79 20 28 64 |).1004 chatty (d|
00000050 72 6f 70 70 65 64 7c 33 29 0a 31 30 30 35 20 74 |ropped|3).1005 t|
00000060 61 67 5f 64 65 66 20 28 74 61 67 7c 31 29 2c 28 |ag_def (tag|1),(|
00000070 6e 61 6d 65 7c 33 29 2c 28 66 6f 72 6d 61 74 7c |name|3),(format||
00000080 33 29 0a 31 30 30 36 20 6c 69 62 6c 6f 67 20 28 |3).1006 liblog (|
00000090 64 72 6f 70 70 65 64 7c 31 29 0a 32 37 31 38 20 |dropped|1).2718 |
000000a0 65 0a 32 37 31 39 20 63 6f 6e 66 69 67 75 72 61 |e.2719 configura|
000000b0 74 69 6f 6e 5f 63 68 61 6e 67 65 64 20 28 63 6f |tion_changed (co|
000000c0 6e 66 69 67 20 6d 61 73 6b 7c 31 7c 35 29 0a 32 |nfig mask|1|5).2|
000000d0 37 32 30 20 73 79 6e 63 20 28 69 64 7c 33 29 2c |720 sync (id|3),|
000000e0 28 65 76 65 6e 74 7c 31 7c 35 29 2c 28 73 6f 75 |(event|1|5),(sou|
000000f0 72 63 65 7c 31 7c 35 29 2c 28 61 63 63 6f 75 6e |rce|1|5),(accoun|
Per uscire da medit, usa il comando exit o Ctrl-D.
> exit
Bye!
Puoi eseguire i codici di test con il comando make.
$ make test
Licenza MIT