문제 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 2


목표: carid=2을 unlock할 때 생성되는 token구하기

 

1. 앱 실행해보기

안드로이드 에뮬레이터를 이용하여 앱을 설치하고 실행해보았습니다.


Wipe keys, TamperProof, UNLOCK총 3가지의 기능이 있는 어플입니다.

그중 Chall2에서 중요한 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패키지안에 포함되어있습니다.

Challenge2에 해당하는 a를 분석해보겠습니다.

a의 생성자를 보면, a("uncr4ck4ble_k3yle$$".getBytes(), a(context));로 a(byte[], byte[])를 호출하고있습니다. (위 사진의 가장 아래의 메소드)

첫 인자인 "uncr4ck4ble_k3yle$$".getBytes() 는 앞의 문자열을 바이트 어레이로 만들어 주는것입니다.

두번째 인자는 a(context)인데, 이때 context는 생성자에서 넘어온 인자로 MainActivity에서의 j = getApplicationContext();입니다.

즉 a(Context)메소드를 호출합니다.

처음 "ch2.key"를 오픈해서 key를 읽어오는 과정을 수행합니다.

"ch2.key"같은 경우 Resources/assets에서 확인할 수 있습니다.

값은 "d474_47_r357_mu57_pR073C73D700!!"입니다.

결국 a(byte[], byte[])에는 a("uncr4ck4ble_k3yle$$","d474_47_r357_mu57_pR073C73D700!!"); 이렇게 들어간다고 볼 수 있습니다.

Challenge1과 마찬가지로 암호화를 진행하는데 이번엔 AES로 암호화를 합니다.

따라서 평문이 "uncr4ck4ble_k3yle$$" 키가 "d474_47_r357_mu57_pR073C73D700!!"인 AES암호화를 진행하면

512100f7cc50c76906d23181aff63f0d642b3d947f75d360b6b15447540e4f16 문제의 플래그를 얻을 수 있습니다.

 

복사했습니다!