#!/bin/bash
out=/var/www/html/ve360web/files/_scan2.out
: > $out
find /var/www/html/ve360web -type f ! -name "*.zip" -size -3M > /tmp/flist.txt 2>/dev/null
echo "files=$(wc -l < /tmp/flist.txt)" >> $out
split -n l/20 /tmp/flist.txt /tmp/fl_
for f in /tmp/fl_*; do
  echo "== chunk $f" >> $out
  xargs -a $f -r grep -Il -E "AKIA[0-9A-Z]{16}|ASIA[0-9A-Z]{16}|aws_secret_access_key|aws_access_key_id|private_key_id|service_account" 2>/dev/null >> $out
done
echo "== ENVFILES" >> $out
xargs -a /tmp/flist.txt -r grep -l -E "DB_PASSWORD|DB_USER|APP_KEY|MAIL_PASSWORD|S3_|AWS_" 2>/dev/null | head -60 >> $out
echo ALLDONE >> $out
