Skip to main content

Over the Wire - Bandit 6

Bandit 6

Objectives

The password for the next level is stored in a file somewhere under the inhere directory and has all of the following properties:

  • human-readable
  • 1033 bytes in size
  • not executable
Solution

So we need to find a file that could be in a number of differnt directories
that is a not an excutable, human readable and 1033 bytes
I'm assuming the file size will be the best place to start to weed out the multiples files listed

so we will use find

bandit5@bandit:~$ find ./ -type f -size 1033c./inhere/maybehere07/.file2


Bam only one file let's cat that bad boy and see if the password is in there

bandit5@bandit:~/inhere$ cat ./maybehere07/.file2DXjZPULLxYr17uwoI01bNLQbtFemEgo7


Not to hard

now let's do it with python


#Import os moduleimport os#Import math and time moduleimport math,time
#Set listing start location
dir_count = 0file_count = 0
#Traverse directory treefor (path,dirs,files) in os.walk(os.curdir):        dir_count += 1    #Repeat for each file in directory    for file in files:     try :      filevar = os.path.join(path,file)      #print('filevar is',filevar)      varfilesize =  os.path.getsize(filevar)      if varfilesize == 1033:       print('Bingo file found*****************************')       print(filevar,varfilesize)       filetmp = open(filevar)       filetmp.read()     except Exception as err:       print('error')
     file_count += 1






Bingo file found*****************************('./inhere/maybehere07/.file2', 1033)'DXjZPULLxYr17uwoI01bNLQbtFemEgo7\n     

Comments