ShellSpells
  • 🧙‍♂️Welcome!
    • ShellSpells
    • FAQs
    • License & Disclaimer
  • 🐧Linux
    • System Ops
      • Transcripts
      • Help
      • System Info
        • Date/Time
        • System Details
        • Patches & Updates
        • Init System Identification
        • Hostname / Host ID
        • Variables
        • Hardware & Resources
      • Filesystem
        • Traverse & Enumerate
        • Drives & Partitions
        • Shares
        • Packages
        • Connected Devices
        • Kernel Modules (Drivers)
      • Users & Groups
        • Enumerate
        • Modify
      • Network
        • Enumerate
        • Modify
      • Scheduled Jobs
        • Enumerate
        • Modify
      • Processes
        • Enumerate
        • Modify
        • Custom Script and Shared Object
        • Process I/O Redirection
      • Services
        • Enumerate
        • Modify
        • Create a Service
      • Startup/Boot Scripts
        • Enumerate
        • Modify
      • Security
        • Antivirus
        • Firewall
        • SSH Keys
      • History & Logs
        • History
        • Logs
    • File Ops
      • Search
        • Filename
        • Content
        • Users (Owners)
        • Time
        • Size
        • Permission
        • Hidden Files
        • Inode
        • Find + Exec
        • Notes
      • Enumerate Metadata
      • Modify Metadata
      • Read Content
      • Modify Content
      • Extract Content
      • Sort / Compare / Count
      • Move
      • Copy
      • Execute
      • Hash
      • Encode/Decode
      • Compress/Decompress
      • Working With Weird Filenames
    • Terminal Ops
      • Keyboard Shortcuts
      • Tmux Shortcuts
  • 🪟Windows
    • System Ops
      • Transcripts
      • Help
      • System Info
        • One-liners
        • Date/Time
        • System Details
        • Hotfixes
        • Domain or Workgroup
        • Data Execution Prevention
        • Variables
        • Hardware & Resources
      • Filesystem
        • Traverse & Enumerate
        • Drives & Partitions
        • Installed Software
        • Drivers
        • Shares
      • Registry
        • Enumerate
        • Modify
        • Forensically Relevant Keys
      • Users & Groups
        • Enumerate
        • Modify
      • Network
        • Enumerate
        • Modify
      • Scheduled Tasks
      • Processes
        • Enumerate
        • Modify
      • Services
        • Enumerate
        • Modify
      • Autorun / Startup
        • Enumerate
        • Modify
      • Security
        • Permissions
          • Enumerate
          • Page
        • Antivirus
        • Firewall
          • Enumerate
          • Modify
        • Audit Policies
        • Remoting
          • Enumerate
          • Modify
          • Registry Locations
        • Stored Credentials
      • Remote Command Execution
      • Active Directory
        • Enumerate
        • Modify
      • History & Logs
        • History
        • Logs
      • PowerShell Config
      • Scripting
      • WMIC Notes
    • File Ops
      • Search
        • Filename
        • Time
        • Size
        • Permissions
        • Attributes
        • Wildcarding
      • Enumerate Metadata
        • One Liners
        • Users (Owners)
        • Timestamps
        • Size
        • Permissions
        • Attributes
      • Modify Metadata
        • Change Owner
        • Timestamps
        • Size
        • Attributes
      • Read Content
      • Modify Content
        • Overwrite
        • Insert
        • Append
        • Replace / Remove
        • Convert Case
        • Alternate Data Streams
      • Extract Content
      • Sort / Compare / Count
        • Sort
        • Count
        • Compare
      • Move
      • Copy
      • Execute
      • Hash
      • Encode/Decode
      • Compress/Decompress
      • Working With Weird Filenames
      • Output Formatting / Filtering
      • File Formatting
      • Operators
  • ⛓️Network
    • Traffic Manipulation
      • iptables
        • Option List
        • General Commands
        • Filter Tables
        • NAT
        • Mangle
        • Filter for SSH Traffic (Example)
      • nftables
    • Packet Capture
      • Syntax
      • TCPDump Examples
    • Packet Analysis
      • Wireshark
  • 🚗Maneuver
    • SSH
    • Control Sockets
    • RDP
    • Windows Port Proxy
  • 🛩️Data Transfer
    • SCP
    • FTP
    • Netcat
      • Netcat Relays
    • Server Interactions
    • Alternate Methods
  • 🪄REGEX
    • Examples
Powered by GitBook
On this page
  • Read
  • Other/World
  • Current User
  • User specific
  • Group
  • Write
  • Other/World
  • Current User
  • User Specific
  • Group
  • Execute
  • Other/World
  • Current User
  • User specific
  • Group
  • Wide-Open
  • SUID/SGID
  • Permission Filters
  • SUID Only
  • SGID Only
  • SUID AND/OR SGID
  • Capabilties

Was this helpful?

  1. Linux
  2. File Ops
  3. Search

Permission

Read

Other/World

find / -a -perm -o+r

World-readable

find / -a -perm -4

World-readable

grep -r "r-." /

Alternative method

Extracts usernames from /etc/passwd and finds files owned by each user where "others" have read permission (Need to test):

grep "r-" /etc/passwd | cut -d: -f1 | xargs find . -user

Current User

find / -a -readable

Current user readable.

find / -a -perm -u+r

Current user readable.

User specific

find / -a -user [username] -readable

Specific user readable.

find / -a -user [username] -perm -4

Specific user readable.

find / -a -user [username] -perm -u+r

Combines owner read permission to show files owned by user with read permissions.

Group

find / -a -perm -g+r

Group readable.

find / -a -group <group_name> -readable

Specific group readable.

Write

Other/World

find / -a -perm -o+w

Writable by "Other"

find / -a -perm -2

Writable by "Other"

grep -r "w-." /

Alternative method

Find world-writable config files:

find /etc -a -type f ( -name ".conf" -o -name ".cfg" -o -name "*.ini" ) -perm -o+w -exec ls -l {} ;

Current User

find / -a -writable 2>/dev/null

Current user writable

find / -a -perm -u+r

Current user writable

Current-user writable filtering out running processes:

find / -a -writable 2>/dev/null | cut -d "/" -f 2,3 | grep -v proc | sort -u

User Specific

find / -a -user [username] -readable

Specific user writable

find / -a -user [username] -perm -2

Specific user writable

find / -a -user [username] -perm -u+r

Combines owner read permission to show files owned by user with read permissions.

Group

find / -a -perm -g+w

Group Writable.

find / -a -group <group_name> -readable

Specific group Writable.

Execute

Other/World

find / -a -perm -o+x

World-executable

find / -a -perm -1

World-executable

grep -r "x-." /

Alternative method

Finds files owned by each user where "others" have execute permission:

grep "x-" /etc/passwd | cut -d: -f1 | xargs find . -user

Current User

find / -a -executable

Current user executable

find / -a -perm -u+x

Current user executable

User specific

find / -a -user [username] -executable

Specific user executable

find / -a -user [username] -perm -1

Specific user executable

find / -a -user [username] -perm -u+x

Combines owner read permission to show files owned by user with read permissions

Group

find / -a -perm -g+x

Group executable

find / -a -group <group_name> -executable

Specific group executable

Wide-Open

find / -a -perm 0777

Wide open files

Find files with insecure permissions:

find / -a -type f ( -perm 777 -o -perm 666 ) -exec ls -l {} ;

SUID/SGID

Permission Filters

-2000 = Owner has write permissions, SGID is set. File inherits the GID of the process that executes it. -4000 = Only files with SUID bit. /6000 = SUID, SGID, or Both.

SUID Only

find / -a -perm -4000

SUID set

find / -a -perm /u=s

SUID set

find / -a -perm -4000 -user root

SUID files owned by root

find / -a -perm -4000 -not -user root

SUID files NOT owned by root

grep -r "w-s-" /

SUID set (Alternate method)

Processes usernames from /etc/passwd, searches for world-executable SUID files owned by each user.

Use with Caution!

grep -r "w-s-" / | cut -d: -f1 | xargs find . -user

SGID Only

find / -a -perm -2000

Owner has write permissions, SGID is set

find / -a -perm /u=g

SGID set

find / -a -perm -2000 -user root

SGID set and owned by root

find / -a -perm -2000 -not -user root

SGID set and NOT owned by root

grep -r "w-S-" /

SGID set (Alternate method)

SUID AND/OR SGID

find / -a -perm /6000

SUID, SGID, or both set

find / -a -perm /u=s,g=s

Both SUID and SGID set

find / -a -perm /6000 -user root

SUID, SGID, or both set and owned by root

find / -a -perm /6000 -not -user root

SUID, SGID, or both set and NOT owned by root

SUID or SGID then execute ls -l:

find / -a \( -perm -4000 -o -perm -2000 \) -exec ls -l {} \;
find / -a -a ( -perm -u+s -o -perm -g+s ) -exec ls -l {} ; 2>/dev/null

Capabilties

getcap [filepath]

Check a specific file for capabilities.

getcap -r [filepath]

Recursively check capabilities of files in a directory hierarchy.

find / -a -perm -0002 | getcap -d -

Searches for capabilities (excluding sticky bits) and pipes getcap for details.

Recursively to search for capabilities within open file descriptors, potentially revealing files in use with capabilities. Requires root privileges:

grep -r /etc/security/capabilities /proc/self/fd/*.

This searches for specific capabilities by name within open file descriptors of a specific process ID (PID). Requires root privileges:

grep -r "\<[CAP_>\w+]*\>" /proc/[pid]/fd/*
PreviousSizeNextHidden Files

Last updated 1 year ago

Was this helpful?

🐧