error: only position independent executables (PIE) are supported 에러 해결
root@zerofltektt:/sdcard/test # ./hijack
error: only position independent executables (PIE) are supported.
안드로이드에서(아마도 롤리팝 이상인 경우 ELF로더가 PIE를 확인하는 듯) 위와 같이 PIE로 컴파일 되지 않으면 실행되지 않는다는 에러 메시지가 발생한 경우
Android.mk 파일에 아래와 같이 두줄을 간단히 추가해주면 해결된다.
LOCAL_CFLAGS += -fPIE
LOCAL_LDFLAGS += -fPIE -pie
# vi Android.mk
=============================================
1 # Copyright (C) 2009 The Android Open Source Project
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 #
15 LOCAL_PATH := $(call my-dir)
16
17 include $(CLEAR_VARS)
18 LOCAL_MODULE := base
19 LOCAL_SRC_FILES := ../../base/obj/local/armeabi/libbase.a
20 LOCAL_EXPORT_C_INCLUDES := ../../base
21 include $(PREBUILT_STATIC_LIBRARY)
22
23
24 include $(CLEAR_VARS)
25 LOCAL_MODULE := libexample
26 LOCAL_SRC_FILES := ../epoll.c ../epoll_arm.c.arm
27 LOCAL_CFLAGS := -g
28 LOCAL_SHARED_LIBRARIES := dl
29 LOCAL_STATIC_LIBRARIES := base
30 LOCAL_CFLAGS += -fPIE
31 LOCAL_LDFLAGS += -fPIE -pie
32
33 include $(BUILD_SHARED_LIBRARY)
# make
해결~
'Android Hacking' 카테고리의 다른 글
모바일 앱에서 frida timeout error 해결 방법 (1) | 2017.07.26 |
---|---|
DBI on Android - ADBI(Android Dynamic Binary Instrumentation) (1) | 2016.02.14 |
안드로이드 루팅 탐지 우회 (0) | 2015.08.07 |
Bypass Certificate Pinning - iOS / Android (0) | 2015.01.27 |
안드로이드 프로젝트 기본 구조 (1) | 2012.11.27 |