Cowsays What CTF • A Beginner Linux Project

[read_meter]

Table of Contents

Want a beginner Linux CTF (Capture The Flag)? Moove over, here’s Cowsays What CTF. A simple question-based python program to test your beginner Linux level skills.

This simple CTF will use Linux commands to install a program, execute it and interact with it. Cowsays What CTF is inspired by TryHackMe and OverTheWire’s Bandit.

Disclaimer, if you need help getting started with Linux, see Linux Quick Start Guide.

Getting Started

Before you tackle the challenge, understand the scope, here’s what you need to know:

  • Challenge: 14 levels, 1 question per level, each question requires an answer.
  • Players: 1 (singleplayer).
  • Difficulty: Easy – new to Linux.
  • Environment: local Debian-based Linux installation e.g. Ubunutu in VirtualBox.
  • Commands: ls, sudo, cp, man.
  • Help: External research, in-game hints and walkthrough below.

To start, click the play button below, if there’s an issue, use the direct link (https://replit.com/@mrashleyball/cowsayswhatctf):

Edit
Edit

More CTFs in the works!

Enjoy the Cowsays What CTF challenge. If you need a bit more help, here’s what you need to do to play:

  1. Setup Linux however you like e.g. Ubuntu using VirtualBox or Kali via WSL.
  2. Use the Linux Quick Start Guide and open the terminal to start.
  3. Begin the Cowsays What CTF above by pressing the play button.
  4. If you’re stuck, see the Writeup below – spoiler warning.

About The Project

This is a fun side-project to practice basic Linux commands for users while also having an excuse to practice python, it’s a win-win project. If you’d like more detail, see Reflection below.

  • What is Cowsays What CTF? A simple python program running in a Replit terminal so it can be embedded and shared.
  • What’s a CTF? Capture The Flags are fun ways to learn tech skills in Cyber Security.
  • Is Cowsays What CTF really a CTF? Kind of, there are many different types of CTFs.
  • Why does Cowsays What CTF exist? For fun! It’s fun to learn, so both for the user and author (me)!
  • Who is Cowsays What CTF for? Anyone new to learning Linux commands and basic terminal interactions.

Free Checklist: Hacker's Learning Path

Offline checklist to track your learning path, become a great hacker and stay on task.

About The Program

Let’s break down the Cowsays What CTF program, a simple python program. It’s hosted via GitHub and distributed via Replit.

Here’s the pseudo-code:

#1 Welcome message, with instructions
#2 Control menu???
#3 Define help menu + Define hint menu
#4 Define answers
#5 Display questions(1-15), display expected input
#6 Auth user input

The goal was to use variables to not have so much duplicate code, it’s still a work in progress, any feedback is welcome. Here’s the welcome message and main variables:

cq = '[Research] What Linux program can make a cow say something?' # Current Question

print('''Welcome to Cowsays What CTF!! 
You'll have 14 questions to complete, use google, a Debian based Linux distro and a bash CLI.
Use 'help' to see the question again, and use 'hint' if you're stuck on the question.
Question 0: ''' + cq)

ui = ' ' # User Input
qc = 0 # Question Counter
hc = 0 # Hint Counter
h = ' '
a = ' ' # Answer

Here’s the main game loop and the hint and help menu.

# Help + Hint Menu
if ui == 'help' or ui == 'Help':
	print('[Help] You\\'re up to Question ' + str(qc) + ': ' + cq)
elif ui == 'hint' or ui == 'Hint':
	print('[Hint] ' + h + ' [Characters] ' + str((len(a))))

And here’s an example of the first question:

if qc == 0:
	a = 'cowsay'
	h = 'cowsay what?'
	ui = input('Answer Q' + str(qc) + ': ')
	if ui == a:
		print('[Answer] ' + a + ' - Good work!')
		qc +=1
		cq = 'How do you install the program?'
		print('Q' + str(qc) + ': ' + cq)

If you have feedback or any suggestions, feel free to reach out or fork via GitHub. If you’d like to learn Python, feel free to check out Intro To Python • Free Python Starter Guide and the various Python projects like Is It Raining?, Mad Lib Game, Username Generator, Random Number Generator, Bagels, and ZigZag.

Cowsays What CTF Writeup

Okay, warning, spoilers ahead.

  1. [Research] What Linux program can make a cow say something?
    • [Hint] cowsay what?
    • [Answer] cowsay
  2. How do you install the program?
    • [H] Debiasn-based systems: sudo <package manager> install <program>
    • [A] sudo apt install cowsay
  3. How do you execute (or run) the program?
    • [H] Type <program> and a message, use CTRL + C if needed. You may need to use /usr/games/<program>…
    • [A] cowsay
  4. What other program was installed?
    • [H] List /usr/games – don’t say, think.
    • [A] cowthink
  5. How do you access the manual page for this program?
    • [H] man I wonder how…
    • [A] man cowsay
  6. How do you make the cow moo?
    • [H] <program> <argument>
    • [A] cowsay moo
  7. Using the man page, how do you have the cow moo and appear dead?
    • [H] Read the man page and use the - before a letter e.g. cowsay -h
    • [A] cowsay -d moo
  8. Using the same format, how do you make the cow moo and appear paranoid?
    • [H] Use the same format as you just did cowsay -<letter> moo
    • [A] cowsay -p moo
  9. Using the same format, how do you make the cow moo and appear greedy?
    • [H] Use the same format as you just did cowsay -<letter> moo
    • [A] cowsay -g moo
  10. How do you display a list of other cows (if you can call them cows)?
    • [H] man, if only there was a help page!
    • [A] cowsay -l
  11. How do you make a dragon say raw?
    • [H] man, if only there was a help page!
    • [A] cowsay -f dragon raw
  12. How do you make a turtle say hello?
    • [H] man, if only there was a help page!
    • [A] cowsay -f turtle hello
  13. How do you make the cow wink it’s right eye and say moo?
    • [H] Use the - symbol and a captial O for the eyes string – there’s a switch you need.
    • [A] cowsay -e -O moo
  14. [Research] How do you make the cow’s tounge look like this () and say moo?
    • [H] Hm, this is wiki hard.
    • [A] cowsay -T \\(\\) moo

Reflection

Cowsays What CTF has been a fun mini project to think up and publish, I’ve really enjoyed it. I’m also learning Linux and Python, so I’m always looking for fun projects to practice at my current skill level.

I love teaching IT, so I can’t help but focus on projects that help others learn. Building a python program about learning Linux is a good way to learn python and Linux, it’s a circle.

I’m also fascinated with CTFs, I grew up playing video games so learning CyberSec in a gamified format is a no-brainer. Recently I read DarkStar’s Making The Mountain [video] which really opened my eyes to the world of constructing Cyber Security training.

I guess this is something I really want to do more of and this is my first step toward it! I hope you enjoy it. Thanks and helpful links Wiki – cowsay, Have a cow at the Linux command line, and Linux Unhatched Course Notes.

This is Day 43 of #100DaysOfHacking , subscribe to my newsletter to see the CyberSec journey! If you like, follow the Learning Path for yourself, happy hacking.

About The Author
Ashley Ball

Ashley Ball

“Learn, create, share, repeat.” • IT teacher, former web designer, learning CyberSec • Road to #100DaysOfHacking on Hackers Learning Path.
Share This Article
LinkedIn
Twitter
Facebook
WhatsApp
Email

Monthly Newsletter

Learn about cyber security, hacking guides & python programming.

Leave A Comment

Leave a Reply

Your email address will not be published.

More Content

Monthly Newsletter

Learn about cyber security, hacking guides & python programming.

This site uses cookies and other tracking technologies to assist with navigation, monitor site usage and web traffic, assist with our promotional and marketing efforts, and customize and improve our services, as set out in our privacy policy