AndroidManifest.xml
➔구성요소를 정의하고 무슨 작업을 수행할 지 시스템에 알려주는 제어 파일
<manifest ... >
➔ package 명, Build 버전, API Level
<uses-permission>
➔ 앱에서 사용하는 권한
<activities>
➔ 앱의 동작 단위. 명시된 액티비티만 사용 가능
<intent-filter> - <activity> - <action “android.intent,action.MAIN”/>
➔ 앱이 실행될 때 가장 먼저 시작되는 activity 명시

안드로이드 Life Cycle

android:exported, android:sharedUserId 속성이 true 여부와 만약 true라면 protectionLevel이 Signature로 설정되지 않은 컴포넌트 존재여부 확인

android:debuggable : true ➔ 취약

안드로이드의 동작 방식에는 DVM(Dalvik VM) 방식과 ART(Android Runtime) 방식이 존재

 

NDK에서 취약한 함수
➔ BufferOverflow : strcpy, strcat, strncpy, memcpy, memset, scanf, strcat, spintf, strncat, gets, fgets
➔ FormatString : printf, sprintf, fprintf, snprintf, vfprintf, vsprintf, vsnprintf, syslog
➔ RaceCondition : tmpfile

 

DVM 이란 설치 속도는 빠르지만 실행속도가 느리다는 단점이 있다. 또한 많은 배터리와 메모리가 많이 사용된다.

ART 은 모든 파일이 컴파일 된 상태로 설치 시 깔리는데 설치 속도가 느리지만, 실행속도가 매우 빠르다는 장점이 있다.

현재는 늘어난 배터리와 메모리로 인해 ART를 주력으로 사용한다.

 

레지스터는 지역변수처럼 동작하고, 메소드들은 지역변수처럼 각자의 레지스터가 존재한다.

또한 가장 핵심은 호출된 메소드는 호출하는 메소드의 레지스터에 영향을 주지 않는다. 그 이유는 이미 함수를 호출할 때 메모리에 적재되어 있는 상태이기 떄문이다

 

 

https://source.android.com/docs/core/runtime/dalvik-bytecode?hl=ko 

 

Dalvik 바이트 코드  |  Android 오픈소스 프로젝트  |  Android Open Source Project

Dalvik 바이트 코드 컬렉션을 사용해 정리하기 내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요. 일반 디자인 머신 모델과 호출 규칙은 일반적인 실제 아키텍처와 C 스타일 호출 규칙을 거

source.android.com

 

Static : "this" 인수가 암묵적으로 첫번째 인수로 전달되지 않으면, Static메소드

Direct : overridde될 수 없으면 Direct메소드. vtable 개입 없이, 직접적으로 invoke 한다. 프라이빗 메소드, 생성자

Virtual : 자식 클래스들에 의해 overridde될 수 있으면 Virtual메소드. 클래스와 관련된 vtable을 사용해 invoke 한다

 

# 레지스터간 move :
move, move/from16, move-wide, move-wide/from16, move-object, move-object/from16
# 결과값을 얻거나 세팅:
move-result, move-result-wide, move-result-object, return-void, return,
return-wide, return-object
# 예외처리:
throw, move-exception
# 레지스터에 상수 대입:
const/4, const/16, const, const/high16, const-wide/1, const-wide/32,
const-wide, const-wide/high16, const-string, const-class
# 동기화:
monitor-enter, monitor-exit
# 타입체크:
check-cast, instance-of
# 배열 조작:
new-array, array-length, filled-new-array, filled-new-array/range,
fill-array-data
# 인스턴스생성:
new-instance
# 실행 조작:
goto, goto/16, packed-switch, sparse-switch,
if-eq, if-ne, if-lt, if-ge, if-gt, if-le, if-eqz, if-nez, if-ltz, if-gez, if-gtz,
if-lez
# 비교:
cmpl-float, cmpg-float, cmpl-double, cmpl-double, cmpg-double, cmp-long
# 멤버필드에 읽기/쓰기:
iget, iget-wide, iget-object, iget-boolean, iget-byte, iget-char, iget-short,
iput, iput-wide, iput-object, iput-boolean, iput-byte, iput-char, iput-short
#배열요소에 읽기/쓰기:
aget, aget-wide, aget-object, aget-boolean, aget-byte, aget-char, aget-short,
aput, aput-wide, aput-object, aput-boolean, aput-byte, aput-char, aput-short
# 메소드 호출:
invoke-virtual, invoke-super, invoke-direct, invoke-static, invoke-interface,
invoke-virtual/range, invoke-super/range, invoke-direct/range,
invoke-static/range, invoke-interface/range
# int, long, float, double 연산 명령:
add, sub, mul, div, rem, and, or, xor, shl, shr, ushr, neg-(int, long, float, double),
not-(int, long)
# ODEX 명령:
execute-inline, invoke-direct-empty, iget-quick, iget-wide-quick,
iget-object-quick,
iput-quick, iput-wide-quick, iput-object-quick, invoke-virtual-quick,
invoke-virtual-quick/range, invoke-super-quick, invoke-super-quick/range

 

 

 

참조 : https://i2sec.github.io/files/2017-10-20/study_dalvik_smali.pdf

추가 공부 자료 : https://strongslaves.tistory.com/29

'APP 모의해킹 > Android' 카테고리의 다른 글

Activity 강제실행  (0) 2023.03.28
Snapshot  (0) 2023.03.23
burp 인증서 안드로이드 with NOX  (0) 2023.03.22
[Android] 앱 추출 및 분석  (0) 2023.03.08
[Decompiler] APK Studio setting 방법 정리  (0) 2022.12.15

+ Recent posts