Celeb Glow
general | March 18, 2026

using bash and curl to send file from server to client

so i am trying to solve this lab on deterlab.net. but i cant figure out exactly how to create my bash file with the curl instruction in order to created a web traffic stream between the client and the server nodes by writing a script at the client that each second gets index.html from the server. The full purpose of this lab is to create a DOS attack and flood the created traffic after. The attacking part i can manage but the bash file with the curl i cannot.this is what i have so far:

#!/bin/bash
# traffic between client and server
x=1
a = 1000000
while [ x < a]
do curl -o index.html x =x + 1
done

Can someone please help me ?

1 Answer

Leverage a C-style for looping construct:

#!/bin/bash
for ((x=1; x<1000000; x++)); do curl -o index.html
done

In ((x=1; x<1000000; x++)):

  • x=1 initializes x to 1

  • x<1000000 is the condition, the loop will run as long as x is less than 1000000

  • x++ increments x with adding 1 after each run of loop


You have some syntactic mistakes:

  • To refer to the value of a variable, you need $variable i.e. put the $ in front, also it is almost always desired to have quoting around that to prevent word splitting and glob expansion: "$variable"

  • There can't be any whitespace around = while declaring variables,s o a = 1000000 is wrong. You need a=1000000

  • [ x < a]: here [ does not support arithmetic operators like <, you need to use -lt (less than), otherwise it is just doing string comparison. You need: [ "$x" -lt "$a" ]. Also consider using the [[ builtin of bash instead of [. For arithmetic operation you can use (( too, this will allow you to use all the arithmetic operators

  • x =x + 1 is a syntax error, you can not have whitespace around = while declaring variables as mentioned earlier, also + 1 after x is meaning nothing and shell will treat it as separate word (command) with variable x=x in it's environment. you need (( x=x+1 )) or ((x+=1)) or simply (( x++ )).

So your script can take the final form:

#!/bin/bash
# traffic between client and server
x=1
a=1000000
while (( x < a )); do curl -o index.html (( x++ ))
done
7

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy