아래 경로를 알게되었는데 일단 해봐야 겠다.

 

https://hackcatml.tistory.com/14

 

Cydia Impactor 없이 IPA 파일 설치(Xcode 7.3 에러 우회)

언제부터인가 다음과 같은 에러가 뜨면서 탈옥 아이폰에 시디아 임팩터를 이용한 ipa파일 설치가 불가능해졌습니다. ipa 파일 리패키징 후 설치가 안되어서 난감하였습니다. Cydia Impactor 없이도 ip

hackcatml.tistory.com

 

 

 

'모바일' 카테고리의 다른 글

ADB shell /data/data 추출  (0) 2020.08.06
iOS 10.x.x 탈옥  (0) 2020.08.04
Android debugging Anti-cheating  (0) 2020.07.29
ios 환경에서 gdb 이용  (0) 2020.07.15
IDA Remote debugging 안드로이드  (0) 2020.07.15
블로그 이미지

wtdsoul

,

아래 경로 참고

 

https://www.lazenca.net/display/TEC/Anti-cheating+Engine+for+Android

 

Anti-cheating Engine for Android - TechNote - Lazenca.0x0

Excuse the ads! We need some help to keep our site up. List Anti-cheating Engine for Android 해당 내용은 2016년에 분석하고 개발한 Anti-cheating Engine for Android에 대한 설명입니다.여기에서 설명하는 내용들은 아주 기초�

www.lazenca.net

 

 

Check debug

  • 아래와 같이 두가지 방식으로 디버깅 여부를 확인할 수 있습니다.
    • 첫번째는 해당 프로세스의 "/proc/pid/cmdline" 파일의 내용을 확인하는 것 입니다.
    • 프로그램이 GDB에 의해 실행 될 경우 PPID의 프로세스는 gdb이기 때문에 "cmdline" 파일을 이용해 gdb를 탐지 할 수 있습니다.

bool isCheckCmdline()

bool isCheckCmdline() {

   char filePath[32], fileRead[128];

   FILE* file;

 

   snprintf(filePath, 24, "/proc/%d/cmdline", getppid());

   file = fopen(filePath, "r");

 

   fgets(fileRead, 128, file);

   fclose(file);

 

   if(!strcmp(fileRead, "gdb")) {

       DbgPrint("Debugger(gdb) detected\n");

       return true;

   }

   DbgPrint("Clear(Debug)\n");

   return false;

}

    • 두번째는 해당 프로세스의 "/proc/pid/status" 파일의 내용을 확인하는 것 입니다.
    • status 파일에는 해당 프로세스의 상태, 스레드 정보, 메모리 정보, 등 많은 정보들이 저장되어 있습니다.
    • 여기에서 Debug 여부를 확인하기 위해 "TracerPid"의 값을 이용 할 수 있습니다.

      • 해당 프로세스가 다른 프로세스에 의해 추적 되고 있다면 추적하고 있는 프로세스의 PID가 저장됩니다.
      • 추적이 되고 있지 않으면 '0' 이 저장됩니다.

bool isCheckTracerPid()

bool isCheckTracerPid() {

    int TPid;

    char buf[512];

 

    const char *str = "TracerPid:";

    size_t strSize = strlen(str);

 

    FILE* file = fopen("/proc/self/status", "r");

 

    while (fgets(buf, 512, file)) {

        if (!strncmp(buf, str, strSize)) {

            sscanf(buf, "TracerPid: %d", &TPid);

            if (TPid != 0) {

                DbgPrint("Debugger detected\n");

                return true;

            }

        }

    }

    fclose(file);

    DbgPrint("Clear(Debug)\n");

    return false;

}

 

블로그 이미지

wtdsoul

,

 

환경 : 윈10

iOS : 10.3.3

 

아래 경로 참고

 

https://blog.do9.kr/269

 

iOS에서 사용 가능한 GDB

Xcode에 있는 GDB를 변환하여 iOS에서 사용이 가능한 바이너리 파일입니다. GDB 실행 시 "Illegal Instruction: 4" 에러가 발생할 경우 해결 방법: # sed -i 's/\x00\x30\x93\xe4/\x00\x30\x93\xe5/g;s/\x00\x30..

blog.do9.kr

 

gdb 이용 시 

"Illegal Instruction: 4" 에러를 뱉는다..

# sed -i 's/\x00\x30\x93\xe4/\x00\x30\x93\xe5/g;s/\x00\x30\xd3\xe4/\x00\x30\xd3\xe5/g;' /usr/bin/gdb

# ldid -s /usr/bin/gdb


수정 시 이용 가능

 

 

블로그 이미지

wtdsoul

,

 

 

환경 : 윈도 10

IDA 7.2 version

IDA dbgsrv 폴더 내 android_server, android_server64 

루팅된 기기로 adb push

 

아래 경로 참고

https://kinggod-daddong.tistory.com/3

 

IDA에서 안드로이드 원격 디버깅 방법

IDA가 설치된 경로로 이동하면 dbgsrv 디렉토리가 있다. dbgsrv 디렉토리에 있는 android_server를 data/local/tmp 위치로 push 한다. 이때 애뮬레이터의 CPU가 arm 속성을 가져야 한다. (실기기도 가능!) adb..

kinggod-daddong.tistory.com

 

/data/local/tmp 경로에

> adb push android_server /data/local/tmp

chmod 777 권한 변경

 

./android_server64 실행

파워쉘 창 하나더 열어서

adb forward tcp:23946 tcp:23946

 

모바일 디바이스 기기에서

ifconfig 후 wlan0 확인

 

IDA hostname : 192.168.X.X  Port : 디폴트

프로세스 확인 후 접근

 

- IDA64비트와 android_server64 로 원격디버깅 실행

 

'모바일' 카테고리의 다른 글

Android debugging Anti-cheating  (0) 2020.07.29
ios 환경에서 gdb 이용  (0) 2020.07.15
Android 안티디버깅 관련 대응방안  (0) 2020.07.15
frida source share  (0) 2020.07.14
iOS frida 환경 셋팅  (0) 2020.07.14
블로그 이미지

wtdsoul

,

 

참고

mobile-security.gitbook.io/mobile-security-testing-guide/android-testing-guide/0x05j-testing-resiliency-against-reverse-engineering

 

Android Anti-Reversing Defenses

 

mobile-security.gitbook.io

IDA 원격 디버깅이 가능하여 네이티브 단에서 대응방안이 필요함

 

1. ptrace 선점하는 자식프로세스 생성
2. 시간체크 함수 만들어서 일정시간 이상이면 디버깅 탐지
3. /proc/self/status 에서 tracerPid 값 확인해서 디버깅 탐지

- Using Fork and ptrace
- Timer Checks
- Checking TracerPid

 

Timer Checks

Debug.threadCpuTimeNanos indicates the amount of time that the current thread has been executing code. Because debugging slows down process execution, you can use the difference in execution time to guess whether a debugger is attached.

 

static boolean detect_threadCpuTimeNanos(){

long start = Debug.threadCpuTimeNanos();

 

for(int i=0; i<1000000; ++i)

continue;

 

long stop = Debug.threadCpuTimeNanos();

 

if(stop - start < 10000000) {

return false;

}

else {

return true;

}

}

 

Checking TracerPid

When you debug an app and set a breakpoint on native code, Android Studio will copy the needed files to the target device and start the lldb-server which will use ptrace to attach to the process. From this moment on, if you inspect the status file of the debugged process (/proc/<pid>/status or /proc/self/status), you will see that the "TracerPid" field has a value different from 0, which is a sign of debugging.

Remember that this only applies to native code. If you're debugging a Java/Kotlin-only app the value of the "TracerPid" field should be 0.

This technique is usually applied within the JNI native libraries in C, as shown in Google's gperftools (Google Performance Tools)) Heap Checker implementation of the IsDebuggerAttached method. However, if you prefer to include this check as part of your Java/Kotlin code you can refer to this Java implementation of the hasTracerPid method from Tim Strazzere's Anti-Emulator project.

When trying to implement such a method yourself, you can manually check the value of TracerPid with ADB. The following listing uses Google's NDK sample app hello-jni (com.example.hellojni) to perform the check after attaching Android Studio's debugger:

 

$ adb shell ps -A | grep com.example.hellojni

u0_a271 11657 573 4302108 50600 ptrace_stop 0 t com.example.hellojni

$ adb shell cat /proc/11657/status | grep -e "^TracerPid:" | sed "s/^TracerPid:\t//"

TracerPid: 11839

$ adb shell ps -A | grep 11839

u0_a271 11839 11837 14024 4548 poll_schedule_timeout 0 S lldb-server

You can see how the status file of com.example.hellojni (PID=11657) contains a TracerPID of 11839, which we can identify as the lldb-server process.

 

Using Fork and ptrace

You can prevent debugging of a process by forking a child process and attaching it to the parent as a debugger via code similar to the following simple example code:

 

void fork_and_attach()

{

int pid = fork();

 

if (pid == 0)

{

int ppid = getppid();

 

if (ptrace(PTRACE_ATTACH, ppid, NULL, NULL) == 0)

{

waitpid(ppid, NULL, 0);

 

/* Continue the parent process */

ptrace(PTRACE_CONT, NULL, NULL);

}

}

}

With the child attached, further attempts to attach to the parent will fail. We can verify this by compiling the code into a JNI function and packing it into an app we run on the device.

 

root@android:/ # ps | grep -i anti

u0_a151 18190 201 1535844 54908 ffffffff b6e0f124 S sg.vantagepoint.antidebug

u0_a151 18224 18190 1495180 35824 c019a3ac b6e0ee5c S sg.vantagepoint.antidebug

Attempting to attach to the parent process with gdbserver fails with an error:

 

root@android:/ # ./gdbserver --attach localhost:12345 18190

warning: process 18190 is already traced by process 18224

Cannot attach to lwp 18190: Operation not permitted (1)

Exiting

You can easily bypass this failure, however, by killing the child and "freeing" the parent from being traced. You'll therefore usually find more elaborate schemes, involving multiple processes and threads as well as some form of monitoring to impede tampering. Common methods include

 

 

이하 생략

 

'모바일' 카테고리의 다른 글

ios 환경에서 gdb 이용  (0) 2020.07.15
IDA Remote debugging 안드로이드  (0) 2020.07.15
frida source share  (0) 2020.07.14
iOS frida 환경 셋팅  (0) 2020.07.14
frida iOS 환경 셋팅 (Clutch, class-dump-ios, etc)  (0) 2020.07.14
블로그 이미지

wtdsoul

,

frida source share

모바일 2020. 7. 14. 18:19

https://codeshare.frida.re/browse

 

Frida CodeShare

27 | 68K Android SSL Re-Pinning, more information can be found here https://techblog.mediaservice.net/2017/07/universal-android-ssl-pinning-bypass-with-frida/ 9 | 19K Android antiroot checks bypass 7 | 6K Show useful info about AES encryption/decryption at

codeshare.frida.re

 

 

 

 

'모바일' 카테고리의 다른 글

IDA Remote debugging 안드로이드  (0) 2020.07.15
Android 안티디버깅 관련 대응방안  (0) 2020.07.15
iOS frida 환경 셋팅  (0) 2020.07.14
frida iOS 환경 셋팅 (Clutch, class-dump-ios, etc)  (0) 2020.07.14
frida ios dump ipa 추출  (0) 2020.07.14
블로그 이미지

wtdsoul

,

iOS frida 환경 셋팅

모바일 2020. 7. 14. 17:50

 

윈도우 10

환경 : iPhone 5S

버전 : 10.3.X

 

아래 블로그 참고

https://goroad.tistory.com/298

 

[Frida] Android Memory Dump (1. 환경세팅)

이 글은 Android Memory Dump에 대한 시선으로만 작성되었으며, 다른 기능들의 언급은 없음. 1. frida, fridump 초기 세팅 2. Device not found 라는 에러가 발생 위 두가지에 해당 하는 사람에게 도움이 될수 있.

goroad.tistory.com

frida 공식 github

https://github.com/frida/frida/releases

 

Releases · frida/frida

Clone this repo to build Frida. Contribute to frida/frida development by creating an account on GitHub.

github.com

 

파이썬 : 3.7.0(64bit)

frida-server-12.7.22-ios-arm64

 

\Python37\Scripts 경로에서

python2

pip install frida==12.7.22

pip install frida-tools==4.1.0

 

python3

pip3 install frida==12.7.22

pip3 install frida-tools==4.1.0

 

삭제가 필요한 경우

ex) pip3 uninstall frida==(version) 입력

 

 

 

블로그 이미지

wtdsoul

,

 

iOS 탈옥 기기에서 frida 후킹 및 분석 관련해서 환경 설정 중

 

Clutch 2.0.4는 다행히 사용 가능

 

 

https://github.com/KJCracks/Clutch/releases

 

Releases · KJCracks/Clutch

Fast iOS executable dumper. Contribute to KJCracks/Clutch development by creating an account on GitHub.

github.com

chmod 777 변경

/usr/bin 경로로 이동

 

앱의 복호화가 성공하면

binary 파일은 /tmp/clutch/### 에 위치,

ipa 파일은 /private/var/mobile/Documents/Dumped/###.ipa 에 위치하게 된다.

 

 

 

 

class-dump-z에서 

이전에 사용하던 버전이 안되어서 다시 찾아보니 아래 경로 건 제대로 돌아가는듯

 

다른 블로그 참조

deb 파일 받아서

dpkg -i deb 파일로 설치 후 /usr/bin 폴더에 넣고 chmod 777 변경

 

https://github.com/DreamDevLost/classdumpios/releases

 

Releases · DreamDevLost/classdumpios

iOS port from nygard/class-dump. Contribute to DreamDevLost/classdumpios development by creating an account on GitHub.

github.com

 

'모바일' 카테고리의 다른 글

frida source share  (0) 2020.07.14
iOS frida 환경 셋팅  (0) 2020.07.14
frida ios dump ipa 추출  (0) 2020.07.14
라인 - 난독화 컴퍼일러 도구(블로그)  (0) 2020.04.01
윈도우10 내부망 모바일 진단 설정  (0) 2020.01.31
블로그 이미지

wtdsoul

,

참고

 

현재 iOS  10.3.X 대 사용 중

 

윈도우 7, 10 환경

 

그 외 frida-ios-dump

 

https://hackcatml.tistory.com/15

 

bagbak을 이용한 IPA파일 추출

iOS 12 이상에서는 Clutch를 이용한 ipa파일 추출이 안되어서 다른 방법이 필요합니다. bagbak이라는 좋은 툴이 있어 소개합니다. 준비물은 탈옥폰 및 칼리입니다. 저는 uncover탈옥툴을 이용하여 아이��

hackcatml.tistory.com

 

https://nightohl.tistory.com/206

 

기기에서 .ipa 파일 추출하는 방법 4가지

기기에서 .ipa 파일 추출하기 아이폰 앱 파일은 .ipa 인데 사실 .zip 형식임 따라서 1. /var/containers/Bundle/Application/ 경로에서 2. ls * 로 원하는 앱 찾고 3. 목표 앱 압축해서 확장자만 .ipa 로 바꿔..

nightohl.tistory.com

https://mingzz1.github.io/pentesting/ios/2020/01/02/iOS-app_decrypt.html

 

[iOS] 어플리케이션 Decrypt 및 분석 | mingzzi

iOS 어플리케이션은 안드로이드 어플리케이션과 달리 어플리케이션을 Decrypt해야 분석을 할 수 있다. 어플리케이션을 Decrypt 하는 방법은 다음과 같다. 먼저 내가 사용 한 환경은 다음과 같다. Crack

mingzz1.github.io

 

블로그 이미지

wtdsoul

,

https://engineering.linecorp.com/ko/blog/code-obfuscation-compiler-tool-ork-1/

 

오크(ORK) - 난독화 컴파일러 도구 1편 - LINE ENGINEERING

안녕하세요. LINE에서 클라이언트 보호 솔루션인 AIR ARMOR 개발을 담당하고 있는 정상민입니다. 이전 글, 'iOS 코드 서명에 대해서'에서는 심민영 님이 iOS 앱의 무결성과 서명자를 검증할 수 있는 iOS 코드 서명에 대해서 설명했는데요. 이번 글에서는 앱의 위변조 및 도용 방지를 위해서 자체 개발 중인 난독화 도구를 소개하려고 합니다. 예제 소스 코드를 이용해 컴파일러 동작의 각 단계를 확인하면서 난독화가 어떻게 수행되는지 살펴보겠습니다.

engineering.linecorp.com

 

 

블로그 이미지

wtdsoul

,