0

I'm trying to brute-force this pin in a challenge, The output of the nc localhost 30002 is: "Wrong! Please try Again" if its wrong. I wanted to put an IF condition to check if the output is different from "Wrong!" and stop the FOR loop

#!/bin/bash
for ((i=1000;i<10000;i++));
do
    echo "$i" | nc localhost 30002 >> /tmp/script_dir/output &
sleep 1
done
John Kugelman
  • 349,597
  • 67
  • 533
  • 578
Yuri Aps
  • 929
  • 8
  • 13

1 Answers1

0

Make the test you want within the for loop. If the desired condition is met, break

break [n]

Exit from a for, while, until, or select loop. If n is supplied, the nth enclosing loop is exited. n must be greater than or equal to 1. The return status is zero unless n is not greater than or equal to 1.

Community
  • 1
  • 1
JRFerguson
  • 7,426
  • 2
  • 32
  • 36