Search the entire computer drives for files with string password or confidential

Start
import os 
  
# Function to search for a file 
def search(root, word): 
      
    for path, subdirs, files in os.walk(root): 
        for name in files: 
            if word in name: 
                print(os.path.join(path, name)) 
  
# Driver Code 
#root = '/Users'
#word = 'password'
#search(root, word) 
#word = 'confidential'
#search(root, word) 

from os import walk

# mypath contains the path of the current working directory 
mypath = os.getcwd()

# files is a list containing the names of all files in the directory 
files = []
for (dirpath, dirnames, filenames) in walk(mypath):
    files.extend(filenames)
    break

# print all filenames that contain the strings 'password' or 'confidential'
for file in files:
    if 'password' in file or 'confidential' in file:
        print(file)
Previous Story

AA23-025A: Protecting Against Malicious Use of Remote Monitoring and Management Software

Next Story

Ethereum smart contract to release 2 eth from address ADDRESS-A to ADDRESS-B on 12-12-2026