Rating:

I had written a super dirty shell script, which was heavily taken from [this](https://www.youtube.com/watch?v=wRSwagjvSqU&t=589s) John Hammond's video

Although there is a slight issue with this code, that is you need to unzip once and then run on the tar.bz2 file. Sorry but I didn't give much thought about it. The exact command to run this is `./recursive_extract.sh 1.tar.bz2`. Then all the text files would be transferred to a folder named `ftxt`. `cd ftxt` next and then run `cat * | sort -u | uniq` to get the flag.

Here's the script to extract all of them

```
#!/bin/bash

filename=$1

rm -r tmp
rm -r ftxt
mkdir tmp
mkdir ftxt
cp $filename tmp

cd tmp

while [ 1 ]
do
file $filename | grep "tar"
if [ "$?" -eq "0" ]
then
echo "TAR"
mv $filename $filename.tar
tar -xf $filename.tar
rm $filename.tar
cd *
filename=$(ls *.txt)
mv $filename ~/ctf/tjctf/zips/0/ftxt/
filename=$(ls *)
fi

file $filename | grep "Zip"
if [ "$?" -eq "0" ]
then
echo "ZIP"
mv $filename $filename.zip
unzip $filename.zip
rm $filename.zip
cd *
filename=$(ls *.txt)
mv $filename ~/ctf/tjctf/zips/0/ftxt/
filename=$(ls *)
fi

file $filename | grep "bzip2"
if [ "$?" -eq "0" ]
then
echo "BZ2"
mv $filename $filename.bz2
bunzip2 $filename.bz2
mv *.txt ~/ctf/tjctf/zips/0/ftxt/
filename=$(ls *)
fi
done
```