using bash and curl to send file from server to client - Ask Ubuntu
so trying solve lab on deterlab.net. cant figure out how create bash file curl instruction in order created web traffic stream between client , server nodes writing script @ client each second gets index.html server. full purpose of lab create dos attack , flood created traffic after. attacking part can manage bash file curl cannot.this have far:
#!/bin/bash # traffic between client , server x=1 = 1000000 while [ x < a] curl -o index.html https://localhost/2389 x =x + 1 done
can please me ?
leverage c-style for
looping construct:
#!/bin/bash ((x=1; x<1000000; x++)); curl -o index.html https://localhost/2389 done
in ((x=1; x<1000000; x++))
:
x=1
initializesx
1x<1000000
condition, loop run longx
less 1000000x++
incrementsx
adding 1 after each run of loop
you have syntactic mistakes:
to refer value of variable, need
$variable
i.e. put$
in front, desired have quoting around prevent word splitting , glob expansion:"$variable"
there can't whitespace around
=
while declaring variables,s oa = 1000000
wrong. needa=1000000
[ x < a]
: here[
not support arithmetic operators<
, need use-lt
(less than), otherwise doing string comparison. need:[ "$x" -lt "$a" ]
. consider using[[
builtin ofbash
instead of[
. arithmetic operation can use((
too, allow use arithmetic operatorsx =x + 1
syntax error, can not have whitespace around=
while declaring variables mentioned earlier,+ 1
afterx
meaning nothing , shell treat separate word (command) variablex=x
in it's environment. need(( x=x+1 ))
or((x+=1))
or(( x++ ))
.
so script can take final form:
#!/bin/bash # traffic between client , server x=1 a=1000000 while (( x < )); curl -o index.html https://localhost/2389 (( x++ )) done
Comments
Post a Comment