메뉴 건너뛰기

app

[FRIDA] Android CTF 예제

lispro062016.10.27 20:29조회 수 3974댓글 0

  • 2
    • 글자 크기

http://www.frida.re/docs/examples/android/


에 소개된 문제이다.(SECCON 2015 Online CTF(Capture The Flag)


writeup은 https://blog.squareroots.de/en/2015/12/seccon-2015-online-ctf-reverse-engineering-android-apk-1/

(Xposed 로 된 예제이다. https://github.com/ctfs/write-ups-2015/raw/master/trend-micro-ctf-2015/analysis/offensive-200/VirusClicker.apk 는 추후 테스트)



에 있고, 해당 apk를 다운 받아 코드를 실행시키면, 답이 나온다.


1000번 이겼을 때, 출력되므로 cnt 변수를 999로 하고, m, n을 적당히 정의했다.


m, n이 정확히 뭔지는 모르겠으나, 승부를 결정짓는 변수로 생각된다.


apk 에서 dex를 jar로 바꾸어 코드를 보면 지거나 비길 때, cnt를 0으로 초기화 해 버린다. 아무리 가위 바위보를 잘 해도 1000번 연속 이기기는 불가능하므로 무조건 후킹을 할 수 밖에 없을 것이다. T.T;;


import frida, sys


def on_message(message, data):

    if message['type'] == 'send':

        print("[*] {0}".format(message['payload']))

    else:

        print(message)


jscode = """

Java.perform(function () {

    // Function to hook is defined here

    var MainActivity = Java.use('com.example.seccon2015.rock_paper_scissors.MainActivity');


    // Whenever button is clicked

    MainActivity.onClick.implementation = function (v) {

        // Show a message to know that the function got called

        send('onClick');


        // Call the original onClick handler

        this.onClick(v);


        // Set our values after running the original onClick handler

        this.m.value = 0;

        this.n.value = 1;

        this.cnt.value = 999;


        // Log to the console that it's done, and we should have the flag!

        console.log('Done:' + JSON.stringify(this.cnt));

    };

});

"""


process = frida.get_usb_device().attach('com.example.seccon2015.rock_paper_scissors')

script = process.create_script(jscode)

script.on('message', on_message)

print('[*] Running CTF')

script.load()

sys.stdin.read()

lispro06 (비회원)
  • 2
    • 글자 크기
[FRIDA] LolliPin screen lock 예제 (by lispro06) [FRIDA] 예제 코드 실행 (by lispro06)

댓글 달기

이전 1 2 3 4 5 6 7 8 9 10... 14다음
첨부 (2)
rps.apk
1.07MB / Download 90
rps.zip
1.07MB / Download 54
위로