Created
June 1, 2017 08:15
-
-
Save dicksonkv/80a20cce703c300c263a98074b9a65f3 to your computer and use it in GitHub Desktop.
Python Script to find SUID enabled files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
import os | |
binaryPaths = ('/usr/bin' , '/usr/sbin' , '/bin', '/sbin') | |
for binaryPath in binaryPaths: | |
for rootDir,subDirs,subFiles in os.walk(binaryPath): | |
for subFile in subFiles: | |
absPath = os.path.join(rootDir,subFile) | |
permission = oct(os.stat(absPath).st_mode)[-4:] | |
specialPermission = permission[0] | |
if int(specialPermission) >= 4: | |
print(permission , absPath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment