macOS XPC Connecting Process Check
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μ μ μΆνμ¬ ν΄νΉ νΈλ¦μ 곡μ νμΈμ.
XPC Connecting Process Check
XPC μλΉμ€μ μ°κ²°μ΄ μ€μ λλ©΄, μλ²λ μ°κ²°μ΄ νμ©λλμ§ νμΈν©λλ€. μΌλ°μ μΌλ‘ μννλ 체ν¬λ λ€μκ³Ό κ°μ΅λλ€:
- μ°κ²°νλ νλ‘μΈμ€κ° Apple μλͺ μΈμ¦μλ‘ μλͺ λμλμ§ νμΈν©λλ€ (Appleμμλ§ λ°κΈ).
- μ΄ νμΈμ΄ μ΄λ£¨μ΄μ§μ§ μμΌλ©΄, 곡격μλ κ°μ§ μΈμ¦μλ₯Ό λ§λ€μ΄ λ€λ₯Έ 체ν¬μ μΌμΉμν¬ μ μμ΅λλ€.
- μ°κ²°νλ νλ‘μΈμ€κ° μ‘°μ§μ μΈμ¦μλ‘ μλͺ λμλμ§ νμΈν©λλ€ (ν ID νμΈ).
- μ΄ νμΈμ΄ μ΄λ£¨μ΄μ§μ§ μμΌλ©΄, Appleμ λͺ¨λ κ°λ°μ μΈμ¦μκ° μλͺ μ μ¬μ©λ μ μμΌλ©°, μλΉμ€μ μ°κ²°ν μ μμ΅λλ€.
- μ°κ²°νλ νλ‘μΈμ€κ° μ μ ν λ²λ€ IDλ₯Ό ν¬ν¨νκ³ μλμ§ νμΈν©λλ€.
- μ΄ νμΈμ΄ μ΄λ£¨μ΄μ§μ§ μμΌλ©΄, λμΌν μ‘°μ§μμ μλͺ λ λκ΅¬κ° XPC μλΉμ€μ μνΈμμ©νλ λ° μ¬μ©λ μ μμ΅λλ€.
- (4 λλ 5) μ°κ²°νλ νλ‘μΈμ€κ° μ μ ν μννΈμ¨μ΄ λ²μ λ²νΈλ₯Ό κ°μ§κ³ μλμ§ νμΈν©λλ€.
- μ΄ νμΈμ΄ μ΄λ£¨μ΄μ§μ§ μμΌλ©΄, μ€λλ, μ·¨μ½ν ν΄λΌμ΄μΈνΈκ° νλ‘μΈμ€ μ£Όμ μ μ·¨μ½νμ¬ λ€λ₯Έ 체ν¬κ° μμ΄λ XPC μλΉμ€μ μ°κ²°λ μ μμ΅λλ€.
- (4 λλ 5) μ°κ²°νλ νλ‘μΈμ€κ° μνν κΆνμ΄ μλ κ°νλ λ°νμμ κ°μ§κ³ μλμ§ νμΈν©λλ€ (μμμ λΌμ΄λΈλ¬λ¦¬λ₯Ό λ‘λνκ±°λ DYLD νκ²½ λ³μλ₯Ό μ¬μ©ν μ μλ κΆνκ³Ό κ°μ).
- μ΄ νμΈμ΄ μ΄λ£¨μ΄μ§μ§ μμΌλ©΄, ν΄λΌμ΄μΈνΈκ° μ½λ μ£Όμ μ μ·¨μ½ν μ μμ΅λλ€.
- μ°κ²°νλ νλ‘μΈμ€κ° μλΉμ€μ μ°κ²°ν μ μλ κΆνμ κ°μ§κ³ μλμ§ νμΈν©λλ€. μ΄λ Apple λ°μ΄λ리μ μ μ©λ©λλ€.
- κ²μ¦μ μ°κ²°νλ ν΄λΌμ΄μΈνΈμ κ°μ¬ ν ν°μ κΈ°λ°μΌλ‘ ν΄μΌ νλ©°, νλ‘μΈμ€ ID (PID) λμ μ¬μ©ν΄μΌ ν©λλ€. μ΄λ νμκ° PID μ¬μ¬μ© 곡격μ λ°©μ§νκΈ° λλ¬Έμ λλ€.
- κ°λ°μλ€μ κ°μ¬ ν ν° API νΈμΆμ λλ¬Όκ² μ¬μ©νλ©°, μ΄λ λΉκ³΅μμ μ΄λ―λ‘ Appleμ΄ μΈμ λ μ§ λ³κ²½ν μ μμ΅λλ€. λν, λΉκ³΅μ API μ¬μ©μ Mac App Store μ±μμ νμ©λμ§ μμ΅λλ€.
processIdentifierλ©μλκ° μ¬μ©λλ©΄ μ·¨μ½ν μ μμ΅λλ€.- **
xpc_dictionary_get_audit_token**μ΄xpc_connection_get_audit_tokenλμ μ¬μ©λμ΄μΌ νλ©°, νμλ νΉμ μν©μμ μ·¨μ½ν μ μμ΅λλ€.
Communication Attacks
PID μ¬μ¬μ© 곡격μ λν μμΈν μ 보λ λ€μμ νμΈνμμμ€:
xpc_connection_get_audit_token 곡격μ λν μμΈν μ 보λ λ€μμ νμΈνμμμ€:
macOS xpc_connection_get_audit_token Attack
Trustcache - Downgrade Attacks Prevention
Trustcacheλ Apple Silicon κΈ°κ³μμ λμ λ λ°©μ΄ λ°©λ²μΌλ‘, Apple λ°μ΄λμ€μ CDHSAH λ°μ΄ν°λ² μ΄μ€λ₯Ό μ μ₯νμ¬ νμ©λ λΉμμ λ°μ΄λμ€λ§ μ€νλ μ μλλ‘ ν©λλ€. μ΄λ λ€μ΄κ·Έλ μ΄λ λ²μ μ μ€νμ λ°©μ§ν©λλ€.
Code Examples
μλ²λ **shouldAcceptNewConnection**μ΄λΌλ ν¨μμμ μ΄ κ²μ¦μ ꡬνν©λλ€.
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
//Check connection
return YES;
}
NSXPCConnection κ°μ²΄λ private μμ± auditToken (μ¬μ©ν΄μΌ νμ§λ§ λ³κ²½λ μ μλ κ²)κ³Ό public μμ± processIdentifier (μ¬μ©ν΄μλ μ λλ κ²)μ κ°μ§κ³ μμ΅λλ€.
μ°κ²°λ νλ‘μΈμ€λ λ€μκ³Ό κ°μ λ°©λ²μΌλ‘ νμΈν μ μμ΅λλ€:
[...]
SecRequirementRef requirementRef = NULL;
NSString requirementString = @"anchor apple generic and identifier \"xyz.hacktricks.service\" and certificate leaf [subject.CN] = \"TEAMID\" and info [CFBundleShortVersionString] >= \"1.0\"";
/* Check:
- Signed by a cert signed by Apple
- Check the bundle ID
- Check the TEAMID of the signing cert
- Check the version used
*/
// Check the requirements with the PID (vulnerable)
SecRequirementCreateWithString(requirementString, kSecCSDefaultFlags, &requirementRef);
SecCodeCheckValidity(code, kSecCSDefaultFlags, requirementRef);
// Check the requirements wuing the auditToken (secure)
SecTaskRef taskRef = SecTaskCreateWithAuditToken(NULL, ((ExtendedNSXPCConnection*)newConnection).auditToken);
SecTaskValidateForRequirement(taskRef, (__bridge CFStringRef)(requirementString))
κ°λ°μκ° ν΄λΌμ΄μΈνΈμ λ²μ μ νμΈνκ³ μΆμ§ μλ€λ©΄, μ μ΄λ ν΄λΌμ΄μΈνΈκ° νλ‘μΈμ€ μ£Όμ μ μ·¨μ½νμ§ μμμ§ νμΈν μ μμ΅λλ€:
[...]
CFDictionaryRef csInfo = NULL;
SecCodeCopySigningInformation(code, kSecCSDynamicInformation, &csInfo);
uint32_t csFlags = [((__bridge NSDictionary *)csInfo)[(__bridge NSString *)kSecCodeInfoStatus] intValue];
const uint32_t cs_hard = 0x100; // don't load invalid page.
const uint32_t cs_kill = 0x200; // Kill process if page is invalid
const uint32_t cs_restrict = 0x800; // Prevent debugging
const uint32_t cs_require_lv = 0x2000; // Library Validation
const uint32_t cs_runtime = 0x10000; // hardened runtime
if ((csFlags & (cs_hard | cs_require_lv)) {
return Yes; // Accept connection
}
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μ μ μΆνμ¬ ν΄νΉ νΈλ¦μ 곡μ νμΈμ.


