Monday, March 18, 2013

HTTP/HTTPs traffic generation with curl

I ran into a problem with https neg and one of my favorite http tool ( apache benchmark ). So I needed away to  generate http traffic for testing and review.

Here's a small script that uses curl;

#!/bin/bash
#
#

#rev 1.0

#  HTTP requester for traffic generation via curl
#  full http.request == HEAD
#
#  Be carefull not to flood any downwind DoS detector/WAFs, and be kind to your client sever(s)!
#
#
if [ ! $1 ]; then
            echo " Usage : http_requester.sh <delay in seconds between requests>  < The #of requests to execute> url1 url2 url3 url4 url5 "
            echo ""
            echo "Example  http_requester.sh 5 10 https://www.1example.com http://www.2example.com https://www.3example.com http://www.4example.com http://www.5example.com"
            echo ""
        echo " You can test upto 5 unique URLs & no more than 1K requests "

            exit 1
fi

#
i="0"

#

COUNTER=$2
MAX=1001

if  (( $2 >= $MAX )) ; then

        echo "   "
        echo "Please make a request range of <1000 or less"
        echo "   "
else


while [ $i -lt $COUNTER ] ;

  do  curl -k  -v --head --keepalive  -L {$3,$4,$5,$6,$7}
  echo "   "
  echo " Request # $i "
  echo "   "
  sleep $1

  echo "The request was completed, and $COUNTER http.requests was sent!"

  i=$[$i + 1]

#   let "COUNTER += 1"

done

fi

#



Ken Felix
Freelance Network/Security Engineer
kfelix a-t hyperfeed d-o-t com

No comments:

Post a Comment