PicoCTF - like1000

PicoCTF - like1000

tags: PicoCTF CTF Misc

Challenge: like1000

Background

How to extract nested tar.gz files easily? Shell Script - While

Exploit - Untar 1000 times

  • For untar folders
      #! /bin/bash
      PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
      export PATH
      file_name=1000
      for next in ${file_name}.tar
      while [ $file_name > 1 ]
          do
              echo "Untaring - $file_name"
              tar -xvf ${file_name}.tar #-C ./
              file_name=$(($file_name-1))
              mkdir ./$file_name
              mv ${file_name}.tar ./$file_name
              cd ./${file_name}
          done
    
  • For getting flag
      #! /bin/bash
      PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin
      export PATH
      file_name=999
      while [ "$file_name" > "0" ]
          do
              cd ./${file_name}
              file_name=$(($file_name-1))
              if [ "$file_name" == "0" ]
                  then ls -al
                  cat filler.txt
                  mv flag.png ~/CTF/PicoCTF/Misc/like1000
              fi
          done
      exit 0
    

Reference

Shell Script 變數相加 How to solve gzip: stdin: not in gzip format error 解压缩报错tar: Error is not recoverable: exiting now In a bash script, using the conditional “or” in an “if” statement