๋ฉ๋ชจ๋ฆฌ์ ๊ฐ์ฒด
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.
CFRuntimeClass
CF* ๊ฐ์ฒด๋ CoreFoundation์์ ์ ๋ํ๋ฉฐ, CFString, CFNumber ๋๋ CFAllocator์ ๊ฐ์ 50๊ฐ ์ด์์ ํด๋์ค ๊ฐ์ฒด๋ฅผ ์ ๊ณตํฉ๋๋ค.
์ด ๋ชจ๋ ํด๋์ค๋ CFRuntimeClass ํด๋์ค์ ์ธ์คํด์ค์ด๋ฉฐ, ํธ์ถ๋ ๋ __CFRuntimeClassTable์ ๋ํ ์ธ๋ฑ์ค๋ฅผ ๋ฐํํฉ๋๋ค. CFRuntimeClass๋ CFRuntime.h์์ ์ ์๋์ด ์์ต๋๋ค:
// Some comments were added to the original code
enum { // Version field constants
_kCFRuntimeScannedObject = (1UL << 0),
_kCFRuntimeResourcefulObject = (1UL << 2), // tells CFRuntime to make use of the reclaim field
_kCFRuntimeCustomRefCount = (1UL << 3), // tells CFRuntime to make use of the refcount field
_kCFRuntimeRequiresAlignment = (1UL << 4), // tells CFRuntime to make use of the requiredAlignment field
};
typedef struct __CFRuntimeClass {
CFIndex version; // This is made a bitwise OR with the relevant previous flags
const char *className; // must be a pure ASCII string, nul-terminated
void (*init)(CFTypeRef cf); // Initializer function
CFTypeRef (*copy)(CFAllocatorRef allocator, CFTypeRef cf); // Copy function, taking CFAllocatorRef and CFTypeRef to copy
void (*finalize)(CFTypeRef cf); // Finalizer function
Boolean (*equal)(CFTypeRef cf1, CFTypeRef cf2); // Function to be called by CFEqual()
CFHashCode (*hash)(CFTypeRef cf); // Function to be called by CFHash()
CFStringRef (*copyFormattingDesc)(CFTypeRef cf, CFDictionaryRef formatOptions); // Provides a CFStringRef with a textual description of the object// return str with retain
CFStringRef (*copyDebugDesc)(CFTypeRef cf); // CFStringRed with textual description of the object for CFCopyDescription
#define CF_RECLAIM_AVAILABLE 1
void (*reclaim)(CFTypeRef cf); // Or in _kCFRuntimeResourcefulObject in the .version to indicate this field should be used
// It not null, it's called when the last reference to the object is released
#define CF_REFCOUNT_AVAILABLE 1
// If not null, the following is called when incrementing or decrementing reference count
uint32_t (*refcount)(intptr_t op, CFTypeRef cf); // Or in _kCFRuntimeCustomRefCount in the .version to indicate this field should be used
// this field must be non-NULL when _kCFRuntimeCustomRefCount is in the .version field
// - if the callback is passed 1 in 'op' it should increment the 'cf's reference count and return 0
// - if the callback is passed 0 in 'op' it should return the 'cf's reference count, up to 32 bits
// - if the callback is passed -1 in 'op' it should decrement the 'cf's reference count; if it is now zero, 'cf' should be cleaned up and deallocated (the finalize callback above will NOT be called unless the process is running under GC, and CF does not deallocate the memory for you; if running under GC, finalize should do the object tear-down and free the object memory); then return 0
// remember to use saturation arithmetic logic and stop incrementing and decrementing when the ref count hits UINT32_MAX, or you will have a security bug
// remember that reference count incrementing/decrementing must be done thread-safely/atomically
// objects should be created/initialized with a custom ref-count of 1 by the class creation functions
// do not attempt to use any bits within the CFRuntimeBase for your reference count; store that in some additional field in your CF object
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-field-initializers"
#define CF_REQUIRED_ALIGNMENT_AVAILABLE 1
// If not 0, allocation of object must be on this boundary
uintptr_t requiredAlignment; // Or in _kCFRuntimeRequiresAlignment in the .version field to indicate this field should be used; the allocator to _CFRuntimeCreateInstance() will be ignored in this case; if this is less than the minimum alignment the system supports, you'll get higher alignment; if this is not an alignment the system supports (e.g., most systems will only support powers of two, or if it is too high), the result (consequences) will be up to CF or the system to decide
} CFRuntimeClass;
Objective-C
Memory sections used
ObjectiveโC ๋ฐํ์์์ ์ฌ์ฉํ๋ ๋๋ถ๋ถ์ ๋ฐ์ดํฐ๋ ์คํ ์ค์ ๋ณ๊ฒฝ๋๋ฏ๋ก, ๋ฉ๋ชจ๋ฆฌ์ MachโO __DATA ๊ณ์ด ์ธ๊ทธ๋จผํธ์ ์๋ ์ฌ๋ฌ ์น์
์ ์ฌ์ฉํฉ๋๋ค. ์ญ์ฌ์ ์ผ๋ก ์ด๋ค์๋ ๋ค์์ด ํฌํจ๋์์ต๋๋ค:
__objc_msgrefs(message_ref_t): ๋ฉ์์ง ์ฐธ์กฐ__objc_ivar(ivar): ์ธ์คํด์ค ๋ณ์__objc_data(...): ๊ฐ๋ณ ๋ฐ์ดํฐ__objc_classrefs(Class): ํด๋์ค ์ฐธ์กฐ__objc_superrefs(Class): ์ํผํด๋์ค ์ฐธ์กฐ__objc_protorefs(protocol_t *): ํ๋กํ ์ฝ ์ฐธ์กฐ__objc_selrefs(SEL): ์ ๋ ํฐ ์ฐธ์กฐ__objc_const(...): ํด๋์ค ์ฝ๊ธฐ ์ ์ฉ ๋ฐ์ดํฐ ๋ฐ ๊ธฐํ (๊ฐ๋ฅํ) ์์ ๋ฐ์ดํฐ__objc_imageinfo(version, flags): ์ด๋ฏธ์ง ๋ก๋ ์ค์ ์ฌ์ฉ: ๋ฒ์ ์ ํ์ฌ0; ํ๋๊ทธ๋ ์ฌ์ ์ต์ ํ๋ GC ์ง์ ๋ฑ ์ง์ __objc_protolist(protocol_t *): ํ๋กํ ์ฝ ๋ชฉ๋ก__objc_nlcatlist(category_t): ์ด ๋ฐ์ด๋๋ฆฌ์ ์ ์๋ Non-Lazy ์นดํ ๊ณ ๋ฆฌ์ ๋ํ ํฌ์ธํฐ__objc_catlist(category_t): ์ด ๋ฐ์ด๋๋ฆฌ์ ์ ์๋ ์นดํ ๊ณ ๋ฆฌ์ ๋ํ ํฌ์ธํฐ__objc_nlclslist(classref_t): ์ด ๋ฐ์ด๋๋ฆฌ์ ์ ์๋ Non-Lazy ObjectiveโC ํด๋์ค์ ๋ํ ํฌ์ธํฐ__objc_classlist(classref_t): ์ด ๋ฐ์ด๋๋ฆฌ์ ์ ์๋ ๋ชจ๋ ObjectiveโC ํด๋์ค์ ๋ํ ํฌ์ธํฐ๋ค
์์๋ฅผ ์ ์ฅํ๊ธฐ ์ํด __TEXT ์ธ๊ทธ๋จผํธ์ ๋ช๋ช ์น์
๋ ์ฌ์ฉ๋ฉ๋๋ค:
__objc_methname(CโString): ๋ฉ์๋ ์ด๋ฆ__objc_classname(CโString): ํด๋์ค ์ด๋ฆ__objc_methtype(CโString): ๋ฉ์๋ ํ์
์ต์ macOS/iOS(ํนํ Apple Silicon)์์๋ ObjectiveโC/Swift ๋ฉํ๋ฐ์ดํฐ๋ฅผ ๋ค์์ ๋ฐฐ์นํ๊ธฐ๋ ํฉ๋๋ค:
__DATA_CONST: ํ๋ก์ธ์ค ๊ฐ์ ์ฝ๊ธฐ ์ ์ฉ์ผ๋ก ๊ณต์ ํ ์ ์๋ ๋ถ๋ณ ObjectiveโC ๋ฉํ๋ฐ์ดํฐ(์: ๋ง์__objc_*๋ชฉ๋ก์ด ์ด์ ์ฌ๊ธฐ์ ์กด์ฌ)__AUTH/__AUTH_CONST: arm64e์์ ๋ก๋ ์ ๋๋ ์ฌ์ฉ ์ ์ธ์ฆ๋์ด์ผ ํ๋ ํฌ์ธํฐ๋ฅผ ํฌํจํ๋ ์ธ๊ทธ๋จผํธ(ํฌ์ธํฐ ์ธ์ฆ). ๋ํ ๋ ๊ฑฐ์__la_symbol_ptr/__got๋์__AUTH_CONST์__auth_got์ ๋ณด๊ฒ ๋ฉ๋๋ค. ์ธ์คํธ๋ฃจ๋จผํธ๋ ํํน์ ํ ๋๋ ์ต์ ๋ฐ์ด๋๋ฆฌ์์__got๊ณผ__auth_got์ํธ๋ฆฌ ๋ ๋ค๋ฅผ ๊ณ ๋ คํด์ผ ํฉ๋๋ค.
dyld ์ฌ์ ์ต์ ํ(์: selector uniquing ๋ฐ class/protocol ์ฌ์ ๊ณ์ฐ)์ ๋ํ ๋ฐฐ๊ฒฝ๊ณผ ๊ณต์ ์บ์์์ ๋ก๋๋ ๋ ์ ์ด๋ค ์น์
์ค ๋ง์ ๋ถ๋ถ์ด โ์ด๋ฏธ ๊ณ ์ ๋์ด ์๋์งโ์ ๋ํด์๋ Apple objc-opt ์์ค์ dyld shared cache ๋
ธํธ๋ฅผ ์ฐธ๊ณ ํ์ธ์. ์ด๋ ๋ฐํ์์ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ํจ์นํ ์ ์๋ ์์น์ ๋ฐฉ๋ฒ์ ์ํฅ์ ์ค๋๋ค.
macOS Universal binaries & Mach-O Format
Type Encoding
ObjectiveโC๋ ๋จ์ ๋ฐ ๋ณตํฉ ํ์ ์ selector์ ๋ณ์ ํ์ ์ ์ธ์ฝ๋ฉํ๊ธฐ ์ํด mangling์ ์ฌ์ฉํฉ๋๋ค:
- ํ๋ฆฌ๋ฏธํฐ๋ธ ํ์
์ ํ์
์ ์ฒซ ๊ธ์๋ฅผ ์ฌ์ฉํฉ๋๋ค โ
int๋i,char๋c,long์l๋ฑโฆ unsigned์ธ ๊ฒฝ์ฐ ๋๋ฌธ์๋ฅผ ์ฌ์ฉํฉ๋๋ค(์:unsigned long์L). - ๋ค๋ฅธ ๋ฐ์ดํฐ ํ์
์
long long์q, ๋นํธํ๋๋b, ๋ถ๋ฆฌ์ธ์B, ํด๋์ค๋#,id๋@,char *๋*, ์ผ๋ฐ ํฌ์ธํฐ๋^, ์ ์๋์ง ์์ ๊ฒ์?๋ฑ ๋ค๋ฅธ ๋ฌธ์๋ ๊ธฐํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค. - ๋ฐฐ์ด, ๊ตฌ์กฐ์ฒด, ์ ๋์จ์ ๊ฐ๊ฐ
[,{,(์ ์ฌ์ฉํฉ๋๋ค.
Example Method Declaration
- (NSString *)processString:(id)input withOptions:(char *)options andError:(id)error;
์
๋ ํฐ๋ processString:withOptions:andError: ์
๋๋ค
ํ์ ์ธ์ฝ๋ฉ
id๋@๋ก ์ธ์ฝ๋ฉ๋ฉ๋๋คchar *๋*๋ก ์ธ์ฝ๋ฉ๋ฉ๋๋ค
๋ฉ์๋์ ์ ์ฒด ํ์ ์ธ์ฝ๋ฉ์ ๋ค์๊ณผ ๊ฐ์ต๋๋ค:
@24@0:8@16*20^@24
์์ธ ๋ถ์
- ๋ฐํ ํ์
(
NSString *):@๋ก ์ธ์ฝ๋ฉ, ๊ธธ์ด 24 self(๊ฐ์ฒด ์ธ์คํด์ค):@๋ก ์ธ์ฝ๋ฉ, ์คํ์ 0_cmd(์ ๋ ํฐ)::๋ก ์ธ์ฝ๋ฉ, ์คํ์ 8- ์ฒซ ๋ฒ์งธ ์ธ์ (
char * input):*๋ก ์ธ์ฝ๋ฉ, ์คํ์ 16 - ๋ ๋ฒ์งธ ์ธ์ (
NSDictionary * options):@๋ก ์ธ์ฝ๋ฉ, ์คํ์ 20 - ์ธ ๋ฒ์งธ ์ธ์ (
NSError ** error):^@๋ก ์ธ์ฝ๋ฉ, ์คํ์ 24
์ ๋ ํฐ + ์ธ์ฝ๋ฉ์ผ๋ก ๋ฉ์๋๋ฅผ ์ฌ๊ตฌ์ฑํ ์ ์๋ค.
ํด๋์ค
ObjectiveโC์ ํด๋์ค๋ ์์ฑ, ๋ฉ์๋ ํฌ์ธํฐ ๋ฑ์ผ๋ก ๊ตฌ์ฑ๋ C struct๋ค. struct objc_class๋ source code์์ ์ฐพ์ ์ ์๋ค:
struct objc_class : objc_object {
// Class ISA;
Class superclass;
cache_t cache; // formerly cache pointer and vtable
class_data_bits_t bits; // class_rw_t * plus custom rr/alloc flags
class_rw_t *data() {
return bits.data();
}
void setData(class_rw_t *newData) {
bits.setData(newData);
}
void setInfo(uint32_t set) {
assert(isFuture() || isRealized());
data()->setFlags(set);
}
[...]
์ด ํด๋์ค๋ ํด๋์ค์ ๋ํ ์ ๋ณด๋ฅผ ํ์ํ๊ธฐ ์ํด isa ํ๋์ ์ผ๋ถ ๋นํธ๋ฅผ ์ฌ์ฉํฉ๋๋ค.
๊ทธ ๋ค์, ํด๋น struct๋ ๋์คํฌ์ ์ ์ฅ๋ class_ro_t struct๋ฅผ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ๋ฅผ ๊ฐ์ง๋ฉฐ, ์ด ๊ตฌ์กฐ์ฒด์๋ ์ด๋ฆ, ๊ธฐ๋ณธ ๋ฉ์๋, ์์ฑ, ์ธ์คํด์ค ๋ณ์ ๊ฐ์ ํด๋์ค ์์ฑ์ด ๋ค์ด ์์ต๋๋ค. ๋ฐํ์ ๋์์๋ ๋ฉ์๋, ํ๋กํ ์ฝ, ์์ฑ์ฒ๋ผ ๋ณ๊ฒฝ๋ ์ ์๋ ํฌ์ธํฐ๋ฅผ ํฌํจํ๋ ์ถ๊ฐ ๊ตฌ์กฐ์ฒด์ธ class_rw_t๊ฐ ์ฌ์ฉ๋ฉ๋๋ค.
Modern object representations in memory (arm64e, tagged pointers, Swift)
Nonโpointer isa and Pointer Authentication (arm64e)
Apple Silicon๊ณผ ์ต์ ๋ฐํ์์์๋ ObjectiveโC isa๊ฐ ํญ์ ์์ class ํฌ์ธํฐ๊ฐ ์๋๋๋ค. arm64e์์๋ PAC(Pointer Authentication Code)๋ฅผ ํฌํจํ ์๋ ์๋ ํจํน๋ ๊ตฌ์กฐ์ฒด์
๋๋ค. ํ๋ซํผ์ ๋ฐ๋ผ nonpointer, has_assoc, weakly_referenced, extra_rc ๋ฑ ํ๋์ (์ํํธ๋๊ฑฐ๋ ์๋ช
๋) ํด๋์ค ํฌ์ธํฐ ์์ฒด๋ฅผ ํฌํจํ ์ ์์ต๋๋ค. ๋ฐ๋ผ์ ObjectiveโC ๊ฐ์ฒด์ ์ฒ์ 8๋ฐ์ดํธ๋ฅผ ๋ฌด์์ ์ญ์ฐธ์กฐํ๋ฉด ํญ์ ์ ํจํ Class ํฌ์ธํฐ๊ฐ ๋์ค์ง ์์ ์ ์์ต๋๋ค.
arm64e ๋๋ฒ๊น ์ค๋ฌด ๋ ธํธ:
- LLDB๋ ๋ณดํต
po๋ก ObjectiveโC ๊ฐ์ฒด๋ฅผ ์ถ๋ ฅํ ๋ PAC ๋นํธ๋ฅผ ์ ๊ฑฐํด ์ฃผ์ง๋ง, raw pointer๋ก ์์ ํ ๋๋ ์ธ์ฆ์ ์๋์ผ๋ก ์ ๊ฑฐํด์ผ ํ ์ ์์ต๋๋ค:
(lldb) expr -l objc++ -- #include <ptrauth.h>
(lldb) expr -l objc++ -- void *raw = ptrauth_strip((void*)0x000000016f123abc, ptrauth_key_asda);
(lldb) expr -l objc++ -O -- (Class)object_getClass((id)raw)
- ๋ง์ MachโO์ ํจ์/๋ฐ์ดํฐ ํฌ์ธํฐ๋
__AUTH/__AUTH_CONST์ ์์นํ๋ฉฐ ์ฌ์ฉ ์ ์ ์ธ์ฆ์ด ํ์ํฉ๋๋ค. interposing ๋๋ ์ฌ๋ฐ์ธ๋ฉ(์: fishhookโstyle)์ ํ ๊ฒฝ์ฐ, ๋ ๊ฑฐ์__got๋ฟ ์๋๋ผ__auth_got๋ ์ฒ๋ฆฌํด์ผ ํฉ๋๋ค.
์ธ์ด/ABI ๋ณด์ฅ๊ณผ Clang/LLVM์์ ์ ๊ณตํ๋ <ptrauth.h> ์ธํธ๋ฆฐ์์ ๋ํ ์์ธํ ๋ด์ฉ์ ์ด ํ์ด์ง ๋์ ์ฐธ์กฐ๋ฅผ ๋ณด์ธ์.
Tagged pointer objects
์ผ๋ถ Foundation ํด๋์ค๋ ๊ฐ์ฒด์ ํ์ด๋ก๋๋ฅผ ํฌ์ธํฐ ๊ฐ์ ์ง์ ์ธ์ฝ๋ฉ(ํ๊ทธ๋ ํฌ์ธํฐ)ํ์ฌ ํ ํ ๋น์ ํผํฉ๋๋ค. ๊ฐ์ง๋ ํ๋ซํผ๋ง๋ค ๋ค๋ฅด๋ฉฐ(์: arm64์์๋ ์ต์์ ๋นํธ, x86_64 macOS์์๋ ์ตํ์ ๋นํธ) ํ๊ทธ๋ ๊ฐ์ฒด๋ ๋ฉ๋ชจ๋ฆฌ์ ์ผ๋ฐ์ ์ธ isa๋ฅผ ์ ์ฅํ์ง ์์ผ๋ฉฐ ๋ฐํ์์ด ํ๊ทธ ๋นํธ๋ก๋ถํฐ ํด๋์ค๋ฅผ ๊ฒฐ์ ํฉ๋๋ค. ์์์ id ๊ฐ์ ๊ฒ์ฌํ ๋:
isaํ๋๋ฅผ ์ง์ ๊ฑด๋๋ฆฌ์ง ๋ง๊ณ ๋ฐํ์ API๋ฅผ ์ฌ์ฉํ์ธ์:object_getClass(obj)/[obj class].- LLDB์์
po (id)0xADDR๋ง์ผ๋ก๋ ๋ฐํ์์์ ํด๋์ค๋ฅผ ํ์ธํด ํ๊ทธ๋ ํฌ์ธํฐ ์ธ์คํด์ค๋ฅผ ์ฌ๋ฐ๋ฅด๊ฒ ์ถ๋ ฅํฉ๋๋ค.
Swift heap objects and metadata
์์ Swift ํด๋์ค๋ ObjectiveโC isa๊ฐ ์๋ Swift ๋ฉํ๋ฐ์ดํฐ๋ฅผ ๊ฐ๋ฆฌํค๋ ํค๋๋ฅผ ๊ฐ์ง ๊ฐ์ฒด์
๋๋ค. ์์ ์์ด ์คํ ์ค์ธ Swift ํ๋ก์ธ์ค๋ฅผ ์กฐ์ฌํ๋ ค๋ฉด Swift ํด์ฒด์ธ์ swift-inspect๋ฅผ ์ฌ์ฉํ ์ ์์ผ๋ฉฐ, ์ด๋ Remote Mirror ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ํ์ฉํด ๋ฐํ์ ๋ฉํ๋ฐ์ดํฐ๋ฅผ ์ฝ์ต๋๋ค:
# Xcode toolchain (or Swift.org toolchain) provides swift-inspect
swift-inspect dump-raw-metadata <pid-or-name>
swift-inspect dump-arrays <pid-or-name>
# On Darwin additionally:
swift-inspect dump-concurrency <pid-or-name>
์ด๊ฒ์ ํผํฉ Swift/ObjC ์ฑ์ ๋ฆฌ๋ฒ์ค ์์ง๋์ด๋งํ ๋ Swift ํ ๊ฐ์ฒด์ ํ๋กํ ์ฝ ์ค์๋ฅผ ๋งคํํ๋ ๋ฐ ๋งค์ฐ ์ ์ฉํฉ๋๋ค.
Runtime inspection cheatsheet (LLDB / Frida)
LLDB
- ์์ ํฌ์ธํฐ์์ ๊ฐ์ฒด ๋๋ ํด๋์ค ์ถ๋ ฅ:
(lldb) expr -l objc++ -O -- (id)0x0000000101234560
(lldb) expr -l objc++ -O -- (Class)object_getClass((id)0x0000000101234560)
- ๋ธ๋ ์ดํฌํฌ์ธํธ์์ ๊ฐ์ฒด ๋ฉ์๋์
selfํฌ์ธํฐ๋ก๋ถํฐ ObjectiveโC ํด๋์ค๋ฅผ ๊ฒ์ฌํ๊ธฐ:
(lldb) br se -n '-[NSFileManager fileExistsAtPath:]'
(lldb) r
... breakpoint hit ...
(lldb) po (id)$x0 # self
(lldb) expr -l objc++ -O -- (Class)object_getClass((id)$x0)
- ObjectiveโC ๋ฉํ๋ฐ์ดํฐ๋ฅผ ํฌํจํ๋ ์น์
์ ๋คํํฉ๋๋ค (์ฐธ๊ณ : ๋ง์ ์น์
์ด ์ด์
__DATA_CONST/__AUTH_CONST์ ์์ต๋๋ค):
(lldb) image dump section --section __DATA_CONST.__objc_classlist
(lldb) image dump section --section __DATA_CONST.__objc_selrefs
(lldb) image dump section --section __AUTH_CONST.__auth_got
- ์๋ ค์ง ํด๋์ค ๊ฐ์ฒด์ ๋ฉ๋ชจ๋ฆฌ๋ฅผ ์ฝ์ด
class_ro_t/class_rw_t๋ก pivotํ์ฌ ๋ฉ์๋ ๋ชฉ๋ก์ ์ญ๋ถ์ํ ๋:
(lldb) image lookup -r -n _OBJC_CLASS_$_NSFileManager
(lldb) memory read -fx -s8 0xADDRESS_OF_CLASS_OBJECT
Frida (ObjectiveโC and Swift)
Frida๋ ์ฌ๋ณผ ์์ด๋ ๋ผ์ด๋ธ ๊ฐ์ฒด๋ฅผ ํ์ํ๊ณ ๊ณ์ธกํ ์ ์๊ฒ ํด์ฃผ๋ ๊ณ ์์ค ๋ฐํ์ ๋ธ๋ฆฌ์ง๋ฅผ ์ ๊ณตํฉ๋๋ค:
- ํด๋์ค์ ๋ฉ์๋๋ฅผ ์ด๊ฑฐํ๊ณ , ๋ฐํ์์ ์ค์ ํด๋์ค ์ด๋ฆ์ ํ์ธํ๋ฉฐ, ObjectiveโC selectors๋ฅผ ๊ฐ๋ก์ฑ ์ ์์ต๋๋ค:
if (ObjC.available) {
// List a class' methods
console.log(ObjC.classes.NSFileManager.$ownMethods);
// Intercept and inspect arguments/return values
const impl = ObjC.classes.NSFileManager['- fileExistsAtPath:isDirectory:'].implementation;
Interceptor.attach(impl, {
onEnter(args) {
this.path = new ObjC.Object(args[2]).toString();
},
onLeave(retval) {
console.log('fileExistsAtPath:', this.path, '=>', retval);
}
});
}
- Swift bridge: Swift ํ์ ์ ์ด๊ฑฐํ๊ณ Swift ์ธ์คํด์ค์ ์ํธ์์ฉํฉ๋๋ค (์ต์ Frida ํ์; Apple Silicon ํ๊น์์ ๋งค์ฐ ์ ์ฉ).
์ฐธ๊ณ ์๋ฃ
- Clang/LLVM: Pointer Authentication ๋ฐ
<ptrauth.h>intrinsics (arm64e ABI). https://clang.llvm.org/docs/PointerAuthentication.html - Apple objc runtime headers (tagged pointers, nonโpointer
isa, etc.) ์:objc-object.h. https://opensource.apple.com/source/objc4/objc4-818.2/runtime/objc-object.h.auto.html
Tip
AWS ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training AWS Red Team Expert (ARTE)
GCP ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:HackTricks Training GCP Red Team Expert (GRTE)
Azure ํดํน ๋ฐฐ์ฐ๊ธฐ ๋ฐ ์ฐ์ตํ๊ธฐ:
HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks ์ง์ํ๊ธฐ
- ๊ตฌ๋ ๊ณํ ํ์ธํ๊ธฐ!
- **๐ฌ ๋์ค์ฝ๋ ๊ทธ๋ฃน ๋๋ ํ ๋ ๊ทธ๋จ ๊ทธ๋ฃน์ ์ฐธ์ฌํ๊ฑฐ๋ ํธ์ํฐ ๐ฆ @hacktricks_live๋ฅผ ํ๋ก์ฐํ์ธ์.
- HackTricks ๋ฐ HackTricks Cloud ๊นํ๋ธ ๋ฆฌํฌ์งํ ๋ฆฌ์ PR์ ์ ์ถํ์ฌ ํดํน ํธ๋ฆญ์ ๊ณต์ ํ์ธ์.


