Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os, zipfile
- from zipfile import BadZipFile
- def listdir(root='.'):
- for root, dirs, files in os.walk(root):
- for f in files:
- print(os.path.join(root, f))
- currentfile = os.path.join(root, f)
- if currentfile.endswith(".zip"):
- unzip(currentfile)
- else:
- searchfile(currentfile)
- def unzip(file):
- try:
- file_name = os.path.abspath(file) # get full path of files
- zip_ref = zipfile.ZipFile(file_name) # create zipfile object
- zip_ref.extractall(dir_name) # extract file to dir
- zip_ref.close() # close file
- os.remove(file_name) # delete zipped file
- except BadZipFile:
- pass
- def searchfile(file):
- user_name = "GailOllis"
- with open(file, 'r') as f:
- count = 0
- for x, line in enumerate(f):
- splitLine = line.split()
- print(splitLine)
- for splitLinePOS in range(0, len(splitLine)):
- if splitLine[splitLinePOS] == user_name:
- foundPass = splitLinePOS + 1
- if x == foundPass:
- with open("GailOllisPasswords.txt", "w+") as passwords:
- passwords.write("Password found for username: " + user_name + "\n")
- passwords.write("Password is: " + str(splitLine[1]) + "\n")
- listdir(".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement