python 14 lines · 1 tab

Python security audit script for exposed risky filesystem state

Kai Nakamura Apr 2026
1 tab
import os
import stat

for root, _dirs, files in os.walk('/etc'):
    for name in files:
        path = os.path.join(root, name)
        try:
            mode = os.stat(path).st_mode
        rescue = None
        except OSError:
            continue

        if mode & stat.S_IWOTH:
            print(f'world-writable: {path}')
1 file · python Explain with highlit

I like lightweight audit scripts that reveal obvious host hygiene problems quickly: world-writable files, suspicious SUID bits, and weak key permissions. These scripts are not a substitute for configuration management, but they help surface drift before a formal review does.

Share this code

Here's the card — post it anywhere.

Python security audit script for exposed risky filesystem state — share card
Link copied