# picoCTF 2023 – useless

28 March 2023 – Written by Valentin Huber – in ctf, grep, and man

## Challenge

There’s an interesting script in the user’s home directory

Script content:

``````#!/bin/bash
# Basic mathematical operations via command-line arguments

if [ \$# != 3 ]
then
else
if [[ "\$1" == "add" ]]
then
sum=\$(( \$2 + \$3 ))
echo "The Sum is: \$sum"

elif [[ "\$1" == "sub" ]]
then
sub=\$(( \$2 - \$3 ))
echo "The Substract is: \$sub"

elif [[ "\$1" == "div" ]]
then
div=\$(( \$2 / \$3 ))
echo "The quotient is: \$div"

elif [[ "\$1" == "mul" ]]
then
mul=\$(( \$2 * \$3 ))
echo "The product is: \$mul"

else

fi
fi
``````

## Solution

The `Read the manual` line prompted me to do so:

``````man useless
``````
``````useless
useless, — This is a simple calculator script

SYNOPSIS
useless, [add sub mul div] number1 number2

DESCRIPTION
Use the useless, macro to make simple calulations like addition,subtraction, multiplication and di‐
vision.

Examples
This will add 1 and 2 and return 3

./useless mul 2 3
This will return 6 as a product of 2 and 3

./useless div 6 3
This will return 2 as a quotient of 6 and 3

./useless sub 6 5
This will return 1 as a remainder of substraction of 5 from 6

Authors
This script was designed and developed by Cylab Africa

picoCTF{us3l3ss_ch4ll3ng3_3xpl0it3d_1155}
``````