|
CURL: directory_traversal.sh |
|
|
|
|
Wednesday, 23 September 2009 19:55 |
#!/bin/bash CURL=/sw/bin/curl
# a file with known pages, one URL per line URLFILE=pages.txt
# file descriptor 3 is our URLs 3<"${URLFILE}"
typeset -i FAILED
# for each URL in the URLFILE while read -u 3 URL do FAILED=0 # call curl to fetch the page. Get the headers, too. We're # interested in the first line that gives the status RESPONSE=$(${CURL} -D - -s "${URL}" | head -1) OIFS="$IFS" set - ${RESPONSE} result=$2 IFS="$OIFS"
# If we got something in the 200 series, it's probably a failure if [ $result -lt 300 ] then echo "FAIL: $result ${URL}" FAILED=${FAILED}+1 else # response in the 300 series is a redirect. Need to check manually if [ $result -lt 400 ] then echo "CHECK: $result ${URL}" FAILED=${FAILED}+1 else # response in the 400 series is some kind of # denial. That's generally considered "success" if [ $result -lt 500 ] then echo "PASS: $result ${URL}" else # response in the 500 series means server # failure. Anything we haven't already accounted for # will be called a failure. echo "FAIL: $result ${URL}" FAILED=${FAILED}+1 fi fi fi done
|