This article was written in collaboration with "Toptal".
아래 글은 Python 개발자인 Nikolay Derkach 가 작성한 글로 Private API에 대한 분석, 안드로이드에 대한 분석 내용을 담고 있습니다.
요약하자면 dex2jar , jd-gui를 통한 분석과 proxy 설정을 통한 분석이죠. 한번 읽어보시면 도움 될 부분이 있을겁니다.
https://www.toptal.com/back-end/reverse-engineering-the-private-api-hacking-your-couch
오늘은 이 글 내용에 약간 더 덧붙여서 작성해볼까 합니다.
Reverse Engineering Your Software's Private API - Set Android Proxy
To implement a sniffing proxy used to reverse engineer the private API, I’ll use tool called mitmproxy. You can use any other transparent HTTPS proxy. Charles is another example with a nice GUI. To make this work we need to set up the following things:Configure your phone’s WiFi connection default gateway to be the proxy (so that the proxy is in middle and all the packets pass through) Install proxy’s certificate on the phone (so that the client has the proxy’s public key in its trust store)
Check your proxy’s documentation about installing the certificate. Here are the instructions for mitmproxy. And here is the certificate PEM file for iOS.
To monitor intercepted HTTP requests, you simply launch mitmproxy and connect to it from your mobile phone (default port is 8080).
mitmproxy라는 툴을 이용해서 App에서 요청되는 데이터를 로깅합니다. 개인적으로는 App 분석에도 Burp suite나 Fiddler를 사용하기 때문에 여기선 개인의 취향에 따라 사용하시면 될 것 같네요.
기본적으로 Andoroid / iOS 모두 Proxy 설정을 통해서 요청되는 데이터를 보거나 변조할 수 있고, HTTPS와 같이 SSL이 적용된 사이트에 대해서는 프록시 툴의 인증서를 모바일 디바이스에 설치하여 테스트가 가능합니다. 관련해서는 아래 링크 참고해주세요.
http://www.hahwul.com/2015/12/web-hacking-burp-suite-android-ssl_2.html
Reverse Engineering Your Software's Private API - Proguard Decompile
CFR and FernFlower worked the best for me. JD-GUI was unable to decompile some critical parts of the code and was useless, while the others were about the same in quality. Luckily, it seems that the Java code code hasn’t been obfuscated, but there are tools like ProGuard http://developer.android.com/tools/help/proguard.html to help you deobfuscate the code.해당 글에서는 CFR과 FernFlower를 통해 난독화된 코드를 풀어나가고 있습니다. 물론 Decompile 방지가 걸린 난독화의 경우는 상황에 따라 애먹긴하죠.. (개인적으로는 코드 난독화가 더 싫어요..)
Reverse Engineering Your Software's Private API - Hacking API and HMAC!
Firstly, I’ve searched for mentions of X-CS-Url-Signature, which I’ve found in RetrofitHttpClient. One particular call seemed interesting - to EncUtils module. Digging into it, I realized that they are using HMAC SHA1. HMAC is a message authentication code which uses a cryptographic function (SHA1 in this case) to compute a hash of a message. It’s used to ensure integrity (i.e. to prevent a man in the middle from modifying the request) and authentication.디컴파일까지 마친 후 앱 내 API에 대한 변조 과정에서 HMAC이 언급되었습니다. API 분석을 해보시면 아시겠지만 은근히 많은 서비스들이 HMAC을 적용한 통신을 하고있죠. 공격자 입장에서는 굉장히 번거로운 부분입니다. 매번 요청에 대한 서명이 발생하기 때문에 쉽게 위변조를 할 수는 없죠.
니콜라이가 생각한대로, 이런 경우에는 HMAC 키를 찾는것이 우선적입니다. 키 값은 앱 내부 어딘가에는 숨겨져 있습니다. 코드단에 있을수도 있고 native code 에 있을수도 있죠. 키를 찾는 순간 우리는 어느정도 API에 대한 제어권을 가질 수 있습니다. 변조된 API 내용에 HMAC을 통해서 재 서명하여 정상적인 요청으로 보일 수 있는거죠.
![]() |
사용자 프로필 정보를 불러오는 API 일부 (https://www.toptal.com/back-end/reverse-engineering-the-private-api-hacking-your-couch) |
Toptal collaboration
This post originally apperared in Toptal(https://www.toptal.com/back-end/reverse-engineering-the-private-api-hacking-your-couch)
Reference
https://www.toptal.com/back-end/reverse-engineering-the-private-api-hacking-your-couchhttp://www.hahwul.com/2015/12/web-hacking-burp-suite-android-ssl_2.html
![]() |
HAHWULSecurity engineer, Gopher and H4cker! |
0 개의 댓글:
Post a Comment