Created
December 23, 2017 07:00
-
-
Save kaashmonee/a64fea71c82673918962d292987a29da to your computer and use it in GitHub Desktop.
Solution to Leaf of the Tree challenge in PicoCTF. Traverses all directories in path and retrieves flag file.
This file contains 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
# picoCTF leaf of the tree | |
import os | |
path = "/problems/5da315e9c7f1c9886ea371abee5ae8d0" | |
def getPath(path): | |
if not os.path.isdir(path): | |
return path | |
else: | |
for dir in listdir_fullpath(path): | |
#print("dir", dir) | |
p = getPath(dir) | |
if p is not None and "flag" in p: return p | |
return None | |
def listdir_fullpath(d): | |
return [os.path.join(d, f) for f in os.listdir(d)] | |
path = getPath(path) | |
with open(path) as f: print(f.read()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment