https://www.telerik.com/download/fiddler

 

Download Fiddler Web Debugging Tool for Free by Telerik

Download and install Fiddler Classic web debugging tool. Watch a quick tutorial to get started.

www.telerik.com

모바일 진단할 때 Burp를 이용하여 패킷을 확인하는데 특정 앱의 경우 통신 시간이 너무 오래 걸리는 경우가 있다.

인증서 문제인지는 모르겠지만 해당 문제는 Burp와 모바일 사이에 Fiddler를 연동시켜주면 해결이 된다.

 

우선 피들러를 다운받고 설치해준다. 그 후 Options 접속

 

 

HTTPS 옵션에서 Decrypt HTTPS traffic, Ignore server certificate errors, check for certificate revocation 을 체크 해준다.

하는 도중에 경고 뜨는게 좀 있을 텐데 다 YES로 진행  ←해당과정은 HTTPS 통신하는 패킷을 잡기 위해서 필수

 

 

그리고 Actions에서 Trust Root Certificate도 YES 해서 인증서를 해당 PC에 설치해 준다.

 

 

Connections 부분도 아래와 같이 세팅 여기까지 진행 후 설정 적용을 위해 껐다가 다시 피들러 실행할 것

 

 

이제 단말기에서 Fiddler 인증서를 설치해야한다. Proxy 설정을 아래와 같이 진행

다만 서버 IP의 경우 진행중인 PC의 아이피로 진행해야하고 같은 네트워크 상에 있어야 한다.

 

 

그 다음에 단말기에서 해당 https://192.168.0.17:8888 로 접속 후 certificate를 설치해 준다.

ios 에서는 사파리로 들어가야 해당 인증서가 깔리니 크롬으로 들어가지 말 것

 

 

 

피들러는 8080 포트를 프록시로 설정해 Burp에서 패킷을 잡을 수 있게한다.

 

 

Burp는 피들러와의 연동을 위해 8080 포트를 All interface로 진행한다. 127.0.0.1로 진행해도 상관 없을 거 같긴하다.

 

 

이러면 패킷이 정상적으로 잡힐 것이다.

 

만약 안된다면 피들러를 한번 껐다가 다시 켜볼것

 

+ 필터가 필요하다면 아래와 같이 세팅

안드로이드의 경우 안드로이드 8버전 이상부터 인증서를 직접 수정해서 넣어줘야 신뢰할 수 있는 인증서 획득이 가능하다.

왼쪽 하단 QuickExec에 about:config 입력 후 엔터시 설정이 나오는데 아래와 같은 설정이 없다면

아래 명령어를 순차적으로  QuickExec에 넣어서 작동시켜줘야한다.

PREFS SET fiddler.certmaker.validdays 360
PREFS SET fiddler.certmaker.gracedays 1

그 후 아래와 같이 인증서 초기화 및 새로 발급받는다.

추출된 파일은 바탕화면에 존재한다.

해당 인증서는 openssl로 안드로이드 단말기 내에서 사용할 수 있는 파일로 만들어 집어넣는다.

# 확장자 der로 변경
openssl x509 -inform DER -in FiddlerRoot.der -out FiddlerRoot.pem
openssl x509 -inform PEM -subject_hash_old -in FiddlerRoot.pem | head -1
# 위 결과값을 이름으로 변경하고 확장자를 <해쉬값>.0 으로 변경해준다.
mount -o rw,remount /system
chmod 644 269953fb.0
mv 269953fb.0 /system/etc/security/cacerts/
#만약 인식 안되면 재부팅

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

TCP Proxy  (0) 2023.04.04
Objection + frida-trace  (0) 2023.04.04
IDA Setting  (0) 2023.04.03
Anaconda Setting for virtual environment + frida  (0) 2023.03.23
pip 인증서 문제  (0) 2023.03.22

Objection

설치

pip install objection

사용방법

objection -g [app name] explore
ios jailbreak disable
ios hooking watch method "[후킹 메소드]" --dump-return
ios hooking set return_value "[메소드]" 0x0
file download <FILENAME> : iOS > PC 파일 다운받기
file upload <local_file_path> : PC > iOS 파일 업로드

frida-trace

사용방법

open을 사용하는 클래스 추출

frida-trace -U -f [PACKAGE_NAME] -i “open*”

 init으로 시작하는 클래스 추출

frida-trace -U -i “init*” [PID]

 

Class 내 모든 Method 추출

function hook_class_method(class_name, method_name)
{
	var hook = ObjC.classes[class_name][method_name];
		Interceptor.attach(hook.implementation, {
			onEnter: function(args) {
			console.log("[*] Detected call to: " + class_name + " -> " + method_name);
		}
	});
}

function run_hook_all_methods_of_specific_class(className_arg)
{
	console.log("[*] Started: Hook all methods of a specific class");
	console.log("[+] Class Name: " + className_arg);
	//Your class name here
	var className = className_arg;
	//var methods = ObjC.classes[className].$methods;
	var methods = ObjC.classes[className].$ownMethods;
	for (var i = 0; i < methods.length; i++)
	{
		console.log("[-] "+methods[i]);
		console.log("\t[*] Hooking into implementation");
		//eval('var className2 = "'+className+'"; var funcName2 = "'+methods[i]+'"; var hook = eval(\'ObjC.classes.\'+className2+\'["\'+funcName2+\'"]\'); Interceptor.attach(hook.implementation, {   onEnter: function(args) {    console.log("[*] Detected call to: " + className2 + " -> " + funcName2);  } });');
		var className2 = className;
		var funcName2 = methods[i];
		hook_class_method(className2, funcName2);
		console.log("\t[*] Hooking successful");
	}
	console.log("[*] Completed: Hook all methods of a specific class");
}

function hook_all_methods_of_specific_class(className_arg)
{
	setImmediate(run_hook_all_methods_of_specific_class,[className_arg])
}

//Your class name goes here
hook_all_methods_of_specific_class("추출한 Class Name")

Method trace 스크립트 by hackcatml

// generic trace
function trace(pattern)
{
    var type = (pattern.indexOf(" ") === -1) ? "module" : "objc";    // [A B]와 같이 공백이 있으면 objc, 없으면 모듈  
    var res = new ApiResolver(type);
    var matches = res.enumerateMatchesSync(pattern);
    var targets = uniqBy(matches, JSON.stringify);

    targets.forEach(function(target) {
      if (type === "objc")
          traceObjC(target.address, target.name);
      else if (type === "module")
          traceModule(target.address, target.name);
  });
}

// remove duplicates from array
function uniqBy(array, key) 
{
    var seen = {};
    return array.filter(function(item) {
        var k = key(item);
        return seen.hasOwnProperty(k) ? false : (seen[k] = true);
    });
}

// trace ObjC methods
function traceObjC(impl, name)
{
    console.log("Tracing " + name);

    Interceptor.attach(impl, {

        onEnter: function(args) {

            // debug only the intended calls
            this.flag = 0;
            // if (ObjC.Object(args[2]).toString() === "1234567890abcdef1234567890abcdef12345678")
                this.flag = 1;

            if (this.flag) {
                console.warn("\n[+] entered " + name);
                // print caller
                console.log("\x1b[31mCaller:\x1b[0m \x1b[34m" + DebugSymbol.fromAddress(this.returnAddress) + "\x1b[0m\n");

                // print args
                console.log("\x1b[31margs[2]:\x1b[0m \x1b[34m" + args[2] + ", \x1b[32m" + ObjC.Object(args[2]) + "\x1b[0m")
                console.log("\x1b[31margs[3]:\x1b[0m \x1b[34m" + args[3] + ", \x1b[32m" + ObjC.Object(args[3]) + "\x1b[0m")
                // console.log("\x1b[31margs[4]:\x1b[0m \x1b[34m" + args[4] + ", \x1b[32m" + ObjC.Object(args[4]) + "\x1b[0m")
                
                // print full backtrace
                // console.log("\nBacktrace:\n" + Thread.backtrace(this.context, Backtracer.ACCURATE)
                //      .map(DebugSymbol.fromAddress).join("\n"));
            }
        },

        onLeave: function(retval) {

            if (this.flag) {
                // print retval
                console.log("\n\x1b[31mretval:\x1b[0m \x1b[34m" + retval + "\x1b[0m");
                console.warn("[-] exiting " + name);
            }
        }

    });
}

// trace Module functions
function traceModule(impl, name)
{
    console.log("Tracing " + name);

    Interceptor.attach(impl, {

        onEnter: function(args) {

            // debug only the intended calls
            this.flag = 0;
            // var filename = Memory.readCString(ptr(args[0]));
            // if (filename.indexOf("Bundle") === -1 && filename.indexOf("Cache") === -1) // exclusion list
            // if (filename.indexOf("my.interesting.file") !== -1) // inclusion list
                this.flag = 1;

            if (this.flag) {
                console.warn("\n*** entered " + name);

                // print backtrace
                console.log("\nBacktrace:\n" + Thread.backtrace(this.context, Backtracer.ACCURATE)
                        .map(DebugSymbol.fromAddress).join("\n"));
            }
        },

        onLeave: function(retval) {

            if (this.flag) {
                // print retval
                console.log("\nretval: " + retval);
                console.warn("\n*** exiting " + name);
            }
        }

    });
}

// usage examples. 관심있는 클래스를 명시. 대소문자 구분
if (ObjC.available) {
    trace("*[JailbreakDetection *]")
    // trace("*[FireflySecurityUtil *]")
    // trace("*[ *ncrypt*]");
    // trace("*[* *]"); 모든 클래스 추적. 앱이 다운됨
    // trace("exports:libSystem.B.dylib!CCCrypt");
    // trace("exports:libSystem.B.dylib!open");
    // trace("exports:*!open*");
    
} else {
    send("error: Objective-C Runtime is not available!");
}

 

UI Dump by hackcatml

var window = ObjC.classes.UIWindow.keyWindow();
var rootControl = window.rootViewController();

var ui = window.recursiveDescription().toString();
var ui_autolayout = window['- _autolayoutTrace']().toString();
var control = rootControl['- _printHierarchy']().toString();

// 전체 UI 계층 출력하고 싶은 경우    
// console.log("\n\x1b[31m" + ui + "\x1b[0m"); 

// Simplified recursiveDescription
// console.log("\n\x1b[34m" + ui_autolayout + "\x1b[0m");

// 현재 화면에 보여지는 UIController를 알고 싶은 경우
console.log("\n\x1b[32m" + control + "\x1b[0m");

 

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

Burp Fiddler 연동  (0) 2023.07.10
TCP Proxy  (0) 2023.04.04
IDA Setting  (0) 2023.04.03
Anaconda Setting for virtual environment + frida  (0) 2023.03.23
pip 인증서 문제  (0) 2023.03.22

Function call : shift + f4

문자열 검색창 : shift + f12

검색한 문자열 클릭후 X 클릭시 변수 참조하는 모든 주소 출력

주소로 이동 : g 키 > 주소를 입력해야함

디컴파일(Smail을 분석 코드로 변조) : F5

Graph ↔ Text change : Space

이름 변경 : n 키

돌아가기 : ESC

대략적인 함수 진행 : view -> Graphs

전체화면 : W 키

 

 

Android

decompile된 파일명\lib\arm64-v8a\lib.so

classdex 

 

ios

ipa 파일 내 가장 binary가 큰 앱 파일

 

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

Burp Fiddler 연동  (0) 2023.07.10
TCP Proxy  (0) 2023.04.04
Objection + frida-trace  (0) 2023.04.04
Anaconda Setting for virtual environment + frida  (0) 2023.03.23
pip 인증서 문제  (0) 2023.03.22

아나콘다 가상환경을 이용하여 다양한 환경에서 모의해킹을 하기 위한 세팅을 할 것이다.

우선 아래에서 아나콘다를 다운로드한다.

https://www.anaconda.com/products/distribution

 

Anaconda | Anaconda Distribution

Anaconda's open-source Distribution is the easiest way to perform Python/R data science and machine learning on a single machine.

www.anaconda.com

중간에 환경 변수를 설정하라는 창이 있을 것인데 무조건 해주길 바란다. 아니면 나중에 환경 변수를 설정해줘야한다.

만약 빼먹었을 경우

시스템 환경 변수 편집 > 환경변수 > 시스템변수 > path 내 변수 편집에 아래 를 추가해준다. 재시작을 해줘야 해당 경로가 반영된다.

C:\Users\Tyrell\anaconda3\
C:\Users\Tyrell\anaconda3\Library
C:\Users\Tyrell\anaconda3\Scripts

   conda create -n 가상환경
   conda create -n 가상환경 python=2
   conda create -n 가상환경 python=3.7

그 후 위의 명령어로 app이라는 가상환경과 python을 설정 해주면 자동으로 설치해준다.

해당 가상환경 사용 및 설정은 아래를 입력하면 된다.

# 가상환경 List
conda env list
conda info envs

# 활성화
activate 가상환경이름

# 비활성화
conda deactivate

# 가상환경 삭제
conda env remove -n 가상환경이름

 

 

frida 설정

# frida-tools 먼저 설치시 자동 frida 설치
pip install frida-tools

pip install frida

현재 사용중인 운영체제 정보

adb shell getprop ro.product.cpu.abi

frida 저장 github

위의 운영체제 정보에 맞게 frida-server를 찾아 설치해주면 된다. server랑 설치한 frida랑 버전을 맞춰주어야한다.

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

 

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

Burp Fiddler 연동  (0) 2023.07.10
TCP Proxy  (0) 2023.04.04
Objection + frida-trace  (0) 2023.04.04
IDA Setting  (0) 2023.04.03
pip 인증서 문제  (0) 2023.03.22

가끔 타 공간에서 일할 떄 인증서 문제로 인해 pip install 이 안되는 문제가 발생했다. 이는 인증서 문제로 신뢰할 수 있는 인증서라는 문구를 추가해 주면 정상적으로 설치된다. 보통 보안 솔루션이 깔려있는 컴퓨터의 경우 인증서 문제가 발생했다.

 

pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org 설치할패키지이름
예시
pip install --trusted-host pypi.org --trusted-host files.pythonhosted.org pip setuptools
세팅 필요시 아래 설정
C:\Users\{사용자명}\AppData\Local\Programs\Python\Python36-32\Lib\site-packages\pip\_vendor\requests\sessions.py
-> self.verify==false

 

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

Burp Fiddler 연동  (0) 2023.07.10
TCP Proxy  (0) 2023.04.04
Objection + frida-trace  (0) 2023.04.04
IDA Setting  (0) 2023.04.03
Anaconda Setting for virtual environment + frida  (0) 2023.03.23

+ Recent posts