Post

7z: pwn.college

7z: pwn.college

I checked sudo -l first to see what I could run as root. Screenshot sudo -l showed that I could run /usr/bin/7z as root without a password. Screenshot I looked for the protected flag file: Screenshot The file is /flag. I ran 7z once with sudo to put /flag into a tar stream, then ran it again to print the stream’s contents:

1
sudo -u root 7z a -ttar -an -so /flag | 7z e -ttar -si -so

This requires the active sudo policy to permit the invocation. Screenshot

Flag:

1
pwn.college{ssyWdagNWwZhZlxdGM2xJG1ahJF.0VM4IjMywCO4YDM5EzW}

Findings

I checked sudo -l and found that I could run 7z as root. I found the protected file at /flag. The command below reads it into a tar stream, then prints the contents. It only works because of the sudo rule on this challenge.

What I Learned

The stream options are normal 7z features. The important part was the challenge’s sudo rule, which let the first 7z process read /flag as root. I checked the options in the 7-Zip source.

This post is licensed under CC BY 4.0 by the author.