
문제 github
https://github.com/nowsecure/cybertruckchallenge19
nowsecure/cybertruckchallenge19
Android security workshop material taught during the CyberTruck Challenge 2019 (Detroit USA). - nowsecure/cybertruckchallenge19
github.com
목표
Challenge1 to unlock car1. "DES key: Completely Keyless. Completely safe"
-
50pts: There is a secret used to create a DES key. Can you tell me which one?
-
100pts: There is a token generated at runtime to unlock the carid=1. Can you get it? (flag must be summitted in hexa all lowercase)
Challenge2 to unlock car2: "AES key: Your Cell Mobile Is Your Key"
- 50pts: This challenge has been obfuscated with ProGuard, therefore you will not recover the AES key.
- 100pts: There is a token generated at runtime to unlock the carid=2. Can you get it? (flag must be summitted in hexa all lowercase)
Challenge3 to unlock car3. "Mr Truck: Unlock me Baby!"
-
50pts: There is an interesting string in the native code. Can you catch it?
-
100pts: Get the secret generated at runtime to unlock the carid=3. Security by obscurity is not a great design. Use real crypto! (hint: check the length when summitting the secret!)
Challenge 1
목표: carid=1
을 unlock할 때 생성되는 token
구하기
1. 앱 실행해보기
안드로이드 에뮬레이터를 이용하여 앱을 설치하고 실행해보았습니다.
Wipe keys
, TamperProof
, UNLOCK
총 3가지의 기능이 있는 어플입니다.
그중 Chall1에서 중요한 unlock부분을 살펴보도록 하겠습니다.
2. jadx로 분석하기
jadx github링크 https://github.com/skylot/jadx
skylot/jadx
Dex to Java decompiler. Contribute to skylot/jadx development by creating an account on GitHub.
github.com
왼쪽 탐색창에서 MainActivity를 먼저 분석합니다.
UNLOCK
기능의 버튼을 생성하는 코드입니다.
Unlocking cars...
라는 토스트 메세지를 띄우고 this.k()
를 호출합니다.
Challenge1
과 a
를 생성하고 init()
을 호출합니다.
a
와 Challenge1
는 keygenerator
패키지안에 포함되어있습니다.
Challenge1
의 생성자에서 generateKey()
가 호출됩니다.
generateKey()
내부에서 Log.d(TAG, "KEYLESS CRYPTO [1] - Unlocking carID = 1");
를 보아 Challenge1
의 목표인 carid=1의 토큰을 생성하는 것 같습니다.
generateKey()
에서 generateDynamicKey("CyB3r_tRucK_Ch4113ng3".getBytes());
구문을 통해 "CyB3r_tRucK_Ch4113ng3"라는 바이트 배열을 generateDynamicKey
메소드의 인자로 전달하였습니다.
generateDynamicKey()
를 하나씩 분석해보면, new DESKeySpec("s3cr3t$_n3veR_mUst_bE_h4rdc0d3d_m4t3!".getBytes())
를 통해서 "s3cr3t$_n3veR_mUst_bE_h4rdc0d3d_m4t3!"
의 첫 8바이트로 DESkeySpec을 만듭니다.
참고
만들어진 KeySpec을 generateSecret()로 비밀키를 만듭니다
참고
1
은 ENCRYPT_MODE
에 해당합니다.
따라서 인자로 받은 CyB3r_tRucK_Ch4113ng3
를 KEY s3cr3t$_
로 DES암호화한 결과를 token으로 사용하게 됩니다.
Challenge 1 FLAG : 0x046e04ff67535d25dfea022033fcaaf23606b95a5c07a8c6
'Security > Mobile' 카테고리의 다른 글
[ctf apk문제]CyberTruck Challenge 2019 #Challenge 2 (0) | 2020.02.07 |
---|---|
[apk hooking tutorial] FridaLab 으로 frida 익히기 (0) | 2020.01.30 |