AUTHOR='@xer0dayz'
VULN_NAME='Arachni Vulnerability Scan - HTTP'
FILENAME="$LOOT_DIR/web/arachni-$TARGET-webscan-http.txt"
OUTPUT_NAME=$(echo $VULN_NAME | sed -E 's/[^[:alnum:]]+/_/g')

rm -f $LOOT_DIR/vulnerabilities/sc0pe-$TARGET-$OUTPUT_NAME.txt 2> /dev/null
rm -f /tmp/report.txt 2> /dev/null
touch /tmp/report.txt 2> /dev/null
x=0
cat $FILENAME 2> /dev/null | egrep 'Proof\:|URL\:|Severity\:|\[\+\]\ \[' | sed 's/\n//g' | sed -r 's/</\&lh\;/g' | awk '{print $3 " " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10 " " $11 " " $12 " " $13 " " $14 " " $15}' 2> /dev/null | tr -d '"' > /tmp/out 2> /dev/null

# DELETE FIRST LINE
sed -i '1d' /tmp/out 2> /dev/null

cat /tmp/out 2> /dev/null | while read line; do
  x=$(( x+1 ))
  if [ $x -eq "1" ]; then
    echo "$line," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
  elif [ $x -eq "2" ]; then
    if [[ $line =~ .*Critical.* ]]; then
      echo "P1 - CRITICAL," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
    elif [[ $line =~ .*High.* ]]; then
      echo "P2 - HIGH," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
    elif [[ $line =~ .*Medium.* ]]; then
      echo "P3 - MEDIUM," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
    elif [[ $line =~ .*Low.* ]]; then
      echo "P4 - LOW," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
    elif [[ $line =~ .*Informational.* ]]; then
      echo "P5 - INFO," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
    fi
  elif [ $x -eq "3" ]; then
    echo "$line," | tr -d '\n' >> /tmp/report.txt 2> /dev/null
  elif [ $x -eq "4" ]; then
    echo "$line" >> /tmp/report.txt 2> /dev/null
    x=0
  fi
done
cat /tmp/report.txt 2> /dev/null | awk -F',' '{print $2 ", " $1 ", " $3 ", " $4 " " $5 " " $6 " " $7 " " $8 " " $9 " " $10}' 2> /dev/null >> $LOOT_DIR/vulnerabilities/sc0pe-$TARGET-$OUTPUT_NAME.txt
cat $LOOT_DIR/vulnerabilities/sc0pe-$TARGET-$OUTPUT_NAME.txt 2> /dev/null