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=1initializesx1x<1000000condition, loop run longxless 1000000x++incrementsxadding 1 after each run of loop
you have syntactic mistakes:
to refer value of variable, need
$variablei.e. put$in front, desired have quoting around prevent word splitting , glob expansion:"$variable"there can't whitespace around
=while declaring variables,s oa = 1000000wrong. 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 ofbashinstead of[. arithmetic operation can use((too, allow use arithmetic operatorsx =x + 1syntax error, can not have whitespace around=while declaring variables mentioned earlier,+ 1afterxmeaning nothing , shell treat separate word (command) variablex=xin 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