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 initializes x 1

  • x<1000000 condition, loop run long x less 1000000

  • x++ increments x 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 o a = 1000000 wrong. need a=1000000

  • [ x < a]: here [ not support arithmetic operators <, need use -lt (less than), otherwise doing string comparison. need: [ "$x" -lt "$a" ]. consider using [[ builtin of bash instead of [. arithmetic operation can use (( too, allow use arithmetic operators

  • x =x + 1 syntax error, can not have whitespace around = while declaring variables mentioned earlier, + 1 after x meaning nothing , shell treat separate word (command) variable x=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

Popular posts from this blog

download - Firefox cannot save files (most of the time), how to solve? - Super User

windows - "-2146893807 NTE_NOT_FOUND" when repair certificate store - Super User

sql server - "Configuration file does not exist", Event ID 274 - Super User