macOS xattr-acls extra stuff

AWS 해킹 배우기 및 연습하기:HackTricks Training AWS Red Team Expert (ARTE) GCP 해킹 배우기 및 연습하기: HackTricks Training GCP Red Team Expert (GRTE)

HackTricks 지원하기
rm -rf /tmp/test*
echo test >/tmp/test
chmod +a "everyone deny write,writeattr,writeextattr,writesecurity,chown" /tmp/test
./get_acls test
ACL for test:
!#acl 1
group:ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C:everyone:12:deny:write,writeattr,writeextattr,writesecurity,chown

ACL in hex: \x21\x23\x61\x63\x6c\x20\x31\x0a\x67\x72\x6f\x75\x70\x3a\x41\x42\x43\x44\x45\x46\x41\x42\x2d\x43\x44\x45\x46\x2d\x41\x42\x43\x44\x2d\x45\x46\x41\x42\x2d\x43\x44\x45\x46\x30\x30\x30\x30\x30\x30\x30\x43\x3a\x65\x76\x65\x72\x79\x6f\x6e\x65\x3a\x31\x32\x3a\x64\x65\x6e\x79\x3a\x77\x72\x69\x74\x65\x2c\x77\x72\x69\x74\x65\x61\x74\x74\x72\x2c\x77\x72\x69\x74\x65\x65\x78\x74\x61\x74\x74\x72\x2c\x77\x72\x69\x74\x65\x73\x65\x63\x75\x72\x69\x74\x79\x2c\x63\x68\x6f\x77\x6e\x0a
get_acls의 코드

```c // gcc -o get_acls get_acls #include #include #include

int main(int argc, char *argv[]) { if (argc != 2) { fprintf(stderr, "Usage: %s \n", argv[0]); return 1; }

const char *filepath = argv[1]; acl_t acl = acl_get_file(filepath, ACL_TYPE_EXTENDED); if (acl == NULL) { perror("acl_get_file"); return 1; }

char *acl_text = acl_to_text(acl, NULL); if (acl_text == NULL) { perror("acl_to_text"); acl_free(acl); return 1; }

printf("ACL for %s:\n%s\n", filepath, acl_text);

// Convert acl_text to hexadecimal and print it printf("ACL in hex: "); for (char *c = acl_text; *c != '\0'; c++) { printf("\x%02x", (unsigned char)*c); } printf("\n");

acl_free(acl); acl_free(acl_text); return 0; }

```markdown
<details>
<summary>macOS 파일 시스템 트릭</summary>

macOS는 파일 시스템에 대한 여러 가지 보안 보호 기능을 제공합니다. 이 문서에서는 macOS의 xattr(확장 속성) 및 ACL(접근 제어 목록)과 같은 기능을 활용하여 보안을 강화하는 방법을 설명합니다.

## xattr

xattr는 파일에 추가 메타데이터를 저장할 수 있는 기능입니다. 이 메타데이터는 파일의 보안 및 무결성을 강화하는 데 사용될 수 있습니다.

## ACL

ACL은 파일 및 디렉토리에 대한 세부적인 접근 제어를 제공합니다. 이를 통해 특정 사용자 또는 그룹에 대한 권한을 세밀하게 조정할 수 있습니다.

## 추가 정보

macOS의 보안 기능을 활용하여 시스템을 강화하는 방법에 대한 더 많은 정보는 Apple의 공식 문서를 참조하십시오.

</details>
# Lets add the xattr com.apple.xxx.xxxx with the acls
mkdir start
mkdir start/protected
./set_xattr start/protected
echo something > start/protected/something

Last updated