보안/android

[앱][리버싱] 악성앱 분석 - InsecureBankv2 환경구축

y00&z1 2021. 10. 28. 15:41

환경구축

 

[1]

>git clone https://github.com/dineshshetty/Android-InsecureBankv2.git

 

 

[2]

AnroLabServer폴더 이동해서 명령어 실행하기 ; 서버 구동

+) 한글경로 포함되어 있으면 정상 구동 안되니까 주의할 것, cmd 창에서 실행안되면 파워쉘에서 해보기

>python2 app.py 

 

방화벽 허용 필요! 

 

 

-오류 해결-

[3]
import 필요함 ->  C:\Users\[사용자명]\Downloads\Android-InsecureBankv2\AndroLabServer\requirements

pip install -r requirements.txt

 


+) 한글문제 
https://itinerant.tistory.com/10

 

[Python][pip] UnicodeDecodeError 해결 방법

pip 으로 패키지 설치하는데 아래와 같이  UnicodeDecodeError: 'ascii' codec can't decode byte 0xb9 in position 7: ordinal not in range(128) 오류나는 경우 아래 두 파일의 인코딩 방식을 수정해 주면 된..

itinerant.tistory.com

 

 

 

[4]

C:\Users\[사용자이름]\Downloads\Android-InsecureBankv2\AndroLabServer>py -2.7 -m pip install web.py==0.51

 

 

 


 

 

 

  • 앱 내에 여러가지 취약점이 존재
    • Flawed Broadcast Receivers
    • Intent Sniffing and Injection
    • Weak Authorization mechanism
    • Local Encryption issues
    • Vulnerable Activity Components
    • Root Detection and Bypass
    • Emulator Detection and Bypass
    • Insecure Content Provider access
    • Insecure Webview implementation
    • Weak Cryptography implementation
    • Application Patching
    • Sensitive Information in Memory
    • Insecure Logging mechanism
    • Android Pasteboard vulnerability
    • Application Debuggable
    • Android keyboard cache issues
    • Android Backup vulnerability
    • Runtime Manipulation
    • Insecure SDCard storage
    • Insecure HTTP connections
    • Parameter Manipulation
    • Hardcoded secrets
    • Username Enumeration issue
    • Developer Backdoors
    • Weak change password implementation

 

 


정적분석

 

 

[디컴파일]

dex-tools 이용하여 apk ->  jar 파일로 변환

변환완료. (명령어 실행한 위치에 저장된다)

 

 

ju-gui 디컴파일러로 디컴파일 수행 

-> MainActivity가 없다?!

 

 

apktool 이용하여 apk 내부 파일 추출하기

 

마찬가지로 명령어 실행 위치에서 확인 가능하다. 

 

AndroidManifest 파일을 확인해보니, 

LoginActivity가 MainActivity 역할을 하고 있었다. (앱 실행 시 가장 먼저 실행되는 activity ; 환경 구축하면서 앱 실행 -> 처음에 로그인 화면이 출력된 것을 보고 유추 가능)

이 부분이 진입점임을 나타내고 있다. 

                <action android:name="android.intent.action.MAIN"/>
                <category android:name="android.intent.category.LAUNCHER"/>

https://stackoverflow.com/questions/25219551/what-is-the-meaning-of-android-intent-action-main

 

What is the meaning of android.intent.action.MAIN?

I have seen so many different confusing explenations.. stackoverflow.com

 

 

 

 

 

 

class 파일이 굉장히 많기 때문에 대략적인 전체적인 흐름을 파악하기 위해서,

startActivity 메서드를 이용하여 흐름을 파악할 것이다. 

-> startActivity 메소드는 다음 페이지로 넘어가기 위해 사용하는 메소드이다. 

일종의 메시지 객체인 intent를 통해 activity의 새 인스턴스를 시작한다. -> intent를 startActivity()로 전달

 

 

putExtra() ? 

인텐트는 다른 데이터 유형(예: 문자열)을 제공하는 '추가' 데이터가 필요한 경우 존재 -> putExtra() 메소드로 하나 이상의 추가 데이터 전달 가능

intent.putExtra() 메소드로 추가 데이터 전달 -> subActivity(intent 객체) 호출 ; 추가 데이터 넘어간 채로 다음 페이지로 넘어감. 

 

https://mailmail.tistory.com/15

 

[안드로이드 Intent] startActivity(), startActivityForResult()를 통한 페이지 넘어가기

안녕하세요. 안드로이드 PEACE-입니다. 안드로이드 스터디 [열 두번째] 글입니다. Android Intent를 통해 Activity, Service, BroadCast 등 여러 구성요소 사이에서 통신을 용이하게해줍니다. 오늘은 Acitivity..

mailmail.tistory.com

https://developer.android.com/training/basics/intents/sending?hl=ko 

 

다른 앱으로 사용자 보내기  |  Android 개발자  |  Android Developers

특정 작업을 위해 암시적 인텐트를 생성하는 방법과 암시적 인텐트를 사용하여 다른 앱에서 작업을 실행하는 활동을 시작하는 방법을 알아봅니다.

developer.android.com

https://developer.android.com/reference/android/content/Intent?hl=ko#putExtra(java.lang.String,%20java.lang.String) 

 

Intent  |  Android Developers

 

developer.android.com

 

 

 

 

 

 

그러면 com.android.insecurebankv2 부분 class 파일을 살펴보자! 

 

Manifest 파일에서 확인했듯이, LoginActivity가 MainActivity 역할을 하고 있어서 LoginActivity 부터 차근차근 분석하면서 대략적인 흐름을 파악했다. 

(대충 맨 위 왼쪽부터 ~ 맨 아래 오른쪽 순서)

 

 

눈에 잘 안 들어와서 대략적으로 그려보았다. 

 

layout의 xml 파일과 연결된 class 파일은 총 7개이다!( 사용자가 직접 사용하는 페이지들)

LoginActivity와 FilePrefActivity 는 모든 class에 해당 intent 객체가 생성되고 startActivity로 전달했다. (두 개의 액티비티는 어느 액티비티에서든 페이지 전환 가능하다)

 

그리고 앱 이름에서 알 수 있듯이, 은행 관련 앱임을 유추할 수 있다 ->  핵심 기능으로 보이는 DoTransfer.class 부분을 잘 살펴야 할 것 같다..!